Documentation ¶
Index ¶
- Constants
- Variables
- func IsValidDeviceID(deviceID string) bool
- func LoginWriteConfig(config LoginConfig) error
- type ApprovePendingDeviceRequest
- type Change
- type ChangeListQuery
- type ChangeListSearch
- type ChangeStatus
- type Client
- func (cli *Client) ApprovePendingDevice(ctx context.Context, nodeID string) error
- func (cli *Client) Authenticate(ctx context.Context, email string, password string) error
- func (cli *Client) Call(ctx context.Context, method, path string, src, dst any) error
- func (cli *Client) CommitConfiguration(ctx context.Context, message string) (*Commit, error)
- func (cli *Client) Connect(ctx context.Context, deviceID string, targets []RemoteAccessTarget) error
- func (cli *Client) ConnectMulti(ctx context.Context, connections []RemoteAccessConnection, allowFailures bool) error
- func (cli *Client) CreateConfigurationChange(ctx context.Context, change Change) (*Change, error)
- func (cli *Client) CreateDirectory(ctx context.Context, path, name string) error
- func (cli *Client) DeleteConfigurationChange(ctx context.Context, sha string) error
- func (cli *Client) DeleteFile(ctx context.Context, name string) error
- func (cli *Client) DeleteUncommittedConfigurationChanges(ctx context.Context) error
- func (cli *Client) DownloadFile(ctx context.Context, name string) (io.ReadCloser, error)
- func (cli *Client) FileStats(ctx context.Context) (*Stats, error)
- func (cli *Client) GetActiveConfig(ctx context.Context, entityType config.EntityType, entityID string, ...) (*config.Config, error)
- func (cli *Client) GetAuthToken() string
- func (cli *Client) GetBaseURL() string
- func (cli *Client) GetCommit(ctx context.Context, sha string) (*CommitExtended, error)
- func (cli *Client) GetConfigPreview(ctx context.Context, entityType config.EntityType, entityID string, ...) (*config.Config, error)
- func (cli *Client) GetConfigurationChange(ctx context.Context, sha string) (*Change, error)
- func (cli *Client) GetDeviceInventory(ctx context.Context, deviceID string) (*DeviceInventory, error)
- func (cli *Client) GetDeviceStatus(ctx context.Context, deviceID string) (*DeviceStatus, error)
- func (cli *Client) GetFileMetadata(ctx context.Context, filePath string) (*File, error)
- func (cli *Client) GetHTTPClient() *http.Client
- func (cli *Client) GetPendingDevices(ctx context.Context, pendingOnly bool) ([]PendingDevice, error)
- func (cli *Client) GetRemoteAccessToken(ctx context.Context, req RemoteAccessTokenRequest) (*RemoteAccessToken, error)
- func (cli *Client) GroupTreeGet(ctx context.Context, skipUnassigned bool) (*GroupTree, error)
- func (cli *Client) GroupTreeGetNode(ctx context.Context, nodeID string) (*NodeInfo, error)
- func (cli *Client) GroupTreeSetTags(ctx context.Context, nodeID string, tags []string) error
- func (cli *Client) GroupTreeUpdate(ctx context.Context, req GroupTreeRequest) error
- func (cli *Client) ListCommits(ctx context.Context, query CommitListQuery) (*CommitsList, error)
- func (cli *Client) ListDeviceInventory(ctx context.Context, query InventoryListQuery) (*InventoryListResponse, error)
- func (cli *Client) ListFiles(ctx context.Context, query ListQuery) (*FilesListResponse, error)
- func (cli *Client) ListUncommittedConfigurationChanges(ctx context.Context, query ChangeListQuery) ([]Change, error)
- func (cli *Client) Login(ctx context.Context, email, password string) (string, error)
- func (cli *Client) Login2FA(ctx context.Context, challenge string) (string, error)
- func (cli *Client) ParseConnect(ctx context.Context, deviceID string, targets []string) error
- func (cli *Client) RejectPendingDevice(ctx context.Context, nodeID string) error
- func (cli *Client) RemoveApprovedHost(ctx context.Context, nodeID string) error
- func (cli *Client) RenameFile(ctx context.Context, path, name, newPath string) error
- func (cli *Client) Request(ctx context.Context, method, path string, src any) (*http.Response, error)
- func (cli *Client) UploadFile(ctx context.Context, path, name string, reader io.Reader) error
- func (cli *Client) UploadFileReplace(ctx context.Context, path, name string, replace bool, reader io.Reader) error
- func (cli *Client) WithAuthToken(authToken string) *Client
- func (cli *Client) WithBaseURL(baseURL string) *Client
- func (cli *Client) WithHTTPClient(httpClient *http.Client) *Client
- type Commit
- type CommitExtended
- type CommitListQuery
- type CommitListSearch
- type CommitRequest
- type CommitsList
- type ConfigResponse
- type DeviceAttributes
- type DeviceInventory
- type DeviceStatus
- type EdgeVersion
- type Error
- type File
- type FileManager
- func (m *FileManager) List(ctx context.Context, remotePath string) error
- func (m *FileManager) Remove(ctx context.Context, remotePath string, recursive bool) error
- func (m *FileManager) Sync(ctx context.Context, source, dest string) error
- func (m *FileManager) WithClient(client *Client) *FileManager
- func (m *FileManager) WithDelete(del bool) *FileManager
- func (m *FileManager) WithDryRun(dryrun bool) *FileManager
- type FilesListResponse
- type GroupTree
- type GroupTreeAction
- type GroupTreeChange
- type GroupTreeChangeData
- type GroupTreeNode
- type GroupTreeRequest
- type GroupTreeSetTagsRequest
- type InventoryListItem
- type InventoryListQuery
- type InventoryListResponse
- type InventoryListSearch
- type InventoryReportType
- type ListQuery
- type ListSearch
- type Login2FARequest
- type Login2FAResponse
- type LoginConfig
- type LoginRequest
- type LoginResponse
- type NodeInfo
- type NodeType
- type PendingDevice
- type RemoteAccessConnection
- type RemoteAccessConnectionInfo
- type RemoteAccessTarget
- type RemoteAccessToken
- type RemoteAccessTokenRequest
- type RemoteAccessTokenResponse
- type Stats
- type SystemInfo
- type UserBaseInfo
Constants ¶
const ( // EdgeVersionOpenVPN indicates that the device is connected to an OpenVPN edge. EdgeVersionOpenVPN = 0 // EdgeVersionNative indicates that the device is connected to a native qbee remote access edge. EdgeVersionNative = 1 )
const ( // SortDirectionAsc returns the files sorted in ascending order. SortDirectionAsc = "asc" // SortDirectionDesc returns the files sorted in descending order. SortDirectionDesc = "desc" )
const ( // RootNodeID is the ID of the root node. // Root node cannot be moved or deleted. RootNodeID = "root" // UnassignedGroupNodeID is the ID of the unassigned group node. // Unassigned group node cannot be moved or deleted. UnassignedGroupNodeID = "unassigned_group" )
System node IDs
const ( TCP = "tcp" UDP = "udp" )
Network protocols supported by the remote access.
const DefaultBaseURL = "https://www.app.qbee.io"
DefaultBaseURL is the default base-URL used by the client.
Variables ¶
var Name = "qbee-cli"
Name is the name of the client (to be used as user-agent and application name).
var UserAgent = Name + "/" + Version
UserAgent is the user-agent string used for HTTP requests.
var Version = "1.0.0"
Version is the version of the client.
Functions ¶
func IsValidDeviceID ¶
IsValidDeviceID checks if the provided device ID is valid.
func LoginWriteConfig ¶
func LoginWriteConfig(config LoginConfig) error
LoginWriteConfig writes the CLI authentication configuration to the user's home directory.
Types ¶
type ApprovePendingDeviceRequest ¶ added in v1.2024.8
type ApprovePendingDeviceRequest struct { // NodeID is the node ID of the device to approve. NodeID string `json:"node_id"` }
ApprovePendingDeviceRequest represents a request to approve a pending device.
type Change ¶ added in v1.2024.8
type Change struct { // ID is the unique identifier of the change. ID string `json:"id,omitempty"` // Content is the type specific content of the change. Content any `json:"content"` // SHA is the pseudo-digest of the change. SHA string `json:"sha"` // Status is the current status of the change. Status ChangeStatus `json:"status"` // Type is the type of the change. Type string `json:"type"` // Created is the timestamp when the change was created. Created types.Timestamp `json:"created"` // Updated is the timestamp when the change was last updated. Updated types.Timestamp `json:"updated"` // UserID is the ID of the user who created the change. UserID string `json:"user_id"` // UserName is the first name and last name of the user who created the change. // This field is populated by the API handlers. UserName string `json:"user_name,omitempty"` // User contains the user who created the change. // This field is populated by the API handlers. User *UserBaseInfo `json:"user,omitempty"` // NodeInfo contains base information about the node that the change is associated with (if any). // This field is populated by the API handlers. NodeInfo *NodeInfo `json:"node,omitempty"` }
Change in the system state.
type ChangeListQuery ¶ added in v1.2024.8
type ChangeListQuery struct { Search ChangeListSearch // CreatedStart defines start of the time range to search in, inclusive. // Start date UTC, format: YYYY-MM-DD hh:ii:ss. Default -1 month from now CreatedStart time.Time // CreatedEnd defines end of the time range to search in, exclusive. // End date UTC, format: YYYY-MM-DD hh:ii:ss. Default: now CreatedEnd time.Time // SortField defines field used to sort, 'created' by default. // Supported sort fields: // - id // - created Sort string // SortDirection defines sort direction, 'desc' by default. SortDirection string // Limit defines maximum number of records in result, default 3000, max 10000 Limit int // Offset defines offset of the first record in result, default 0 Offset int }
ChangeListQuery defines query parameters for ChangeList.
func (ChangeListQuery) String ¶ added in v1.2024.8
func (q ChangeListQuery) String() (string, error)
String returns string representation of CommitListQuery which can be used as query string.
type ChangeListSearch ¶ added in v1.2024.8
type ChangeListSearch struct { // UserID - user ID to search for (exact match). UserID string `json:"user_id,omitempty"` // GroupID - group ID to search for (exact match). GroupID string `json:"group_id,omitempty"` // Status - status to search for (exact match). Status ChangeStatus `json:"status,omitempty"` // FormType - form type to search for (exact match). FormType string `json:"form_type,omitempty"` // Type - type to search for (exact match). Type string `json:"type,omitempty"` }
ChangeListSearch defines search parameters for ChangeListQuery.
type ChangeStatus ¶ added in v1.2024.8
type ChangeStatus string
ChangeStatus defines the status of a change.
const ( // ChangeStatusNew is the status of a new change. ChangeStatusNew ChangeStatus = "new" // ChangeStatusCommitted is the status of a committed change. ChangeStatusCommitted ChangeStatus = "committed" )
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client encapsulates communication with the public API.
func LoginGetAuthenticatedClient ¶
LoginGetAuthenticatedClient returns a new authenticated API Client.
func (*Client) ApprovePendingDevice ¶ added in v1.2024.8
ApprovePendingDevice approves a pending device with provided node ID.
func (*Client) Authenticate ¶
Authenticate authenticates the client instance with the given email and password.
func (*Client) Call ¶
Call the API using provided method and path. If src is not nil, it will be encoded as JSON and sent as the request body. If dst is not nil, the response body will be decoded as JSON into dst
func (*Client) CommitConfiguration ¶ added in v1.2024.8
CommitConfiguration commits uncommitted changes with provided message.
func (*Client) Connect ¶
func (cli *Client) Connect(ctx context.Context, deviceID string, targets []RemoteAccessTarget) error
Connect establishes a connection to a remote device.
func (*Client) ConnectMulti ¶
func (cli *Client) ConnectMulti(ctx context.Context, connections []RemoteAccessConnection, allowFailures bool) error
ConnectMulti establishes connections to multiple remote devices concurrently.
func (*Client) CreateConfigurationChange ¶ added in v1.2024.8
CreateConfigurationChange in the system.
func (*Client) CreateDirectory ¶
CreateDirectory creates a directory with the given name in the given path.
func (*Client) DeleteConfigurationChange ¶ added in v1.2024.8
DeleteConfigurationChange deletes a single change by its SHA.
func (*Client) DeleteFile ¶
DeleteFile deletes a file.
func (*Client) DeleteUncommittedConfigurationChanges ¶ added in v1.2024.8
DeleteUncommittedConfigurationChanges deletes all uncommitted configuration changes.
func (*Client) DownloadFile ¶
DownloadFile from the file-manager. Returns a ReadCloser that must be closed after use.
func (*Client) GetActiveConfig ¶ added in v1.2024.8
func (cli *Client) GetActiveConfig( ctx context.Context, entityType config.EntityType, entityID string, scope config.EntityConfigScope, ) (*config.Config, error)
GetActiveConfig returns the active configuration for the entity.
func (*Client) GetAuthToken ¶
GetAuthToken returns the authentication token used by the client.
func (*Client) GetBaseURL ¶
GetBaseURL returns the base URL used by the client.
func (*Client) GetConfigPreview ¶ added in v1.2024.8
func (cli *Client) GetConfigPreview( ctx context.Context, entityType config.EntityType, entityID string, scope config.EntityConfigScope, ) (*config.Config, error)
GetConfigPreview returns the configuration preview (with uncommitted changes) for the entity.
func (*Client) GetConfigurationChange ¶ added in v1.2024.8
GetConfigurationChange returns a single change by its SHA.
func (*Client) GetDeviceInventory ¶
func (cli *Client) GetDeviceInventory(ctx context.Context, deviceID string) (*DeviceInventory, error)
GetDeviceInventory returns the device inventory for the given device ID.
func (*Client) GetDeviceStatus ¶ added in v1.2024.6
GetDeviceStatus returns device status.
func (*Client) GetFileMetadata ¶
GetFileMetadata returns the metadata for the given file.
func (*Client) GetHTTPClient ¶
GetHTTPClient returns the HTTP client used by the client.
func (*Client) GetPendingDevices ¶ added in v1.2024.8
func (cli *Client) GetPendingDevices(ctx context.Context, pendingOnly bool) ([]PendingDevice, error)
GetPendingDevices returns the pending devices list.
func (*Client) GetRemoteAccessToken ¶
func (cli *Client) GetRemoteAccessToken(ctx context.Context, req RemoteAccessTokenRequest) (*RemoteAccessToken, error)
GetRemoteAccessToken returns a remote console token for the specified device.
func (*Client) GroupTreeGet ¶ added in v1.2024.8
GroupTreeGet returns the device group tree.
func (*Client) GroupTreeGetNode ¶ added in v1.2024.8
GroupTreeGetNode returns the node from device group tree.
func (*Client) GroupTreeSetTags ¶ added in v1.2024.8
GroupTreeSetTags sets tags for a node.
func (*Client) GroupTreeUpdate ¶ added in v1.2024.8
func (cli *Client) GroupTreeUpdate(ctx context.Context, req GroupTreeRequest) error
GroupTreeUpdate updates the group tree.
func (*Client) ListCommits ¶ added in v1.2024.8
func (cli *Client) ListCommits(ctx context.Context, query CommitListQuery) (*CommitsList, error)
ListCommits returns a list of commits based on provided query.
func (*Client) ListDeviceInventory ¶
func (cli *Client) ListDeviceInventory(ctx context.Context, query InventoryListQuery) (*InventoryListResponse, error)
ListDeviceInventory returns a list of device inventories based on provided query.
func (*Client) ListUncommittedConfigurationChanges ¶ added in v1.2024.8
func (cli *Client) ListUncommittedConfigurationChanges(ctx context.Context, query ChangeListQuery) ([]Change, error)
ListUncommittedConfigurationChanges returns a list of uncommitted configuration changes.
func (*Client) ParseConnect ¶
ParseConnect parses a device ID and a list of targets and establishes a connection to the device.
func (*Client) RejectPendingDevice ¶ added in v1.2024.8
RejectPendingDevice rejects a pending device with provided node ID.
func (*Client) RemoveApprovedHost ¶ added in v1.2024.8
RemoveApprovedHost rejects a pending device with provided node ID.
func (*Client) RenameFile ¶
RenameFile in the file-manager.
func (*Client) Request ¶
func (cli *Client) Request(ctx context.Context, method, path string, src any) (*http.Response, error)
Request sends an HTTP request to the API and returns the HTTP response.
func (*Client) UploadFile ¶
UploadFile a file to the file-manager. path must start with a slash (/)
func (*Client) UploadFileReplace ¶ added in v1.2024.5
func (cli *Client) UploadFileReplace(ctx context.Context, path, name string, replace bool, reader io.Reader) error
UploadFileReplace a file to the file-manager if replace is set to true
func (*Client) WithAuthToken ¶
WithAuthToken sets the authentication token for the client.
func (*Client) WithBaseURL ¶
WithBaseURL sets the base URL of the API endpoint.
type Commit ¶ added in v1.2024.8
type Commit struct { // ID is the unique identifier of the commit. ID string `json:"-"` // SHA is the pseudo-digest of the commit. SHA string `json:"sha"` // Message is the commit message. Message string `json:"message"` // Type is the type of the commit. Type string `json:"type"` // Labels is the list of labels of the commit. Labels []string `json:"labels"` // Changes is the list of changes' SHA that are part of the commit. Changes []string `json:"changes"` // UserID is the ID of the user who created the commit. UserID string `json:"user_id"` // User contains the user who created the commit. // This field is populated by the API handlers. User *UserBaseInfo `json:"user,omitempty"` // Created is the timestamp when the commit was created. Created types.Timestamp `json:"created"` // Updated is the timestamp when the commit was last updated. Updated types.Timestamp `json:"updated"` }
Commit represents a single commit in the system.
type CommitExtended ¶ added in v1.2024.8
type CommitExtended struct { Commit // Changes is the list of changes' SHA that are part of the commit. Changes []Change `json:"changes"` }
CommitExtended is a commit with complete changes objects.
type CommitListQuery ¶ added in v1.2024.8
type CommitListQuery struct { Search CommitListSearch // SortField defines field used to sort, 'created' by default. // Supported sort fields: // - user_id // - type // - message // - created Sort string // SortDirection defines sort direction, 'desc' by default. SortDirection string // Limit defines maximum number of records in result, default 30, max 1000 Limit int // Offset defines offset of the first record in result, default 0 Offset int }
CommitListQuery defines query parameters for ChangeList.
func (CommitListQuery) String ¶ added in v1.2024.8
func (q CommitListQuery) String() (string, error)
String returns string representation of CommitListQuery which can be used as query string.
type CommitListSearch ¶ added in v1.2024.8
type CommitListSearch struct { // CommitSHA - full string or substring with at least 6 characters. CommitSHA string `json:"commit_sha,omitempty"` // Message - commit message to search for (substring match). Message string `json:"message,omitempty"` // UserID - user ID to search for (exact match). UserID string `json:"user_id,omitempty"` // Committer - name or surname of the user (substring match) Committer string `json:"committer,omitempty"` // ChangeSHA - full string or substring with at least 6 characters ChangeSHA string `json:"change_sha,omitempty"` // LabelsInclude - array of labels which MUST be present (exact match) LabelsInclude []string `json:"labels_include,omitempty"` // LabelsExclude - array of labels which MUST NOT be present (exact match) LabelsExclude []string `json:"labels_exclude,omitempty"` // StartDate - start date UTC, format: YYYY-MM-DD hh:ii:ss StartDate string `json:"start_date,omitempty"` // EndDate - end date UTC, format: YYYY-MM-DD hh:ii:ss EndDate string `json:"end_date,omitempty"` }
CommitListSearch defines search parameters for CommitListQuery.
type CommitRequest ¶ added in v1.2024.8
type CommitRequest struct { // Action must be always set to "commit". Action string `json:"action"` // Message describing changes in the commit. Message string `json:"message"` }
CommitRequest is a request to commit uncommitted changes.
type CommitsList ¶ added in v1.2024.8
type CommitsList struct { Commits []*CommitExtended `json:"items"` Total int `json:"total"` }
CommitsList represents a slice of commits matched by the query. As well as the total number of commits matched by the query.
type ConfigResponse ¶ added in v1.2024.8
type ConfigResponse struct { // Status is the status of the request. Status string `json:"status"` // Config is the configuration of the requested entity. Config *config.Config `json:"config"` }
ConfigResponse is a response for the configuration request.
type DeviceAttributes ¶
type DeviceAttributes struct { // DeviceName is the name of the device which is displayed in the UI (if set). DeviceName string `json:"device_name"` // Description is the extra device description. Description string `json:"description"` // Country is the country where device is located. Country string `json:"country"` // City is the city where device is located. City string `json:"city"` // Zip is the zip code where device is located. Zip string `json:"zip"` // Address is the address where device is located. Address string `json:"address"` // Latitude is the latitude where device is located. Latitude string `json:"latitude"` // Longitude is the longitude where device is located. Longitude string `json:"longitude"` // DiscoveredCountry is the country where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredCountry string `json:"discovered_country,omitempty"` // DiscoveredCity is the city where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredCity string `json:"discovered_city,omitempty"` // DiscoveredZip is the zip code where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredZip string `json:"discovered_zip,omitempty"` // DiscoveredAddress is the address where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredAddress string `json:"discovered_address,omitempty"` // DiscoveredLatitude is the latitude where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredLatitude string `json:"discovered_latitude,omitempty"` // DiscoveredLongitude is the longitude where device was discovered by the platform based on its IP address. // This is a read-only field. DiscoveredLongitude string `json:"discovered_longitude,omitempty"` // DiscoveredByPostAddressLatitude is the latitude where device was discovered by the platform based on address. // This is a read-only field. DiscoveredByPostAddressLatitude string `json:"discovered_by_post_address_latitude,omitempty"` // DiscoveredByPostAddressLongitude is the longitude where device was discovered by the platform based on address. // This is a read-only field. DiscoveredByPostAddressLongitude string `json:"discovered_by_post_address_longitude,omitempty"` // UpdatedAuto contains Unix timestamp of the last time the device attributes were updated by the platform. // This is a read-only field. UpdatedAuto types.Timestamp `json:"updated_auto,omitempty"` // UpdatedUser contains Unix timestamp of the last time the device attributes were updated by a user. // This is a read-only field. UpdatedUser types.Timestamp `json:"updated_user,omitempty"` }
DeviceAttributes represents additional device attributes set for the device.
type DeviceInventory ¶
type DeviceInventory struct { // ID is the device ID for which the inventory was reported. ID string `json:"pub_key_digest"` // SystemInfo contains system information. SystemInfo SystemInfo `json:"system"` // Settings contains device settings. // DEPRECATED: Use PushedConfig.BundleData.Settings instead. Settings config.Settings `json:"settings"` // ConfigPropagated is set to true if the device has received the latest configuration. ConfigPropagated bool `json:"config_propagated"` // LastReported is the unix timestamp when the device checked-in with the platform. LastReported types.Timestamp `json:"last_reported"` // HeartbeatExpirationSoft is the unix timestamp when the device will be marked as delayed. HeartbeatExpirationSoft types.Timestamp `json:"exp_soft"` // HeartbeatExpirationHard is the unix timestamp when the device will be marked as offline. HeartbeatExpirationHard types.Timestamp `json:"exp_hard"` // DeviceCommitSHA is the SHA of the commit that is currently running on the device. DeviceCommitSHA string `json:"device_commit_sha"` // Attributes contains currently defined device attributes. Attributes DeviceAttributes `json:"attributes"` // Tags of the device. // When set, tags are validated against the following regular expression: ^[a-z0-9:-]{3,64}$ Tags []string `json:"tags"` // Status of the device. // Possible values: "online", "delayed", "offline" Status string `json:"status"` // PushedConfig contains the configuration that is expected to be on the device. // See ConfigPropagated to check if the device has already received it. PushedConfig config.Pushed `json:"pushed_config"` }
DeviceInventory represents basic device inventory information.
type DeviceStatus ¶ added in v1.2024.6
type DeviceStatus struct { // UUID is the UUID of the device. UUID string `json:"uuid"` // RemoteAccess is true if the device is connected to the edge. RemoteAccess bool `json:"remote_access"` // Edge is the edge host that the device is connected to. // This field is only set if RemoteAccess is true. // Format is <edge-host>:<edge-port>/edge/<edge-id> Edge string `json:"edge,omitempty"` // EdgeVersion is the version of the edge that the device is connected to. // This field is only set if RemoteAccess is true. // 0 - for OpenVPN edge // 1 - for native qbee remote access EdgeVersion EdgeVersion `json:"edge_version,omitempty"` }
DeviceStatus is the status of a device.
type EdgeVersion ¶ added in v1.2024.6
type EdgeVersion uint8
EdgeVersion indicates the version of the edge server that the device is connected to.
type Error ¶
Error is used to decode API error responses.
func ParseErrorResponse ¶
ParseErrorResponse parses API error from the provided response body.
type File ¶
type File struct { Name string `json:"name"` Extension string `json:"extension"` Mime string `json:"mime"` Size int `json:"size"` Created int64 `json:"created"` IsDir bool `json:"is_dir"` Path string `json:"path"` Digest string `json:"digest"` User struct { ID string `json:"user_id"` } `json:"user"` }
File represents a file in the file-manager.
type FileManager ¶ added in v1.2024.5
type FileManager struct {
// contains filtered or unexported fields
}
FileManager provides implementation of common batch operations inside qbee's file manager.
func NewFileManager ¶ added in v1.2024.5
func NewFileManager() *FileManager
NewFileManager returns a new FileManager.
func (*FileManager) List ¶ added in v1.2024.5
func (m *FileManager) List(ctx context.Context, remotePath string) error
List files under provided remotePath.
func (*FileManager) Remove ¶ added in v1.2024.5
Remove all files under provided remotePath.
If recursive flag is set to true and remotePath points to a directory, this method will remove all nested files and directories recursively. Otherwise, it will return an error when deleting a non-empty directory.
func (*FileManager) Sync ¶ added in v1.2024.5
func (m *FileManager) Sync(ctx context.Context, source, dest string) error
Sync synchronizes the local directory with the FileManager.
func (*FileManager) WithClient ¶ added in v1.2024.5
func (m *FileManager) WithClient(client *Client) *FileManager
WithClient sets the client
func (*FileManager) WithDelete ¶ added in v1.2024.5
func (m *FileManager) WithDelete(del bool) *FileManager
WithDelete sets the delete flag
func (*FileManager) WithDryRun ¶ added in v1.2024.5
func (m *FileManager) WithDryRun(dryrun bool) *FileManager
WithDryRun sets the dryrun flag
type FilesListResponse ¶
FilesListResponse is a response from the file-manager containing a list of files.
type GroupTree ¶ added in v1.2024.8
type GroupTree struct { TotalDevices int `json:"total_devices"` Tree GroupTreeNode `json:"tree"` }
GroupTree represents the device group tree.
type GroupTreeAction ¶ added in v1.2024.8
type GroupTreeAction string
GroupTreeAction represents an action on the group tree.
const ( TreeActionCreate GroupTreeAction = "create" TreeActionRename GroupTreeAction = "rename" TreeActionUpdate GroupTreeAction = "update" TreeActionMove GroupTreeAction = "move" TreeActionDelete GroupTreeAction = "delete" )
GroupTreeAction types enumeration.
type GroupTreeChange ¶ added in v1.2024.8
type GroupTreeChange struct { Action GroupTreeAction `json:"action"` Data GroupTreeChangeData `json:"data"` }
GroupTreeChange represents a change in the device tree. Data is specific to the action: - create: parent_id, node_id, title, type - rename: node_id, title, type=group (only groups can be renamed) - move: parent_id, node_id, old_parent_id, type=device (only devices can be moved) - delete: node_id, type=group (only empty groups can be deleted)
type GroupTreeChangeData ¶ added in v1.2024.8
type GroupTreeChangeData struct { ParentID string `json:"parent_id"` NodeID string `json:"node_id"` // Type is the type of the group (device or group). // This parameter is used only for moving of existing groups. Type NodeType `json:"type,omitempty"` // OldParentID is the ID of the parent group before the move. // This parameter is used only for moving groups. OldParentID string `json:"old_parent_id,omitempty"` // Title is the title of the new group. // This parameter is used only for creating new groups. Title string `json:"title,omitempty"` // Tags is the list of tags to set on the node. // This parameter is used only for updates. Tags []string `json:"tags,omitempty"` }
GroupTreeChangeData represents the data for a group tree change.
type GroupTreeNode ¶ added in v1.2024.8
type GroupTreeNode struct { ID string `json:"id"` NodeID string `json:"node_id"` Title string `json:"title"` Type NodeType `json:"type"` Tags []string `json:"tags,omitempty"` Nodes []GroupTreeNode `json:"nodes"` // device only attributes PublicKeyDigest string `json:"pub_key_digest,omitempty"` DeviceCommitSHA string `json:"device_commit_sha,omitempty"` Status string `json:"status,omitempty"` ConfigPropagated bool `json:"config_propagated,omitempty"` AgentInterval int `json:"agentinterval,omitempty"` LastReported int64 `json:"last_reported,omitempty"` Attributes DeviceAttributes `json:"attributes"` // internal attributes ParentID string `json:"-"` Hostname string `json:"-"` }
GroupTreeNode represents a node in the device group tree.
type GroupTreeRequest ¶ added in v1.2024.8
type GroupTreeRequest struct {
Changes []GroupTreeChange `json:"changes"`
}
GroupTreeRequest is the request to update the group tree.
type GroupTreeSetTagsRequest ¶ added in v1.2024.8
type GroupTreeSetTagsRequest struct {
Tags []string `json:"tags"`
}
GroupTreeSetTagsRequest is the request to set tags for a node.
type InventoryListItem ¶
type InventoryListItem struct { // NodeID - device public key digest (hex-encoded SHA256) NodeID string `json:"node_id"` // PubKeyDigest - same as NodeID (for backwards compatibility) PubKeyDigest string `json:"pub_key_digest"` // UUID - device UUID (legacy identifier used by the remote access subsystem) UUID string `json:"uuid"` // System - system inventory. System SystemInfo `json:"system"` // LastReportedTime - timestamp of the last inventory report. LastReportedTime int64 `json:"last_reported_time"` // HeartbeatExpireSoft - timestamp when device will be considered delayed. HeartbeatExpireSoft int64 `json:"exp_soft"` // HeartbeatExpireHard - timestamp when device will be considered disconnected. HeartbeatExpireHard int64 `json:"exp_hard"` // Ancestors - array of ancestor nodes (incl. self). Ancestors []string `json:"ancestors"` // Attributes - device attributes. Attributes DeviceAttributes `json:"attributes"` // Title - device title. Title string `json:"title"` // AgentInterval - agent interval. // DEPRECATED: This field doesn't provide valid information anymore. AgentInterval string `json:"agentinterval"` // Status - device status (online, delayed or disconnected). Status string `json:"status"` // Tags - device tags. Tags []string `json:"tags"` }
InventoryListItem contains device inventory information.
type InventoryListQuery ¶
type InventoryListQuery struct { Search InventoryListSearch // SortField defines field used to sort, 'title' by default. // Supported sort fields: // - title (fqhost or remoteaddr - depending on what is available) // - device_name (from attribute) // - last_reported_time // - last_policy_update // - commit_sha SortField string // SortDirection defines sort direction, 'desc' by default. SortDirection string // ItemsPerPage defines maximum number of records in result, default 30, max 1000 ItemsPerPage int // Offset defines offset of the first record in result, default 0 Offset int // ReportType defines format of the response payload. ReportType InventoryReportType }
InventoryListQuery defines query parameters for InventoryList.
func (InventoryListQuery) String ¶
func (q InventoryListQuery) String() (string, error)
String returns string representation of InventoryListQuery which can be used as query string.
type InventoryListResponse ¶
type InventoryListResponse struct { Items []InventoryListItem `json:"items"` Total int `json:"total"` }
InventoryListResponse contains list of device inventories.
type InventoryListSearch ¶
type InventoryListSearch struct { // NodeID - device public key digest (hex-encoded SHA256) NodeID string `json:"node_id,omitempty"` // UUID - device UUID (legacy identifier used by the remote access subsystem) UUID string `json:"uuid,omitempty"` // Title - fqhost, remoteaddr or device title (can be set in the attributes) Title string `json:"title,omitempty"` // Flavor - A variable containing an operating system identification string that is used to determine // the current release of the operating system in a form that can be used as a label in naming. // This is used, for instance, to detect which package name to choose when updating software binaries. // Example: "ubuntu_22" Flavor string `json:"flavor,omitempty"` // Architecture - The variable containing the kernel's short architecture description (e.g. "x86_64") Architecture string `json:"arch,omitempty"` // IPAddress match on ipv4_first, ip_addresses, remoteaddr or ipv4 fields from inventory (exact match) IPAddress string `json:"ip,omitempty"` // MACAddress match on hardware_mac field from inventory (exact match) MACAddress string `json:"mac,omitempty"` // Description partial match on device description. Description string `json:"description,omitempty"` // Latitude and Longitude match on device location. Latitude string `json:"latitude,omitempty"` Longitude string `json:"longitude,omitempty"` // Country match on device location. Country string `json:"country,omitempty"` // City match on device location. City string `json:"city,omitempty"` // Zip match on device location. Zip string `json:"zip,omitempty"` // Address match on device location. Address string `json:"address,omitempty"` // DeviceAttribute - match on device attributes: // - flavor, // - architecture, // - description, // - lat/long, // - country, // - city, // - zip, // - address, // - ipv4_first, // - ip_addresses, // - remoteaddr, // - ipv4 // using OR condition and substring match DeviceAttribute string `json:"device_attribute,omitempty"` // Unassigned defines if only unassigned devices should be returned. Unassigned bool `json:"unassigned,omitempty"` // Ancestors - array of parent nodes (exact match) Ancestors []string `json:"ancestor_ids,omitempty"` // Tags - array of tags which MUST be preset (exact match) Tags []string `json:"tags,omitempty"` // CommitSHA - match on active config commit sha (partial match) CommitSHA string `json:"commit_sha,omitempty"` }
InventoryListSearch defines search parameters for InventoryListQuery.
type InventoryReportType ¶
type InventoryReportType string
InventoryReportType defines format of the response payload.
const ( // InventoryReportTypeDetailed - detailed inventory report incl. complete device attributes and system info. InventoryReportTypeDetailed InventoryReportType = "detailed" // InventoryReportTypeShort - short inventory report, incl. only basic device information: // system info: // - fqhost // - remoteaddr // - ipv4 // - last_config_commit_id // - last_policy_update // device attributes: // - device name InventoryReportTypeShort InventoryReportType = "short" )
type ListQuery ¶
type ListQuery struct { // Path defines path to the directory to list files in. // If path is empty and: // - search is empty - show files from the root directory // - search is not empty - search in ALL files // Else, if path is not empty and: // - search is empty - show files from that directory // - search is not empty - search in that directory only Path string Search ListSearch // SortField defines field used to sort, 'name' by default. // Supported sort fields: // - name // - size // - extension // - created SortField string // SortDirection defines sort direction, 'asc' by default. SortDirection string // ItemsPerPage defines maximum number of records in result, default 50, max 1000 ItemsPerPage int // Offset defines offset of the first record in result, default 0 Offset int }
ListQuery defines query parameters for FileList.
type ListSearch ¶
type ListSearch struct { // Name - file name to search for (partial-match). Name string `json:"name"` // Path - file path to search for (partial-match). Path string `json:"path"` }
ListSearch defines search parameters for ListQuery.
type Login2FARequest ¶
type Login2FARequest struct { Challenge string `json:"challenge,omitempty"` Provider string `json:"preferProvider,omitempty"` Code string `json:"code,omitempty"` }
Login2FARequest is the request body for the Login 2FA API.
type Login2FAResponse ¶
type Login2FAResponse struct { Challenge string `json:"challenge,omitempty"` Token string `json:"token,omitempty"` }
Login2FAResponse is the response body for the Login 2FA API.
type LoginConfig ¶
LoginConfig is the configuration file for the CLI authentication.
func LoginReadConfig ¶
func LoginReadConfig() (*LoginConfig, error)
LoginReadConfig reads the CLI authentication configuration from the user's home directory.
type LoginRequest ¶
type LoginRequest struct { // Email is the user email. Email string `json:"email"` // Password is the user password. Password string `json:"password"` }
LoginRequest is the request body for the Login API.
type LoginResponse ¶
type LoginResponse struct { // Token is the authentication token to be used as Bearer token in the Authorization header. Token string `json:"token"` }
LoginResponse is the response body for the Login API.
type NodeInfo ¶ added in v1.2024.8
type NodeInfo struct { NodeID string `json:"node_id"` PublicKeyDigest string `json:"pub_key_digest"` Type NodeType `json:"type"` Ancestors []string `json:"ancestors"` Title string `json:"title"` Tags []string `json:"tags,omitempty"` Nodes []NodeInfo `json:"nodes,omitempty"` // Device specific fields UUID string `json:"uuid,omitempty"` Status string `json:"status,omitempty"` DeviceCommitSHA string `json:"device_commit_sha,omitempty"` Attributes *DeviceAttributes `json:"attributes,omitempty"` ConfigPropagated bool `json:"config_propagated,omitempty"` AgentInterval int `json:"agentinterval,omitempty"` LastReported int64 `json:"last_reported,omitempty"` System *SystemInfo `json:"system,omitempty"` Settings *config.Settings `json:"settings,omitempty"` PushedConfig *config.Pushed `json:"pushed_config,omitempty"` }
NodeInfo contains information about a node. This is used for the device tree API.
type PendingDevice ¶ added in v1.2024.8
type PendingDevice struct { // PublicKeyDigest - device's public key digest (used to identify devices). PublicKeyDigest string `json:"pub_key_digest"` // Approved is true when the device is approved. Approved bool `json:"approved"` // ApprovedTimestamp in UnixNano. ApprovedTimestamp int64 `json:"approved_timestamp,omitempty"` // Certificate - base64-encoded (PEM) signed device certificate. Certificate string `json:"cert,omitempty"` // GroupID where device is assigned. GroupID string `json:"group_id,omitempty"` // RemoteAddress from which device was bootstrapped. RemoteAddress string `json:"remoteaddress"` // Device creation timestamp (in seconds). Timestamp int64 `json:"timestamp"` // Host - The name of the current host, according to the kernel. // It is undefined whether this is qualified or unqualified with a domain name. Host string `json:"host"` // FQHost - The fully qualified name of the host (e.g. "device1.example.com"). FQHost string `json:"fqhost"` // UQHost - The unqualified name of the host (e.g. "device1"). UQHost string `json:"uqhost"` // DeviceName - The custom name for the device. DeviceName string `json:"device_name,omitempty"` // HardwareMAC - This contains the MAC address of the named interface map[interface]macAddress. // Note: The keys in this array are canonified. // For example, the entry for wlan0.1 would be found under the wlan0_1 key. // // Example: // { // "ens1": "52:54:00:4a:db:ee", // "qbee0": "00:00:00:00:00:00" // } HardwareMAC map[string]string `json:"hardware_mac"` // IPDefault - All four octets of the IPv4 address of the first system interface. //Note: If the system has a single ethernet interface, this variable will contain the IPv4 address. // However, if the system has multiple interfaces, then this variable will simply be the IPv4 address of the first // interface in the list that has an assigned address. // Use IPv4[interface_name] for details on obtaining the IPv4 addresses of all interfaces on a system. IPDefault string `json:"ip_default"` // IPv4 - All IPv4 addresses of the system mapped by interface name. // Example: // { // "ens1": "192.168.122.239", // "qbee0": "100.64.39.78" // } IPv4 map[string]string `json:"ipv4"` // RawPublicKey of the device as slice of PEM-encoded lines. // Example: // []string{ // "-----BEGIN PUBLIC KEY-----", // "MIGbMBAGByqGSM49AgEGBSuBBAAjA4GGAAQBvDALiaU+dyvd1DhMUCEXnuX4h5r5", // "ikBVNSl88QBtBoxtQy1XsCJ7Dm/tzoQ1YPYT80oVTdExK/oFnZFvI89SX8sBN89L", // "Y8q+8BBQPLf1nA3DG7apq7xq11Zkpde2eK0pCUG7nZPisXlU96C44NLE62TzDYEZ", // "RYkhJQhFeNOlFSpF/xA=", // "-----END PUBLIC KEY-----" // } RawPublicKey []string `json:"pub_key,omitempty"` }
PendingDevice represents a device that is pending approval.
type RemoteAccessConnection ¶
type RemoteAccessConnection struct { // DeviceID is the device ID of the device to which the remote access connection belongs. DeviceID string `json:"device_id"` // Targets is a list of remote access targets. Targets []string `json:"targets"` }
RemoteAccessConnection defines a remote access connection.
type RemoteAccessConnectionInfo ¶
type RemoteAccessConnectionInfo struct { // URL of the remote access server. If empty, a legacy URL will be used. URL string `json:"url"` // VPNIndex is the legacy VPN index to use for the connection. VPNIndex string `json:"vpn_idx"` // Username is the username to use for authentication. Username string `json:"username"` // Password is the password to use for authentication. Password string `json:"password"` // Address is the internal device address client is connecting to. Address string `json:"address"` }
RemoteAccessConnectionInfo contains parameters used to establish a remote access connection.
type RemoteAccessTarget ¶
type RemoteAccessTarget struct { // Protocol is the protocol used for the remote access. // Can be either "tcp" or "udp". Protocol string // RemoteHost is the host of the remote machine to which the local port is forwarded. RemoteHost string // LocalPort is the port on the local machine to which the remote port is forwarded. LocalPort string // RemotePort is the port on the remote machine to which the local port is forwarded. RemotePort string }
RemoteAccessTarget defines
func ParseRemoteAccessTarget ¶
func ParseRemoteAccessTarget(targetString string) (RemoteAccessTarget, error)
ParseRemoteAccessTarget parses a remote access target string. The target string has the following format: <local_port>:<remote_host>:<remote_port>[/udp]
func (RemoteAccessTarget) String ¶
func (target RemoteAccessTarget) String() string
String returns the string representation of a remote access target.
type RemoteAccessToken ¶
type RemoteAccessToken struct { // Title is the title of the device. Title string `json:"title"` // Connection contains the connection details. Connection RemoteAccessConnectionInfo `json:"connection"` }
RemoteAccessToken contains remote console
func (RemoteAccessToken) AuthString ¶
func (token RemoteAccessToken) AuthString() string
AuthString returns the authentication string for the remote access token.
func (RemoteAccessToken) ProxyURL ¶
func (token RemoteAccessToken) ProxyURL() (string, error)
ProxyURL returns the proxy URL for the remote access token.
type RemoteAccessTokenRequest ¶
type RemoteAccessTokenRequest struct { // DeviceID is the PublicKeyDigest of the device for which the token is requested. // Required. DeviceID string // Application is the name of the application for which the token is requested. // Optional - defaults to "qbee-cli". Application string // Username is the username for which the token is requested. // Setting this value will allow to identify the user in the audit log. // Optional. Username string // Ports is the list of ports for which the token is requested. // Setting this value will allow to identify requested ports in the audit log. // Optional. Ports []string }
RemoteAccessTokenRequest is the request sent to the API when requesting a remote console token.
type RemoteAccessTokenResponse ¶
type RemoteAccessTokenResponse map[string]RemoteAccessToken
RemoteAccessTokenResponse is the response returned by the API when requesting a remote console token.
type Stats ¶
type Stats struct { // CountFiles is the number of files in the file-manager. CountFiles int64 `json:"count_files"` // Quota is the allocated storage space in MB. Quota int64 `json:"quota"` // Used is the used storage space in MB. Used float64 `json:"used"` }
Stats represents the statistics of file manager for a company.
type SystemInfo ¶
type SystemInfo struct { // Class - This variable contains the name of the hard-class category for this host, // (i.e. its top level operating system type classification, e.g. "linux"). Class string `json:"class"` // OS - The name of the operating system according to the kernel (e.g. "linux"). OS string `json:"os"` // OSType - Another name for the operating system (e.g. "linux_x86_64"). OSType string `json:"ostype"` // Version - The version of the running kernel. On Linux, this corresponds to the output of uname -v. // Example: "#58-Ubuntu SMP Thu Oct 13 08:03:55 UTC 2022". Version string `json:"version"` // Architecture - The variable gives the kernel's short architecture description (e.g. "x86_64"). Architecture string `json:"arch"` // LongArchitecture - The long architecture name for this system kernel. // This name is sometimes quite unwieldy but can be useful for logging purposes. // Example: "linux_x86_64_5_15_0_52_generic__58_Ubuntu_SMP_Thu_Oct_13_08_03_55_UTC_2022" LongArchitecture string `json:"long_arch"` // Release - The kernel release of the operating system (e.g. "5.15.0-52-generic"). Release string `json:"release"` // Flavor - A variable containing an operating system identification string that is used to determine // the current release of the operating system in a form that can be used as a label in naming. // This is used, for instance, to detect which package name to choose when updating software binaries. // Example: "ubuntu_22" Flavor string `json:"flavor"` // BootTime represents system boot time (as Unix timestamp string, e.g. "1586144402") BootTime string `json:"boot_time"` // CPUs - A variable containing the number of CPU cores detected. On systems which provide virtual cores, // it is set to the total number of virtual, not physical, cores. // In addition, on a single-core system the class 1_cpu is set, and on multicore systems the class n_cpus is set, // where n is the number of cores identified (e.g. "4"). CPUs string `json:"cpus"` // CpuSerialNumber - the serial number of the CPU (e.g. "0000000000000000"). CPUSerialNumber string `json:"cpu_sn"` // CPURevision - the revision of the CPU (e.g. "10") CPURevision string `json:"cpu_rev"` // CPUHardware - the CPU hardware description (e.g. "Freescale i.MX6 Quad/DualLite (Device Tree)"). CPUHardware string `json:"cpu_hw"` // Host - The name of the current host, according to the kernel. // It is undefined whether this is qualified or unqualified with a domain name. Host string `json:"host"` // FQHost - The fully qualified name of the host (e.g. "device1.example.com"). FQHost string `json:"fqhost"` // UQHost - The unqualified name of the host (e.g. "device1"). UQHost string `json:"uqhost"` // Interface - The assumed (default) name of the main system interface on this host. Interface string `json:"interface"` // HardwareMAC - This contains the MAC address of the named interface map[interface]macAddress. // For example, the entry for wlan0.1 would be found under the wlan0_1 key. // // Example: // { // "ens1": "52:54:00:4a:db:ee", // "qbee0": "00:00:00:00:00:00" // } HardwareMAC map[string]string `json:"hardware_mac"` // InterfaceFlags - Contains a space separated list of the flags of the named interfaces. // The following device flags are supported: // up // broadcast // debug // loopback // pointopoint // notrailers // running // noarp // promisc // allmulti // multicast // // Example: // { // "ens1": "up broadcast running multicast", // "qbee0": "up pointopoint running noarp multicast" // } InterfaceFlags map[string]string `json:"interface_flags"` // IPAddresses - A system list of IP addresses currently in use by the system (e.g: "100.64.39.78"). IPAddresses string `json:"ip_addresses"` // IPv4First - All four octets of the IPv4 address of the first system interface. //Note: If the system has a single ethernet interface, this variable will contain the IPv4 address. // However, if the system has multiple interfaces, then this variable will simply be the IPv4 address of the first // interface in the list that has an assigned address. // Use IPv4[interface_name] for details on obtaining the IPv4 addresses of all interfaces on a system. IPv4First string `json:"ipv4_first"` // IPv4 - All IPv4 addresses of the system mapped by interface name. // Example: // { // "ens1": "192.168.122.239", // "qbee0": "100.64.39.78" // } IPv4 map[string]string `json:"ipv4"` // RemoteAddress - remote client address from which the inventory was reported (e.g. "1.2.3.4"). RemoteAddress string `json:"remoteaddr"` // LastPolicyUpdate - latest applied policy update timestamp (e.g. "1668156545") LastPolicyUpdate types.Timestamp `json:"last_policy_update"` // LastConfigUpdate - unix timestamp of the last config update (e.g. "1586144402"). LastConfigUpdate types.Timestamp `json:"last_config_update"` // LastConfigCommitID - last applied config commit SHA // (e.g. "6c07b6d021a015329b1815ec954cca6d8c4973c3b574202401dad448e8cdd0f5"). LastConfigCommitID string `json:"last_config_commit_id"` // VPNIndex - defines numeric ID of the VPN server to which the device is connected. VPNIndex string `json:"vpn_idx"` // AgentVersion version of the agent which is currently running on the device. AgentVersion string `json:"cf_version"` }
SystemInfo contains system information collected by the agent.
type UserBaseInfo ¶ added in v1.2024.8
type UserBaseInfo struct { // ID is the unique identifier of the user. ID string `json:"user_id"` // FirstName is the first name of the user. FirstName string `json:"fname"` // LastName is the last name of the user. LastName string `json:"lname"` }
UserBaseInfo is the base information of a user.