octoprint

package module
v0.0.0-...-1c443b6 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 12 Imported by: 0

README

go-octoprint Build Status GoDoc

Go library for accessing the OctoPrint's REST API.

Installation

The recommended way to install go-octoprint

go get github.com/mcuadros/go-octoprint

Example

Retrieving the current connection state:
client, _ := NewClient("<octoprint-url>", "<api-key>")

r := octoprint.ConnectionRequest{}
s, err := r.Do(client)
if err != nil {
  log.Error("error requesting connection state: %s", err)
}

fmt.Printf("Connection State: %q\n", s.Current.State)
Retrieving current temperature for bed and extruders:
r := octoprint.StateRequest{}
s, err := r.Do(c)
if err != nil {
	log.Error("error requesting state: %s", err)
}

fmt.Println("Current Temperatures:")
for tool, state := range s.Temperature.Current {
	fmt.Printf("- %s: %.1f°C / %.1f°C\n", tool, state.Actual, state.Target)
}

Implemented Methods

Version Information
  • GET /api/version
Apps
  • GET /apps/auth
  • POST /apps/auth
Connection Operations
  • GET /api/connection
  • POST /api/connection
File Operations
  • GET `/api/files
  • GET /api/files/<location>
  • POST /api/files/<location>
  • GET /api/files/<location>/<filename>
  • POST /api/files/<location>/<path> (Only select command)
  • DELETE /api/files/<location>/<path>
Job Operations
  • POST /api/job
  • GET /api/job
Languages
  • GET /api/languages
  • POST /api/languages
  • DELETE /api/languages/<locale>/<pack>
Log file management
  • GET /api/logs
  • DELETE /api/logs/<filename>
Printer Operations
  • GET /api/printer
  • POST /api/printer/printhead
  • POST /api/printer/tool
  • GET /api/printer/tool
  • POST /api/printer/bed
  • GET /api/printer/bed
  • POST /api/printer/sd
  • GET /api/printer/sd
  • POST /api/printer/command
  • GET /api/printer/command/custom (un-documented at REST API)
Printer profile operations
  • GET /api/printerprofiles
  • POST /api/printerprofiles
  • PATCH /api/printerprofiles/<profile>
  • DELETE /api/printerprofiles/<profile>
Settings
  • GET /api/settings
  • POST /api/settings
  • POST /api/settings/apikey
Slicing
  • GET /api/slicing
  • GET /api/slicing/<slicer>/profiles
  • GET /api/slicing/<slicer>/profiles/<key>
  • PUT /api/slicing/<slicer>/profiles/<key>
  • DELETE /api/slicing/<slicer>/profiles/<key>
System
  • GET /api/system/commands
  • GET /api/system/commands/<source>
  • POST /api/system/commands/<source>/<action>
Timelapse
  • GET /api/timelapse
  • DELETE /api/timelapse/<filename>
  • POST /api/timelapse/unrendered/<name>
  • DELETE /api/timelapse/unrendered/<name>
  • POST /api/timelapse
User
  • GET /api/users
  • GET /api/users/<username>
  • POST /api/users
  • PUT /api/users/<username>
  • DELETE /api/users/<username>
  • PUT /api/users/<username>/password
  • GET /api/users/<username>/settings
  • PATCH /api/users/<username>/settings
  • POST /api/users/<username>/apikey
  • DELETE /api/users/<username>/apikey
Util
  • POST /api/util/test
Wizard
  • GET /setup/wizard
  • POST /setup/wizard

License

MIT, see LICENSE

Documentation

Index

Constants

View Source
const (
	URIPrinter       = "/api/printer"
	URIPrintHead     = "/api/printer/printhead"
	URIPrintTool     = "/api/printer/tool"
	URIPrintBed      = "/api/printer/bed"
	URIPrintSD       = "/api/printer/sd"
	URICommand       = "/api/printer/command"
	URICommandCustom = "/api/printer/command/custom"
)
View Source
const JobTool = "/api/job"
View Source
const URIConnection = "/api/connection"
View Source
const URISettings = "/api/settings"
View Source
const URISystemCommands = "/api/system/commands"
View Source
const URIVersion = "/api/version"

Variables

View Source
var (
	FilesLocationGETErrors = statusMapping{
		404: "Location is neither local nor sdcard",
	}
	FilesLocationPOSTErrors = statusMapping{
		400: "No file or foldername are included in the request, userdata was provided but could not be parsed as JSON or the request is otherwise invalid.",
		404: "Location is neither local nor sdcard or trying to upload to SD card and SD card support is disabled",
		409: "The upload of the file would override the file that is currently being printed or if an upload to SD card was requested and the printer is either not operational or currently busy with a print job.",
		415: "The file is neither a gcode nor an stl file (or it is an stl file but slicing support is disabled)",
		500: "The upload failed internally",
	}
	FilesLocationPathPOSTErrors = statusMapping{
		400: "The command is unknown or the request is otherwise invalid",
		415: "A slice command was issued against something other than an STL file.",
		404: "Location is neither local nor sdcard or the requested file was not found",
		409: "Selected file is supposed to start printing directly but the printer is not operational or if a file to be sliced is supposed to be selected or start printing directly but the printer is not operational or already printing.",
	}
	FilesLocationDeleteErrors = statusMapping{
		404: "Location is neither local nor sdcard",
		409: "The file to be deleted is currently being printed",
	}
)
View Source
var (
	PrintErrors = statusMapping{
		409: "Printer is not operational",
	}
	PrintHeadJobErrors = statusMapping{
		400: "Invalid axis specified, invalid value for travel amount for a jog command or factor for feed rate or otherwise invalid request",
		409: "Printer is not operational or currently printing",
	}
	PrintToolErrors = statusMapping{
		400: "Targets or offsets contains a property or tool contains a value not matching the format tool{n}, the target/offset temperature, extrusion amount or flow rate factor is not a valid number or outside of the supported range, or if the request is otherwise invalid",
		409: "Printer is not operational",
	}
	PrintBedErrors = statusMapping{
		409: "Printer is not operational or the selected printer profile does not have a heated bed.",
	}
	PrintSDErrors = statusMapping{
		404: "SD support has been disabled in OctoPrint’s settings.",
		409: "SD card has not been initialized.",
	}
)
View Source
var ConnectionErrors = statusMapping{
	400: "The selected port or baudrate for a connect command are not part of the available option",
}
View Source
var ErrUnauthorized = errors.New("Missing or invalid API key")

ErrUnauthorized missing or invalid API key

View Source
var ExecuteErrors = statusMapping{
	404: "The command could not be found for source and action",
	500: "The command didn’t define a command to execute, the command returned a non-zero return code and ignore was not true or some other internal server error occurred",
}
View Source
var JobToolErrors = statusMapping{
	409: "Printer is not operational or the current print job state does not match the preconditions for the command.",
}
View Source
var Version = "0.1"

Functions

This section is empty.

Types

type APIConfig

type APIConfig struct {
	// Enabled whether to enable the API.
	Enabled bool `json:"enabled"`
	// Key current API key needed for accessing the API
	Key string `json:"key"`
}

APIConfig REST API settings.

type Axis

type Axis string
const (
	XAxis Axis = "x"
	YAxis Axis = "y"
	ZAxis Axis = "z"
)

type BedOffsetRequest

type BedOffsetRequest struct {
	// Offset is offset to set.
	Offset int `json:"offset"`
}

BedOffsetRequest sets the given temperature offset on the printer’s bed.

func (*BedOffsetRequest) Do

func (cmd *BedOffsetRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type BedStateRequest

type BedStateRequest struct {
	// History if true retrieve the temperature history.
	History bool
	// Limit limtis amount of returned history data points.
	Limit int
}

BedStateRequest retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target, timestamp) for the printer’s heated bed.

It’s also possible to retrieve the temperature history by supplying the history query parameter set to true. The amount of returned history data points can be limited using the limit query parameter.

func (*BedStateRequest) Do

func (cmd *BedStateRequest) Do(c *Client) (*TemperatureState, error)

Do sends an API request and returns the API response.

type BedTargetRequest

type BedTargetRequest struct {
	// Target temperature to set.
	Target float64 `json:"target"`
}

BedTargetRequest sets the given target temperature on the printer’s bed.

func (*BedTargetRequest) Do

func (cmd *BedTargetRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type CancelRequest

type CancelRequest struct{}

CancelRequest cancels the current print job.

func (*CancelRequest) Do

func (cmd *CancelRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type Client

type Client struct {
	// Endpoint address to the OctoPrint REST API server.
	Endpoint string
	// APIKey used to connect to the OctoPrint REST API server.
	APIKey string
	// contains filtered or unexported fields
}

A Client manages communication with the OctoPrint API.

func NewClient

func NewClient(endpoint, apiKey string) *Client

NewClient returns a new OctoPrint API client with provided base URL and API Key. If baseURL does not have a trailing slash, one is added automatically. If `Access Control` is enabled at OctoPrint configuration an apiKey should be provided (http://docs.octoprint.org/en/master/api/general.html#authorization).

type CommandDefinition

type CommandDefinition struct {
	// Name of the command to display in the System menu.
	Name string `json:"name"`
	// Command is the full command line to execute for the command.
	Command string `json:"command"`
	// Action is an identifier to refer to the command programmatically. The
	// special `action` string divider signifies a `divider` in the menu.
	Action string `json:"action"`
	// Confirm if present and set, this text will be displayed to the user in a
	// confirmation dialog they have to acknowledge in order to really execute
	// the command.
	RawConfirm json.RawMessage `json:"confirm"`
	Confirm    string          `json:"-"`
	// Async whether to execute the command asynchronously or wait for its
	// result before responding to the HTTP execution request.
	Async bool `json:"async"`
	// Ignore whether to ignore the return code of the command’s execution.
	Ignore bool `json:"ignore"`
	// Source of the command definition.
	Source CommandSource `json:"source"`
	// Resource is the URL of the command to use for executing it.
	Resource string `json:"resource"`
}

CommandDefinition describe a system command.

type CommandRequest

type CommandRequest struct {
	// Commands list of commands to send to the printer.
	Commands []string `json:"commands"`
}

CommandRequest sends any command to the printer via the serial interface. Should be used with some care as some commands can interfere with or even stop a running print job.

func (*CommandRequest) Do

func (cmd *CommandRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type CommandSource

type CommandSource string

CommandSource is the source of the command definition.

const (
	// Core for system actions defined by OctoPrint itself.
	Core CommandSource = "core"
	// Custom for custom system commands defined by the user through `config.yaml`.
	Custom CommandSource = "custom"
)

type ConnectRequest

type ConnectRequest struct {
	// Port specific port to connect to. If not set the current `portPreference`
	// will be used, or if no preference is available auto detection will be
	// attempted.
	Port string `json:"port,omitempty"`
	// BaudRate specific baudrate to connect with. If not set the current
	// `baudratePreference` will be used, or if no preference is available auto
	// detection will be attempted.
	BaudRate int `json:"baudrate,omitempty"`
	// PrinterProfile specific printer profile to use for connection. If not set
	// the current default printer profile will be used.
	PrinterProfile string `json:"printerProfile,omitempty"`
	// Save whether to save the request’s port and baudrate settings as new
	// preferences.
	Save bool `json:"save"`
	// Autoconnect whether to automatically connect to the printer on
	// OctoPrint’s startup in the future.
	Autoconnect bool `json:"autoconnect"`
}

ConnectRequest sets the given target temperature on the printer’s tools.

func (*ConnectRequest) Do

func (cmd *ConnectRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type ConnectionRequest

type ConnectionRequest struct{}

ConnectionRequest Retrieve the current connection settings, including information regarding the available baudrates and serial ports and the current connection state.

func (*ConnectionRequest) Do

Do sends an API request and returns the API response.

type ConnectionResponse

type ConnectionResponse struct {
	Current struct {
		// State current state of the connection.
		State ConnectionState `json:"state"`
		// Port to connect to.
		Port string `json:"port"`
		// BaudRate speed of the connection.
		BaudRate int `json:"baudrate"`
		// PrinterProfile profile to use for connection.
		PrinterProfile string `json:"printerProfile"`
	}
	Options struct {
		// Ports list of available ports.
		Ports []string `json:"ports"`
		// BaudRates list of available speeds.
		BaudRates []int `json:"baudrates"`
		// PrinterProfile list of available profiles.
		PrinterProfiles []*Profile `json:"printerProfiles"`
		// PortPreference default port.
		PortPreference string `json:"portPreference"`
		// BaudRatePreference default speed.
		BaudRatePreference int `json:"baudratePreference"`
		// PrinterProfilePreference default profile.
		PrinterProfilePreference string `json:"printerProfilePreference"`
		// Autoconnect whether to automatically connect to the printer on
		// OctoPrint’s startup in the future.
		Autoconnect bool `json:"autoconnect"`
	}
}

ConnectionResponse is the response from a connection command.

type ConnectionState

type ConnectionState string
const (
	Operational ConnectionState = "Operational"
)

func (ConnectionState) IsConnecting

func (s ConnectionState) IsConnecting() bool

func (ConnectionState) IsError

func (s ConnectionState) IsError() bool

func (ConnectionState) IsOffline

func (s ConnectionState) IsOffline() bool

func (ConnectionState) IsOperational

func (s ConnectionState) IsOperational() bool

func (ConnectionState) IsPrinting

func (s ConnectionState) IsPrinting() bool

type ControlContainer

type ControlContainer struct {
	// Name to display above the container, basically a section header.
	Name string `json:"name"`
	// Children a list of children controls or containers contained within this
	// container.
	Children []*ControlDefinition `json:"children"`
	// Layout  to use for laying out the contained children, either from top to
	// bottom (`vertical`) or from left to right (`horizontal“). Defaults to a
	// vertical layout.
	Layout string `json:"layout"`
}

