gcp

package
v0.0.0-...-fc9add8 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2020 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Overview

Package gcp is the Google Cloud Print API client.

Index

Constants

View Source
const (

	// OAuth constants.
	RedirectURL     = "oob"
	ScopeCloudPrint = "https://www.googleapis.com/auth/cloudprint"
	ScopeGoogleTalk = "https://www.googleapis.com/auth/googletalk"
	AccessType      = "offline"

	// Printer Notification channel constants.
	FCP_CHANNEL  = "FCM_CHANNEL"
	XMPP_CHANNEL = "XMPP_CHANNEL"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GoogleCloudPrint

type GoogleCloudPrint struct {
	// contains filtered or unexported fields
}

GoogleCloudPrint is the interface between Go and the Google Cloud Print API.

func NewGoogleCloudPrint

func NewGoogleCloudPrint(baseURL, robotRefreshToken, userRefreshToken, proxyName, oauthClientID, oauthClientSecret, oauthAuthURL, oauthTokenURL string, maxConcurrentDownload uint, jobs chan<- *lib.Job, useFcm bool) (*GoogleCloudPrint, error)

NewGoogleCloudPrint establishes a connection with GCP, returns a new GoogleCloudPrint object.

func (*GoogleCloudPrint) CanShare

func (gcp *GoogleCloudPrint) CanShare() bool

CanShare answers the question "can we share printers when they are registered?"

func (*GoogleCloudPrint) Control

func (gcp *GoogleCloudPrint) Control(jobID string, state *cdd.PrintJobStateDiff) error

Control calls google.com/cloudprint/control to set the state of a GCP print job.

func (*GoogleCloudPrint) Delete

func (gcp *GoogleCloudPrint) Delete(gcpID string) error

Delete calls google.com/cloudprint/delete to delete a printer from GCP.

func (*GoogleCloudPrint) DeleteJob

func (gcp *GoogleCloudPrint) DeleteJob(gcpJobID string) error

DeleteJob calls google.com/cloudprint/deletejob to delete a print job.

func (*GoogleCloudPrint) Download

func (gcp *GoogleCloudPrint) Download(dst io.Writer, url string) error

Download downloads a URL (a print job data file) directly to a Writer.

func (*GoogleCloudPrint) FcmSubscribe

func (gcp *GoogleCloudPrint) FcmSubscribe(subscribeUrl string) (interface{}, error)

FCM Subscribe.

func (*GoogleCloudPrint) Fetch

func (gcp *GoogleCloudPrint) Fetch(gcpID string) ([]Job, error)

Fetch calls google.com/cloudprint/fetch to get the outstanding print jobs for a GCP printer.

func (*GoogleCloudPrint) GetRobotAccessToken

func (gcp *GoogleCloudPrint) GetRobotAccessToken() (string, error)

func (*GoogleCloudPrint) HandleJobs

func (gcp *GoogleCloudPrint) HandleJobs(printer *lib.Printer, reportJobFailed func())

HandleJobs gets and processes jobs waiting on a printer.

func (*GoogleCloudPrint) Jobs

func (gcp *GoogleCloudPrint) Jobs(gcpID string) ([]Job, error)

Jobs calls google.com/cloudprint/jobs to get print jobs for a GCP printer.

func (*GoogleCloudPrint) List

func (gcp *GoogleCloudPrint) List() (map[string]string, error)

List calls google.com/cloudprint/list to get all GCP printers assigned to this connector.

Returns map of GCPID => printer name. GCPID is unique to GCP; printer name should be unique to CUPS. Use Printer to get details about each printer.

func (*GoogleCloudPrint) ListPrinters

func (gcp *GoogleCloudPrint) ListPrinters() ([]lib.Printer, map[string]uint, error)

ListPrinters calls gcp.List, then calls gcp.Printer, one goroutine per printer. This is a fast way to fetch all printers with corresponding CDD info, which the List API does not provide.

The second return value is a map of GCPID -> queued print job quantity.

func (*GoogleCloudPrint) Printer

func (gcp *GoogleCloudPrint) Printer(gcpID string) (*lib.Printer, uint, error)

Printer gets the printer identified by it's GCPID.

The second return value is queued print job quantity.

func (*GoogleCloudPrint) ProximityToken

func (gcp *GoogleCloudPrint) ProximityToken(gcpID, user string) ([]byte, int, error)

ProximityToken gets a proximity token for Privet users to access a printer through the cloud.

Returns byte array of raw JSON to preserve any/all returned fields and returned HTTP status code.

func (*GoogleCloudPrint) Register

func (gcp *GoogleCloudPrint) Register(printer *lib.Printer) error

Register calls google.com/cloudprint/register to register a GCP printer.

Sets the GCPID field in the printer arg.

func (*GoogleCloudPrint) Share

func (gcp *GoogleCloudPrint) Share(gcpID, shareScope string, role Role, skip_notification bool, public bool) error

Share calls google.com/cloudprint/share to share a registered GCP printer.

func (*GoogleCloudPrint) Ticket

func (gcp *GoogleCloudPrint) Ticket(gcpJobID string) (*cdd.CloudJobTicket, error)

Ticket gets a ticket, aka print job options.

func (*GoogleCloudPrint) Unshare

func (gcp *GoogleCloudPrint) Unshare(gcpID, shareScope string, public bool) error

Unshare calls google.com/cloudprint/unshare to unshare a registered GCP printer.

func (*GoogleCloudPrint) Update

func (gcp *GoogleCloudPrint) Update(diff *lib.PrinterDiff) error

Update calls google.com/cloudprint/update to update a GCP printer.

type Job

type Job struct {
	GCPPrinterID  string
	GCPJobID      string
	FileURL       string
	OwnerID       string
	Title         string
	SemanticState *cdd.PrintJobState
}

type Role

type Role string

Role is the role a user or group is granted when sharing a printer.

const (
	User    Role = "USER"
	Manager Role = "MANAGER"
	Owner   Role = "OWNER"
)

Jump to

Keyboard shortcuts

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