anydesk

package module
v0.0.0-...-763e480 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2018 License: BSD-3-Clause Imports: 12 Imported by: 2

README

anydesk

AnyDesk REST API Client for Go

Docs: https://godoc.org/github.com/emmaly/anydesk

Review the anydesktool code in the cmd directory in this repository for example usage.

Documentation

Index

Constants

View Source
const (
	DirectionAny = ""
	DirectionIn  = "in"
	DirectionOut = "out"
)

Direction constants

Variables

View Source
var (
	ErrMissingAPIKey    = errors.New("missing API Key")
	ErrMissingLicenseID = errors.New("missing License ID")
	ErrBadResourceField = errors.New("bad resource field")
)

Errors

View Source
var (
	SortClientID     = "cid"
	SortAlias        = "alias"
	SortOnline       = "online"
	SortClientIDFrom = "from.cid"
	SortClientIDTo   = "to.cid"
	SortTimeStart    = "start-time"
	SortTimeEnd      = "end-time"
	SortDuration     = "duration"
)

Sort constants

Functions

This section is empty.

Types

type AnyDesk

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

AnyDesk is an AnyDesk API client

func New

func New(apiKey, licenseID string, o *Options) (*AnyDesk, error)

New returns a new AnyDesk API client

func (*AnyDesk) AuthTest

func (a *AnyDesk) AuthTest() (*GenericResult, error)

AuthTest tests to see if auth is working

func (*AnyDesk) Client

func (a *AnyDesk) Client(id int) (*Client, error)

Client returns data about a specific client

func (*AnyDesk) ClientAlias

func (a *AnyDesk) ClientAlias(id int, alias string) error

ClientAlias sets the alias for a specific client

func (*AnyDesk) Clients

func (a *AnyDesk) Clients(opts *ClientsOptions) (*Clients, error)

Clients gets a list of individual AnyDesk-powered clients attached to this license

func (*AnyDesk) Session

func (a *AnyDesk) Session(id int) (*Session, error)

Session returns data about a specific session

func (*AnyDesk) SessionClose

func (a *AnyDesk) SessionClose(id int) error

SessionClose closes the specified currently open session

func (*AnyDesk) SessionComment

func (a *AnyDesk) SessionComment(id int, comment string) error

SessionComment sets the comment on a session, overwriting the existing comment if there was one

func (*AnyDesk) Sessions

func (a *AnyDesk) Sessions(opts *SessionsOptions) (*Sessions, error)

Sessions gets a list of sessions regarding a license's clients, or an individual client

func (*AnyDesk) SysInfo

func (a *AnyDesk) SysInfo() (*SysInfo, error)

SysInfo gets general license info and AnyDesk system information

type Client

type Client struct {
	ID             int `json:"cid"`
	Alias          string
	ClientVersion  string `json:"client-version"`
	Online         bool
	OnlineTime     int       `json:"online-time"`
	RecentSessions []Session `json:"last-sessions"`
}

Client is an individual AnyDesk-powered client attached to this license

type Clients

type Clients struct {
	Count      int
	Selected   int
	Offset     int
	Limit      int
	OnlineOnly bool     `json:"online"`
	Clients    []Client `json:"list"`
}

Clients is a response for a Clients method call

type ClientsOptions

type ClientsOptions struct {
	IncludeOffline bool   // Default is false.
	Offset         int    // The index of the first item to be returned.
	Limit          int    // Defaults to unlimited.
	Sort           string // `anydesk.SortClientID`, `anydesk.SortAlias`, or `anydesk.SortOnline`
	Order          bool   // `false` is descending (default), `true` is ascending
}

ClientsOptions are options for client list query

type GenericResult

type GenericResult struct {
	Success     bool
	Error       string
	Code        string
	Method      string
	Resource    string
	RequestTime string `json:"request-time"`
	ContentHash string `json:"content-hash"`
	Result      string
	LicenseID   string
}

GenericResult is a generic result struct

type Options

type Options struct {
	HTTPClient *http.Client
	UserAgent  string
	BaseURL    string
}

Options are optional options for an AnyDesk API client

type Session

type Session struct {
	ID           string `json:"sid"`
	ClientIDFrom Client
	ClientIDTo   Client
	Active       bool
	TimeStart    int `json:"start-time"` // time.Time?
	TimeEnd      int `json:"end-time"`   // time.Time?
	Duration     int
	Comment      string
}

Session is detailed information about an individual session

type Sessions

type Sessions struct {
	Count     int
	Selected  int
	Offset    int
	Limit     int
	ClientID  int
	Direction string
	Sessions  []Session `json:"list"`
}

Sessions list all sessions regarding a license's clients

type SessionsOptions

type SessionsOptions struct {
	ClientID   int       // If set it will limit returned sessions to that client.
	Direction  string    // `anydesk.DirectionAny` (default), `anydesk.DirectionIn`, or `anydesk.DirectionOut`
	TimeAfter  time.Time // Only return sessions after this time.
	TimeBefore time.Time // Only return sessions before this time.
	Offset     int       // The index of the first item to be returned.
	Limit      int       // Defaults to unlimited.
	Sort       string    // `anydesk.SortClientIDFrom`, `anydesk.SortClientIDTo`, `anydesk.SortTimeStart`, `anydesk.SortTimeEnd`, or `anydesk.SortDuration`
	Order      bool      // `false` is descending (default), `true` is ascending
}

SessionsOptions are options for session list query

type SysInfo

type SysInfo struct {
	Name       string
	APIVersion string `json:"api-ver"`
	License    struct {
		Name           string
		Expires        int
		MaxClients     int `json:"max-clients"`
		MaxSessions    int `json:"max-sessions"`
		MaxSessionTime int `json:"max-session-time"`
		Namespaces     []struct {
			Name string
			Size int
		}
		LicenseID   string `json:"license-id"`
		LicenseKey  string `json:"license-key"`
		APIPassword string `json:"api-password"`
	}
	Clients struct {
		Total  int
		Online int
	}
	Sessions struct {
		Total  int
		Online int
	}
	Standalone bool
}

SysInfo is general license info and AnyDesk system information

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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