ControlContainer describes a control container.

type ControlDefinition

type ControlDefinition struct {
	// Name of the control, will be displayed either on the button if it’s a
	// control sending a command or as a label for controls which only display
	// output.
	Name string `json:"name"`
	// Command a single GCODE command to send to the printer. Will be rendered
	// as a button which sends the command to the printer upon click. The button
	// text will be the value of the `name` attribute. Mutually exclusive with
	// `commands` and `script`. The rendered button be disabled if the printer
	// is currently offline or printing or alternatively if the requirements
	// defined via the `enabled` attribute are not met.
	Command string `json:"command"`
	// Command a list of GCODE commands to send to the printer. Will be rendered
	// as a button which sends the commands to the printer upon click. The
	// button text will be the value of the `name` attribute. Mutually exclusive
	// with `command` and `script`. The rendered button will be disabled if the
	// printer is currently offline or printing or alternatively if the
	// requirements defined via the `enabled` attribute are not met.
	Commands []string `json:"commands"`
	// Script is the name of a full blown GCODE script to send to the printer.
	// Will be rendered as a button which sends the script to the printer upon
	// click. The button text will be the value of the name attribute. Mutually
	// exclusive with `command` and `commands`. The rendered button will be
	// disabled if the printer is currently offline or printing or alternatively
	// if the requirements defined via the `enabled“ attribute are not met.
	//
	// Values of input parameters will be available in the template context
	// under the `parameter` variable (e.g. an input parameter speed will be
	// available in the script template as parameter.speed). On top of that all
	// other variables defined in the GCODE template context will be available.
	Script string `json:"script"`
	// JavaScript snippet to be executed when the button rendered for `command`
	// or `commands` is clicked. This allows to override the direct sending of
	// the command or commands to the printer with more sophisticated behaviour.
	// The JavaScript snippet is `eval`’d and processed in a context where the
	// control it is part of is provided as local variable `data` and the
	// `ControlViewModel` is available as self.
	JavasScript string `json:"javascript"`
	// Enabled a JavaScript snippet to be executed when the button rendered for
	// `command` or `commands` is clicked. This allows to override the direct
	// sending of the command or commands to the printer with more sophisticated
	// behaviour. The JavaScript snippet is `eval`’d and processed in a context
	// where the control it is part of is provided as local variable `data` and
	// the `ControlViewModel` is available as `self`.
	Enabled bool `json:"enabled"`
	// Input a list of definitions of input parameters for a command or
	// commands, to be rendered as additional input fields.
	Input *ControlInput `json:"input"`
	// Regex a regular expression to match against lines received from the
	// printer to retrieve information from it (e.g. specific output). Together
	// with template this allows rendition of received data from the printer
	// within the UI.
	Regex string `json:"regex"`
	// Template to use for rendering the match of `regex`. May contain
	// placeholders in Python Format String Syntax[1] for either named groups
	// within the regex (e.g. `Temperature: {temperature}` for a regex
	// `T:\s*(?P<temperature>\d+(\.\d*)`) or positional groups within the regex
	// (e.g. `Position: X={0}, Y={1}, Z={2}, E={3}` for a regex
	// `X:([0-9.]+) Y:([0-9.]+) Z:([0-9.]+) E:([0-9.]+)`).
	// https://docs.python.org/2/library/string.html#format-string-syntax
	Template string `json:"template"`
	// Confirm a text to display to the user to confirm his button press. Can
	// be used with sensitive custom controls like changing EEPROM values in
	// order to prevent accidental clicks.
	Confirm string `json:"confirm"`
}

