Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) CUPSGetDefault(ctx context.Context, attrs []string) (*ipp.PrinterAttributes, error)
- func (c *Client) CUPSGetDevices(ctx context.Context, sel *GetDevicesSelection, attrs []string) ([]*ipp.DeviceAttributes, error)
- func (c *Client) CUPSGetPPD(ctx context.Context, printerURI, ppdName string) (body io.ReadCloser, seeOtherURI string, err error)
- func (c *Client) CUPSGetPPDs(ctx context.Context, filter *ipp.PPDFilter) ([]*ipp.PPDAttributes, error)
- func (c *Client) CUPSGetPrinters(ctx context.Context, sel *GetPrintersSelection, attrs []string) ([]*ipp.PrinterAttributes, error)
- type GetDevicesSelection
- type GetPrintersSelection
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultUNIXURL is the default CUPS socket URL using // UNIX domain sockets DefaultUNIXURL = transport.MustParseURL("unix:/var/run/cups/cups.sock") // DefaultLocalhostURL is the default CUPS socket URL using // Localhost TCP connection DefaultLocalhostURL = transport.MustParseURL("ipp://localhost/") )
Default URLs
var ( DefaultGetPrintersSelection = &GetPrintersSelection{} DefaultGetDevicesSelection = &GetDevicesSelection{ Timeout: DefaultGetDevicesTimeout, } DefaultGetDevicesTimeout = 5 * time.Second )
Default values for common types:
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client represents the CUPS client.
func NewClient ¶
NewClient creates a new CUPS client.
If tr is nil, transport.NewTransport will be used to create a new transport.
func (*Client) CUPSGetDefault ¶
func (c *Client) CUPSGetDefault(ctx context.Context, attrs []string) (*ipp.PrinterAttributes, error)
CUPSGetDefault returns information on default printer. The attrs attribute allows to specify list of requested attributes.
func (*Client) CUPSGetDevices ¶
func (c *Client) CUPSGetDevices(ctx context.Context, sel *GetDevicesSelection, attrs []string) ( []*ipp.DeviceAttributes, error)
CUPSGetDevices performs search for available devices and returns found devices.
If GetDevicesSelection argument is not nil, it allows to specify a subset of devices to be returned.
The attrs attribute allows to specify list of requested attributes.
func (*Client) CUPSGetPPD ¶
func (c *Client) CUPSGetPPD(ctx context.Context, printerURI, ppdName string) ( body io.ReadCloser, seeOtherURI string, err error)
CUPSGetPPD requests PPD file by printer URI or the PPD file name.
It returns one of the following:
- non-nil body where requested PPD file can be read from
- nil body and non-empty seeOtherURI string, that specify the printer URI that can serve the request
- nil body, empty seeOtherURI and non-nil err in a case of error.
If non-nil body returned, caller MUST close it after use.
func (*Client) CUPSGetPPDs ¶
func (c *Client) CUPSGetPPDs(ctx context.Context, filter *ipp.PPDFilter) ([]*ipp.PPDAttributes, error)
CUPSGetPPDs requests information about PPD files available at the server.
If filter is nil, all PPDs will be returned (the response could be really large at this case).
func (*Client) CUPSGetPrinters ¶
func (c *Client) CUPSGetPrinters(ctx context.Context, sel *GetPrintersSelection, attrs []string) ( []*ipp.PrinterAttributes, error)
CUPSGetPrinters returns printer attributes for printers known to the system.
If GetPrintersSelection argument is not nil, it allows to specify a subset of printers to be returned.
The attrs attribute allows to specify list of requested attributes.
type GetDevicesSelection ¶
type GetDevicesSelection struct {
// ExcludeSchemes and IncludeSchemes specifies which schemes
// to include into output.
//
// CUPS supports the following schemes:
// - http, https
// - ipp, ipps
// - lpd
// - smb
// - socket
//
// This list may change and actually depends on installed backends.
//
// By default, CUPS returns all available schemes. If ExcludeSchemes
// is not empty, schemes listed there are excluded. If IncludeSchemes
// is not empty, schemes not listed there are not included.
ExcludeSchemes, IncludeSchemes []string
// If not zero, specifies maximum number of devices to be returned.
Limit int
// Timeout, if set, specifies a maximum search time.
//
// Note, Timeout is rounded up to a whole number of seconds.
// If not set, CUPS server default is used.
Timeout time.Duration
}
GetDevicesSelection configures a selection of devices returned by Client.CUPSGetDevices.
type GetPrintersSelection ¶
type GetPrintersSelection struct {
// Printer name (also, queue name) is the unique name, under
// which printer is registered in the CUPS system.
//
// If this parameter is not empty, it specifies the first printer
// name to be returned.
FirstPrinterName string
// If not zero, specifies maximum number of printers to be returned.
Limit int
// Each printer in the CUPS system has its own PrinterID,
// which is system-unique positive number, assigned to the
// printer when it is added to the system.
//
// If this parameter is not zero, only the printer with specified
// ID (and matching other criteria) will be returned.
PrinterID int
// PrinterLocation is the arbitrary string which can be
// configured on the printer device by owner or system
// administrator. Its purpose is to simplify selection of
// particular devices in a big network. It corresponds to the
// "printer-location" IPP attribute and may sound like
// "Printers on 1st floor" or "Printers at reception".
//
// If this parameter is not empty, only devices with the specified
// locatiom will be returned.
PrinterLocation string
// TODO
PrinterType int
PrinterTypeMask int
// If not empty, only printers accessible to that user will
// be returned. User name is the user's **login** name,
User string
}
GetPrintersSelection configures a selection of printers returned by Client.CUPSGetPrinters.