ControlDefinition describe a system control.

type ControlInput

type ControlInput struct {
	// Name to display for the input field.
	Name string `json:"name"`
	// Parameter name for the input field, used as a placeholder in
	// command/commands.
	Parameter string `json:"parameter"`
	// Default value for the input field.
	Default interface{} `json:"default"`
	// Slider if defined instead of an input field a slider control will be
	// rendered.
	Slider struct {
		// Minimum value of the slider, defaults to 0.
		Min int `json:"min"`
		// Maximum value of the slider, defaults to 255.
		Maximum int `json:"max"`
		// Step size per slider “tick”, defaults to 1.
		Step int `json:"step"`
	} `json:"slider"`
}

ControlInput a list of definitions of input parameters for a command or commands, to be rendered as additional input fields.

type CustomCommandsRequest

type CustomCommandsRequest struct{}

CustomCommandsRequest retrieves all configured system controls.

func (*CustomCommandsRequest) Do

Do sends an API request and returns the API response.

type CustomCommandsResponse

type CustomCommandsResponse struct {
	Controls []*ControlContainer `json:"controls"`
}

CustomCommandsResponse is the response to a CustomCommandsRequest.

type DeleteFileRequest

type DeleteFileRequest struct {
	// Location is the target location on which to delete the file, either
	// `local` (for OctoPrint’s uploads folder) or \sdcard\ for the printer’s
	// SD card (if available)
	Location Location
	// Path of the file to delete
	Path string
}

DeleteFileRequest delete the selected path on the selected location.

func (*DeleteFileRequest) Do

func (req *DeleteFileRequest) Do(c *Client) error

Do sends an API request and returns error if any.

type DisconnectRequest

type DisconnectRequest struct{}

DisconnectRequest instructs OctoPrint to disconnect from the printer.

func (*DisconnectRequest) Do

func (cmd *DisconnectRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type FakesACKRequest

type FakesACKRequest struct{}

FakesACKRequest fakes an acknowledgment message for OctoPrint in case one got lost on the serial line and the communication with the printer since stalled.

This should only be used in “emergencies” (e.g. to save prints), the reason for the lost acknowledgment should always be properly investigated and removed instead of depending on this “symptom solver”.

func (*FakesACKRequest) Do

func (cmd *FakesACKRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type FeaturesConfig

type FeaturesConfig struct {
	// SizeThreshold maximum size a GCODE file may have to automatically be
	// loaded into the viewer, defaults to 20MB. Maps to
	// gcodeViewer.sizeThreshold in config.yaml.
	SizeThreshold uint64
	// MobileSizeThreshold maximum size a GCODE file may have on mobile devices
	// to automatically be loaded into the viewer, defaults to 2MB. Maps to
	// gcodeViewer.mobileSizeThreshold in config.yaml.
	MobileSizeThreshold uint64 `json:"mobileSizeThreshold"`
	// TemperatureGraph whether to enable the temperature graph in the UI or not.
	TemperatureGraph bool `json:"temperatureGraph"`
	// WaitForStart specifies whether OctoPrint should wait for the start
	// response from the printer before trying to send commands during connect.
	WaitForStart bool `json:"waitForStart"`
	// AlwaysSendChecksum specifies whether OctoPrint should send linenumber +
	// checksum with every printer command. Needed for successful communication
	// with Repetier firmware.
	AlwaysSendChecksum bool `json:"alwaysSendChecksum"`
	NeverSendChecksum  bool `json:"neverSendChecksum"`
	// SDSupport specifies whether support for SD printing and file management
	// should be enabled
	SDSupport bool `json:"sdSupport"`
	// SDAlwaysAvailable whether to always assume that an SD card is present in
	// the printer. Needed by some firmwares which don't report the SD card
	// status properly.
	SDAlwaysAvailable bool `json:"sdAlwaysAvailable"`
	// SDReleativePath Specifies whether firmware expects relative paths for
	// selecting SD files.
	SDRelativePath bool `json:"sdRelativePath"`
	// SwallowOkAfterResend whether to ignore the first ok after a resend
	// response. Needed for successful communication with Repetier firmware.
	SwallowOkAfterResend bool `json:"swallowOkAfterResend"`
	// RepetierTargetTemp whether the printer sends repetier style target
	// temperatures in the format `TargetExtr0:<temperature>` instead of
	// attaching that information to the regular M105 responses.
	RepetierTargetTemp bool `json:"repetierTargetTemp"`
	// ExternalHeatupDetection whether to enable external heatup detection (to
	// detect heatup triggered e.g. through the printer's LCD panel or while
	// printing from SD) or not. Causes issues with Repetier's "first ok then
	// response" approach to communication, so disable for printers running
	// Repetier firmware.
	ExternalHeatupDetection bool `json:"externalHeatupDetection"`
	// KeyboardControl whether to enable the keyboard control feature in the
	// control tab.
	KeyboardControl bool `json:"keyboardControl"`
	// PollWatched whether to actively poll the watched folder (true) or to rely
	// on the OS's file system notifications instead (false).
	PollWatched bool `json:"pollWatched"`
	// IgnoreIdenticalResends whether to ignore identical resends from the
	// printer (true, repetier) or not (false).
	IgnoreIdenticalResends bool `json:"ignoreIdenticalResends"`
	// ModelSizeDetection whether to enable model size detection and warning
	// (true) or not (false)
	ModelSizeDetection bool `json:"modelSizeDetection"`
	// FirmwareDetection whether to attempt to auto detect the firmware of the
	// printer and adjust settings  accordingly (true) or not and rely on manual
	// configuration (false)
	FirmwareDetection bool `json:"firmwareDetection"`
	// PrintCancelConfirmation whether to show a confirmation on print
	// cancelling (true) or not (false).
	PrintCancelConfirmation bool `json:"printCancelConfirmation"`
	// BlockWhileDwelling whether to block all sending to the printer while a G4
	// (dwell) command is active (true, repetier) or not (false).
	BlockWhileDwelling bool `json:"blockWhileDwelling"`
}

FeaturesConfig settings to enable or disable OctoPrint features.

type FileInformation

type FileInformation struct {
	// Name is name of the file without path. E.g. “file.gco” for a file
	// “file.gco” located anywhere in the file system.
	Name string `json:"name"`
	// Path is the path to the file within the location. E.g.
	//“folder/subfolder/file.gco” for a file “file.gco” located within “folder”
	// and “subfolder” relative to the root of the location.
	Path string `json:"path"`
	// Type of file. model or machinecode. Or folder if it’s a folder, in
	// which case the children node will be populated.
	Type string `json:"type"`
	// TypePath path to type of file in extension tree. E.g. `["model", "stl"]`
	// for .stl files, or `["machinecode", "gcode"]` for .gcode files.
	// `["folder"]` for folders.
	TypePath []string `json:"typePath"`
	// Hash is the MD5 hash of the file. Only available for `local` files.
	Hash string `json:"hash"`
	// Size of the file in bytes. Only available for `local` files or `sdcard`
	// files if the printer supports file sizes for sd card files.
	Size uint64 `json:"size"`
	// Date when this file was uploaded. Only available for `local` files.
	Date JSONTime `json:"date"`
	// Origin of the file, `local` when stored in OctoPrint’s `uploads` folder,
	// `sdcard` when stored on the printer’s SD card (if available)
	Origin string `json:"origin"`
	// Refs references relevant to this file, left out in abridged versio
	Refs Reference `json:"refs"`
	// GCodeAnalysis information from the analysis of the GCODE file, if
	// available. Left out in abridged version.
	GCodeAnalysis GCodeAnalysisInformation `json:"gcodeAnalysis"`
	// Print information from the print stats of a file.
	Print PrintStats `json:"print"`
	// Contained children for entries of type folder. On non-recursive listings only present on first level sub folders!
	Children []*FileInformation `json:"children"`
}

FileInformation contains information regarding a file.

func (*FileInformation) IsFolder

func (f *FileInformation) IsFolder() bool

IsFolder it returns true if the file is a folder.

type FileRequest

type FileRequest struct {
	// Location of the file for which to retrieve the information, either
	// `local` or `sdcard`.
	Location Location
	// Filename of the file for which to retrieve the information
	Filename string
	// Recursive if set to true, return all files and folders recursively.
	// Otherwise only return items on same level.
	Recursive bool
}

FileRequest retrieves the selected file’s or folder’s information.

func (*FileRequest) Do

func (cmd *FileRequest) Do(c *Client) (*FileInformation, error)

Do sends an API request and returns the API response

type FilesRequest

type FilesRequest struct {
	// Location is the target location .
	Location Location
	// Recursive if set to true, return all files and folders recursively.
	// Otherwise only return items on same level.
	Recursive bool
}

FilesRequest retrieve information regarding all files currently available and regarding the disk space still available locally in the system.

func (*FilesRequest) Do

func (cmd *FilesRequest) Do(c *Client) (*FilesResponse, error)

Do sends an API request and returns the API response.

type FilesResponse

type FilesResponse struct {
	// Files is the list of requested files. Might be an empty list if no files
	// are available
	Files []*FileInformation
	// Free is the amount of disk space in bytes available in the local disk
	// space (refers to OctoPrint’s `uploads` folder). Only returned if file
	// list was requested for origin `local` or all origins.
	Free uint64
}

FilesResponse is the response to a FilesRequest.

type FolderConfig

type FolderConfig struct {
	// Uploads absolute path where to store gcode uploads. Defaults to the
	// uploads folder in the OctoPrint settings folder.
	Uploads string `json:"uploads"`
	// Timelapse absolute path where to store finished timelapse recordings.
	// Defaults to the timelapse folder in the OctoPrint settings dir.
	Timelapse string `json:"timelapse"`
	// TimelapseTmp absolute path where to store temporary timelapse files.
	// Defaults to the timelapse/tmp folder in the OctoPrint settings dir Maps
	// to folder.timelapse_tmp in config.yaml.
	TimelapseTmp string `json:"timelapseTmp"`
	// Logs absolute path where to store log files. Defaults to the logs folder
	// in the OctoPrint settings dir
	Logs string `json:"logs"`
	// Watched absolute path to a folder being watched for new files which then
	// get automatically added to OctoPrint (and deleted from that folder).
	// Can e.g. be used to define a folder which can then be mounted from remote
	// machines and used as local folder for quickly adding downloaded and/or
	// sliced objects to print in the future.
	Watched string `json:"watched"`
}

FolderConfig settings to set custom paths for folders used by OctoPrint.

type FullStateResponse

type FullStateResponse struct {
	//Temperature is the printer’s temperature state data.
	Temperature TemperatureState `json:"temperature"`
	// SD is the printer’s sd state data.
	SD SDState `json:"sd"`
	// State is the printer’s general state.
	State PrinterState `json:"state"`
}

FullStateResponse contains informantion about the current state of the printer.

type GCodeAnalysisInformation

type GCodeAnalysisInformation struct {
	// EstimatedPrintTime is the estimated print time of the file, in seconds.
	EstimatedPrintTime float64 `json:"estimatedPrintTime"`
	// Filament estimated usage of filament
	Filament struct {
		// Length estimated of filament used, in mm
		Length uint32 `json:"length"`
		// Volume estimated of filament used, in cm³
		Volume float64 `json:"volume"`
	} `json:"filament"`
}

GCodeAnalysisInformation Information from the analysis of the GCODE file.

type HistoricTemperatureData

type HistoricTemperatureData historicTemperatureData

HistoricTemperatureData is temperature historic stats for a tool.

func (*HistoricTemperatureData) UnmarshalJSON

func (h *HistoricTemperatureData) UnmarshalJSON(b []byte) error

type JSONTime

type JSONTime struct{ time.Time }

func (JSONTime) MarshalJSON

func (t JSONTime) MarshalJSON() ([]byte, error)

func (*JSONTime) UnmarshalJSON

func (t *JSONTime) UnmarshalJSON(s []byte) (err error)

type JobInformation

type JobInformation struct {
	// File is the file that is the target of the current print job.
	File FileInformation `json:"file"`
	// EstimatedPrintTime is the estimated print time for the file, in seconds.
	EstimatedPrintTime float64 `json:"estimatedPrintTime"`
	// LastPrintTime is the print time of the last print of the file, in seconds.
	LastPrintTime float64 `json:"lastPrintTime"`
	// Filament contains Information regarding the estimated filament
	// usage of the print job.
	Filament struct {
		// Length of filament used, in mm
		Length float64 `json:"length"`
		// Volume of filament used, in cm³
		Volume float64 `json:"volume"`
	} `json:"filament"`
	FilePosition uint64 `json:"filepos"`
}

JobInformation contains information regarding the target of the current job.

type JobRequest

type JobRequest struct{}

JobRequest retrieve information about the current job (if there is one).

func (*JobRequest) Do

func (cmd *JobRequest) Do(c *Client) (*JobResponse, error)

Do sends an API request and returns the API response.

type JobResponse

type JobResponse struct {
	// Job contains information regarding the target of the current print job.
	Job JobInformation `json:"job"`
	// Progress contains information regarding the progress of the current job.
	Progress ProgressInformation `json:"progress"`
}

JobResponse is the response from a job command.

type Location

type Location string
const (
	URIFiles = "/api/files"

	Local  Location = "local"
	SDCard Location = "sdcard"
)

type PauseAction

type PauseAction string
const (
	// Pause the current job if it’s printing, does nothing if it’s already paused.
	Pause PauseAction = "pause"
	// Resume the current job if it’s paused, does nothing if it’s printing.
	Resume PauseAction = "resume"
	// Toggle the pause state of the job, pausing it if it’s printing and
	// resuming it if it’s currently paused.
	Toggle PauseAction = "toggle"
)

type PauseRequest

type PauseRequest struct {
	// Action specifies which action to take.
	// In order to stay backwards compatible to earlier iterations of this API,
	// the default action to take if no action parameter is supplied is to
	// toggle the print job status.
	Action PauseAction `json:"action"`
}

PauseRequest pauses/resumes/toggles the current print job.

func (*PauseRequest) Do

func (cmd *PauseRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type PrintHeadHomeRequest

type PrintHeadHomeRequest struct {
	// Axes is a list of axes which to home.
	Axes []Axis `json:"axes"`
}

PrintHeadHomeRequest homes the print head in all of the given axes.

func (*PrintHeadHomeRequest) Do

func (cmd *PrintHeadHomeRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type PrintHeadJogRequest

type PrintHeadJogRequest struct {
	// X is the amount distance to travel in mm or coordinate to jog print head
	// on x axis.
	X int `json:"x,omitempty"`
	// Y is the amount distance to travel in mm or coordinate to jog print head
	// on y axis.
	Y int `json:"y,omitempty"`
	// Z is the amount distance to travel in mm.or coordinate to jog print head
	// on x axis.
	Z int `json:"z,omitempty"`
	// Absolute is whether to move relative to current position (provided axes
	// values are relative amounts) or to absolute position (provided axes
	// values are coordinates)
	Absolute bool `json:"absolute"`
	// Speed at which to move in mm/s. If not provided, minimum speed for all
	// selected axes from printer profile will be used.
	Speed int `json:"speed,omitempty"`
}

PrintHeadJogRequest jogs the print head (relatively) by a defined amount in one or more axes.

func (*PrintHeadJogRequest) Do

func (cmd *PrintHeadJogRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type PrintStats

type PrintStats struct {
	// Failure number of failed prints.
	Failure int `json:"failure"`
	// Success number of success prints.
	Success int `json:"success"`
	// Last print information.
	Last struct {
		// Date of the last print.
		Date JSONTime `json:"date"`
		// Success or not.
		Success bool `json:"success"`
	} `json:"last"`
}

PrintStats information from the print stats of a file.

type PrinterState

type PrinterState struct {
	Text  string `json:"text"`
	Flags struct {
		Operations    bool `json:"operational"`
		Paused        bool `json:"paused"`
		Printing      bool `json:"printing"`
		SDReady       bool `json:"sdReady"`
		Error         bool `json:"error"`
		Ready         bool `json:"ready"`
		ClosedOnError bool `json:"closedOrError"`
	} `json:"flags"`
}

PrinterState current state of the printer.

type Profile

type Profile struct {
	// ID is the identifier of the profile.
	ID string `json:"id"`
	// Name is the display name of the profile.
	Name string `json:"name"`
}

Profile describe a printer profile.

type ProgressInformation

type ProgressInformation struct {
	// Completion percentage of completion of the current print job.
	Completion float64 `json:"completion"`
	// FilePosition current position in the file being printed, in bytes
	// from the beginning.
	FilePosition uint64 `json:"filepos"`
	// PrintTime is time already spent printing, in seconds
	PrintTime float64 `json:"printTime"`
	// PrintTimeLeft is estimate of time left to print, in seconds
	PrintTimeLeft float64 `json:"printTimeLeft"`
}

ProgressInformation contains information regarding the progress of the current print job.

type Reference

type Reference struct {
	// Resource that represents the file or folder (e.g. for issuing commands
	// to or for deleting)
	Resource string `json:"resource"`
	// Download URL for the file. Never present for folders.
	Download string `json:"download"`
	// Model from which this file was generated (e.g. an STL, currently not
	// used). Never present for folders.
	Model string `json:"model"`
}

Reference of a file.

type RestartRequest

type RestartRequest struct{}

RestartRequest restart the print of the currently selected file from the beginning. There must be an active print job for this to work and the print job must currently be paused

func (*RestartRequest) Do

func (cmd *RestartRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type SDInitRequest

type SDInitRequest struct{}

SDInitRequest initializes the printer’s SD card, making it available for use. This also includes an initial retrieval of the list of files currently stored on the SD card.

func (*SDInitRequest) Do

func (cmd *SDInitRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type SDRefreshRequest

type SDRefreshRequest struct{}

SDRefreshRequest Refreshes the list of files stored on the printer’s SD card.

func (*SDRefreshRequest) Do

func (cmd *SDRefreshRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type SDReleaseRequest

type SDReleaseRequest struct{}

SDReleaseRequest releases the SD card from the printer. The reverse operation to init. After issuing this command, the SD card won’t be available anymore, hence and operations targeting files stored on it will fail.

func (*SDReleaseRequest) Do

func (cmd *SDReleaseRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type SDState

type SDState struct {
	Ready bool `json:"ready"`
}

SDState is the state of the sd reader.

type SDStateRequest

type SDStateRequest struct{}

SDStateRequest retrieves the current state of the printer’s SD card. For this request no authentication is needed.

func (*SDStateRequest) Do

func (cmd *SDStateRequest) Do(c *Client) (*SDState, error)

Do sends an API request and returns the API response.

type SelectFileRequest

type SelectFileRequest struct {
	// Location is target location on which to send the command for is located,
	// either local (for OctoPrint’s uploads folder) or sdcard for the
	// printer’s SD card (if available)
	Location Location `json:"-"`
	// Path  of the file for which to issue the command
	Path string `json:"-"`
	// Print, if set to true the file will start printing directly after
	// selection. If the printer is not operational when this parameter is
	// present and set to true, the request will fail with a response of
	// 409 Conflict.
	Print bool `json:"print"`
}

SelectFileRequest selects a file for printing.

func (*SelectFileRequest) Do

func (cmd *SelectFileRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type SerialConfig

type SerialConfig struct {
	// Port is the default serial port, defaults to unset (= AUTO)
	Port string `json:"port"`
	// Baudrate is the default baudrate, defaults to unset (= AUTO)
	Baudrate int `json:"baudrate"`
	// 	Available serial ports
	PortOptions []string `json:"portOptions"`
	//	Available serial baudrates
	BaudrateOptions []int `json:"baudrateOptions"`
	// Autoconnect whether to automatically connect to the printer on server
	// startup (if available).
	Autoconnect bool `json:"autoconnect"`
	// TimeoutConnection for waiting to establish a connection with the selected
	// port, in seconds. Defaults to 2 sec. Maps to serial.timeout.connection in
	// config.yaml
	TimeoutConnection float64 `json:"timeoutConnection"`
	// TimeoutDetection for waiting for a response from the currently tested
	// port during autodetect, in seconds. Defaults to 0.5 sec Maps to
	// serial.timeout.detection in config.yaml
	TimeoutDetection float64 `json:"timeoutDetection"`
	// TimeoutCommunication during serial communication, in seconds. Defaults to
	// 30 sec. Maps to serial.timeout.communication in config.yaml
	TimeoutCommunication float64 `json:"timeoutCommunication"`
	// TimeoutTemperature after which to query temperature when no target is
	// set. Maps to serial.timeout.temperature in config.yaml
	TimeoutTemperature float64 `json:"timeoutTemperature"`
	// TimeoutTemperatureTargetSet after which to query temperature when a
	// target is set. Maps to serial.timeout.temperatureTargetSet in config.yaml
	TimeoutTemperatureTargetSet float64 `json:"timeoutTemperatureTargetSet"`
	// TimeoutSDStatus after which to query the SD status while SD printing.
	// Maps to serial.timeout.sdStatus in config.yaml
	TimeoutSDStatus float64 `json:"timeoutSdStatus"`
	// Log whether to log whole communication to serial.log (warning: might
	// decrease performance)
	Log bool `json:"log"`
	// AdditionalPorts use this to define additional patterns to consider for
	// serial port listing. Must be a valid "glob" pattern (see
	// http://docs.python.org/2/library/glob.html). Defaults to not set.
	AdditionalPorts []string `json:"additionalPorts"`
	// AdditionalBaudrates use this to define additional baud rates to offer for
	// connecting to serial ports. Must be a valid integer. Defaults to not set
	AdditionalBaudrates []int `json:"additionalBaudrates"`
	// LongRunningCommands which are known to take a long time to be
	// acknowledged by the firmware. E.g. homing, dwelling, auto leveling etc.
	LongRunningCommands []string `json:"longRunningCommands"`
	// ChecksumRequiringCommands which need to always be send with a checksum.
	// Defaults to only M110
	ChecksumRequiringCommands []string `json:"checksumRequiringCommands"`
	// HelloCommand to send in order to initiate a handshake with the printer.
	// Defaults to "M110 N0" which simply resets the line numbers in the
	// firmware and which should be acknowledged with a simple "ok".
	HelloCommand string `json:"helloCommand"`
	// IgnoreErrorsFromFirmware whether to completely ignore errors from the
	// firmware or not
	IgnoreErrorsFromFirmware bool `json:"ignoreErrorsFromFirmware"`
	// DisconnectOnErrors whether to disconnect on errors or not.
	DisconnectOnErrors bool `json:"disconnectOnErrors"`
	// TriggerOkForM29 whether to "manually" trigger an ok for M29 (a lot of
	// versions of this command are buggy and the responds skips on the ok)
	TriggerOkForM29 bool `json:"triggerOkForM29"`
	// SupportResendsWIthoutOk whether to support resends without follow-up ok
	// or not.
	SupportResendsWIthoutOk string `json:"supportResendsWIthoutOk"`
	// Maps to serial.maxCommunicationTimeouts.idle in config.yaml
	MaxTimeoutsIdle float64 `json:"maxTimeoutsIdle"`
	// MaxTimeoutsPrinting maximum number of consecutive communication timeouts
	// after which the printer will be considered dead and OctoPrint disconnects
	// with an error. Maps to serial.maxCommunicationTimeouts.printing in
	// config.yaml
	MaxTimeoutsPrinting float64 `json:"maxTimeoutsPrinting"`
	// MaxTimeoutsPrinting maximum number of consecutive communication timeouts
	// after which the printer will be considered dead and OctoPrint disconnects
	// with an error. Maps to serial.maxCommunicationTimeouts.log in config.yaml
	MaxTimeoutsLong float64 `json:"maxTimeoutsLong"`
}

SerialConfig settings to configure the serial connection to the printer.

type ServerConfig

type ServerConfig struct {
	// Commands to restart/shutdown octoprint or the system it's running on.
	Commands struct {
		// ServerRestartCommand to restart OctoPrint, defaults to being unset
		ServerRestartCommand string `json:"serverRestartCommand"`
		//SystemRestartCommand  to restart the system OctoPrint is running on,
		// defaults to being unset
		SystemRestartCommand string `json:"systemRestartCommand"`
		// SystemShutdownCommand Command to shut down the system OctoPrint is
		// running on, defaults to being unset
		SystemShutdownCommand string `json:"systemShutdownCommand"`
	} `json:"commands"`
	// Diskspace settings of when to display what disk space warning
	Diskspace struct {
		// Warning threshold (bytes) after which to consider disk space becoming
		// sparse, defaults to 500MB.
		Warning uint64 `json:"warning"`
		// Critical threshold (bytes) after which to consider disk space becoming
		// critical, defaults to 200MB.
		Critical uint64 `json:"critical"`
	} `json:"diskspace"`
	// OnlineCheck configuration of the regular online connectivity check.
	OnlineCheck struct {
		// Enabled whether the online check is enabled, defaults to false due to
		// valid privacy concerns.
		Enabled bool `json:"enabled"`
		// Interval in which to check for online connectivity (in seconds)
		Interval int `json:"interval"`
		// Host DNS host against which to check (default: 8.8.8.8 aka Google's DNS)
		Host string `json:"host"`
		// DNS port against which to check (default: 53 - the default DNS port)
		Port int `json:"port"`
	} `json:"onlineCheck"`
	// PluginBlacklist configuration of the plugin blacklist
	PluginBlacklist struct {
		// Enabled whether use of the blacklist is enabled, defaults to false
		Enabled bool `json:"enabled"`
		/// URL from which to fetch the blacklist
		URL string `json:"url"`
		// TTL is time to live of the cached blacklist, in secs (default: 15mins)
		TTL int `json:"ttl"`
	} `json:"pluginBlacklist"`
}

ServerConfig settings to configure the server.

type Settings

type Settings struct {
	// API REST API settings.
	API *APIConfig `json:"api"`
	// Features settings to enable or disable OctoPrint features.
	Feature *FeaturesConfig `json:"feature"`
	//Folder settings to set custom paths for folders used by OctoPrint.
	Folder *FolderConfig `json:"folder"`
	// Serial settings to configure the serial connection to the printer.
	Serial *SerialConfig `json:"serial"`
	// Server settings to configure the server.
	Server *ServerConfig `json:"server"`
	// Temperature profiles which will be displayed in the temperature tab.
	Temperature *TemperatureConfig `json:"temperature"`
	// TerminalFilters to display in the terminal tab for filtering certain
	// lines from the display terminal log.
	TerminalFilters []*TerminalFilter `json:"terminalFilters"`
	// Webcam settings to configure webcam support.
	Webcam *WebcamConfig `json:"webcam"`

	// Un-handled values
	Appearance interface{} `json:"appearance"`
	Plugins    interface{} `json:"plugins"`
	Printer    interface{} `json:"printer"`
}

Settings are the current configuration of OctoPrint.

type SettingsRequest

type SettingsRequest struct{}

SettingsRequest retrieves the current configuration of OctoPrint.

func (*SettingsRequest) Do

func (cmd *SettingsRequest) Do(c *Client) (*Settings, error)

Do sends an API request and returns the API response.

type StartRequest

type StartRequest struct{}

StartRequest starts the print of the currently selected file.

func (*StartRequest) Do

func (cmd *StartRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type StateRequest

type StateRequest struct {
	// History if true retrieve the temperature history.
	History bool
	// Limit limtis amount of returned history data points.
	Limit int
	// Exclude list of fields to exclude from the response (e.g. if not
	// needed by the client). Valid values to supply here are `temperature`,
	// `sd` and `state`.
	Exclude []string
}

StateRequest retrieves the current state of the printer.

func (*StateRequest) Do

func (cmd *StateRequest) Do(c *Client) (*FullStateResponse, error)

Do sends an API request and returns the API response.

type SystemCommandsRequest

type SystemCommandsRequest struct{}

SystemCommandsRequest retrieves all configured system commands.

func (*SystemCommandsRequest) Do

Do sends an API request and returns the API response.

type SystemCommandsResponse

type SystemCommandsResponse struct {
	Core   []*CommandDefinition `json:"core"`
	Custom []*CommandDefinition `json:"custom"`
}

SystemCommandsResponse is the response to a SystemCommandsRequest.

type SystemExecuteCommandRequest

type SystemExecuteCommandRequest struct {
	// Source for which to list commands.
	Source CommandSource `json:"source"`
	// Action is the identifier of the command, action from its definition.
	Action string `json:"action"`
}

SystemExecuteCommandRequest retrieves all configured system commands.

func (*SystemExecuteCommandRequest) Do

Do sends an API request and returns an error if any.

type TemperatureConfig

type TemperatureConfig struct {
	// Graph cutoff in minutes.
	Cutoff int `json:"cutoff"`
	// Profiles  which will be displayed in the temperature tab.
	Profiles []*TemperatureProfile `json:"profiles"`
	// SendAutomatically enable this to have temperature fine adjustments you
	// do via the + or - button be sent to the printer automatically.
	SendAutomatically bool `json:"sendAutomatically"`
	// SendAutomaticallyAfter OctoPrint will use this delay to limit the number
	// of sent temperature commands should you perform multiple fine adjustments
	// in a short time.
	SendAutomaticallyAfter float64 `json:"sendAutomaticallyAfter"`
}

TemperatureConfig temperature profiles which will be displayed in the temperature tab.

type TemperatureData

type TemperatureData struct {
	// Actual current temperature.
	Actual float64 `json:"actual"`
	// Target temperature, may be nil if no target temperature is set.
	Target float64 `json:"target"`
	// Offset currently configured temperature offset to apply, will be left
	// out for historic temperature information.
	Offset float64 `json:"offset"`
}

TemperatureData is temperature stats for a tool.

type TemperatureProfile

type TemperatureProfile struct {
	Name     string  `json:"name"`
	Bed      float64 `json:"bed"`
	Extruder float64 `json:"extruder"`
}

TemperatureProfile describes the temperature profile preset for a given material.

type TemperatureState

type TemperatureState temperatureState

TemperatureState is the printer’s temperature state data.

func (*TemperatureState) UnmarshalJSON

func (r *TemperatureState) UnmarshalJSON(b []byte) error

type TerminalFilter

type TerminalFilter struct {
	Name  string `json:"name"`
	RegEx string `json:"regex"`
}

TerminalFilter to display in the terminal tab for filtering certain lines from the display terminal log.

type ToolExtrudeRequest

type ToolExtrudeRequest struct {
	// Amount is the amount of filament to extrude in mm. May be negative to
	// retract.
	Amount int `json:"amount"`
}

ToolExtrudeRequest extrudes the given amount of filament from the currently selected tool.

func (*ToolExtrudeRequest) Do

func (cmd *ToolExtrudeRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type ToolFlowrateRequest

type ToolFlowrateRequest struct {
	// Factor is the new factor, percentage as integer, between 75 and 125%.
	Factor int `json:"factor"`
}

ToolFlowrateRequest changes the flow rate factor to apply to extrusion of the tool.

func (*ToolFlowrateRequest) Do

func (cmd *ToolFlowrateRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type ToolOffsetRequest

type ToolOffsetRequest struct {
	// Offset is offset(s) to set, key must match the format tool{n} with n
	// being the tool’s index starting with 0.
	Offsets map[string]float64 `json:"offsets"`
}

ToolOffsetRequest sets the given temperature offset on the printer’s tools.

func (*ToolOffsetRequest) Do

func (cmd *ToolOffsetRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type ToolSelectRequest

type ToolSelectRequest struct {
	// Tool to select, format tool{n} with n being the tool’s index starting
	// with 0.
	Tool string `json:"tool"`
}

ToolSelectRequest selects the printer’s current tool.

func (*ToolSelectRequest) Do

func (cmd *ToolSelectRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type ToolStateRequest

type ToolStateRequest struct {
	// History if true retrieve the temperature history.
	History bool
	// Limit limtis amount of returned history data points.
	Limit int
}

ToolStateRequest retrieves the current temperature data (actual, target and offset) plus optionally a (limited) history (actual, target, timestamp) for all of the printer’s available tools.

func (*ToolStateRequest) Do

Do sends an API request and returns the API response.

type ToolTargetRequest

type ToolTargetRequest struct {
	// Target temperature(s) to set, key must match the format tool{n} with n
	// being the tool’s index starting with 0.
	Targets map[string]float64 `json:"targets"`
}

ToolTargetRequest sets the given target temperature on the printer’s tools.

func (*ToolTargetRequest) Do

func (cmd *ToolTargetRequest) Do(c *Client) error

Do sends an API request and returns an error if any.

type UploadFileRequest

type UploadFileRequest struct {
	// Location is the target location to which to upload the file. Currently
	// only `local` and `sdcard` are supported here, with local referring to
	// OctoPrint’s `uploads` folder and `sdcard` referring to the printer’s
	// SD card. If an upload targets the SD card, it will also be stored
	// locally first.
	Location Location
	// Select whether to select the file directly after upload (true) or not
	// (false). Optional, defaults to false. Ignored when creating a folder.
	Select bool
	//Print whether to start printing the file directly after upload (true) or
	// not (false). If set, select is implicitely true as well. Optional,
	// defaults to false. Ignored when creating a folder.
	Print bool
	// contains filtered or unexported fields
}

UploadFileRequest uploads a file to the selected location or create a new empty folder on it.

func (*UploadFileRequest) AddFile

func (req *UploadFileRequest) AddFile(filename string, r io.Reader) error

AddFile adds a new file to be uploaded from a given reader.

func (*UploadFileRequest) AddFolder

func (req *UploadFileRequest) AddFolder(folder string) error

AddFolder adds a new folder to be created.

func (*UploadFileRequest) Do

Do sends an API request and returns the API response.

type UploadFileResponse

type UploadFileResponse struct {
	// Abridged information regarding the file that was just uploaded. If only
	// uploaded to local this will only contain the local property. If uploaded
	// to SD card, this will contain both local and sdcard properties. Only
	// contained if a file was uploaded, not present if only a new folder was
	// created.
	File struct {
		// Local is the information regarding the file that was just uploaded
		// to the local storage.
		Local *FileInformation `json:"local"`
		// SDCard is the information regarding the file that was just uploaded
		// to the printer’s SD card.
		SDCard *FileInformation `json:"sdcard"`
	} `json:"files"`
	// Done whether any file processing after upload has already finished or
	// not, e.g. due to first needing to perform a slicing step. Clients may
	// use this information to direct progress displays related to the upload.
	Done bool `json:"done"`
}

UploadFileResponse is the response to a UploadFileRequest.

type VersionRequest

type VersionRequest struct{}

VersionRequest retrieve information regarding server and API version.

func (*VersionRequest) Do

func (cmd *VersionRequest) Do(c *Client) (*VersionResponse, error)

Do sends an API request and returns the API response.

type VersionResponse

type VersionResponse struct {
	// API is the API version.
	API string `json:"api"`
	// Server is the server version.
	Server string `json:"server"`
}

VersionResponse is the response from a job command.

type WebcamConfig

type WebcamConfig struct {
	// StreamUrl use this option to enable display of a webcam stream in the
	// UI, e.g. via MJPG-Streamer. Webcam support will be disabled if not
	// set. Maps to webcam.stream in config.yaml.
	StreamURL string `json:"streamUrl"`
	// SnapshotURL use this option to enable timelapse support via snapshot,
	// e.g. via MJPG-Streamer. Timelapse support will be disabled if not set.
	// Maps to webcam.snapshot in config.yaml.
	SnapshotURL string `json:"snapshotUrl"`
	// FFmpegPath path to ffmpeg binary to use for creating timelapse
	// recordings. Timelapse support will be disabled if not set. Maps to
	// webcam.ffmpeg in config.yaml.
	FFmpegPath string `json:"ffmpegPath"`
	// Bitrate to use for rendering the timelapse video. This gets directly
	// passed to ffmpeg.
	Bitrate string `json:"bitrate"`
	// FFmpegThreads number of how many threads to instruct ffmpeg to use for
	// encoding. Defaults to 1. Should be left at 1 for RPi1.
	FFmpegThreads int `json:"ffmpegThreads"`
	// Watermark whether to include a "created with OctoPrint" watermark in the
	// generated timelapse movies.
	Watermark bool `json:"watermark"`
	// FlipH whether to flip the webcam horizontally.
	FlipH bool `json:"flipH"`
	// FlipV whether to flip the webcam vertically.
	FlipV bool `json:"flipV"`
	// Rotate90 whether to rotate the webcam 90° counter clockwise.
	Rotate90 bool `json:"rotate90"`
}

WebcamConfig settings to configure webcam support.

Directories

Path Synopsis
_examples

Jump to

Keyboard shortcuts

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