-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d170f9e
commit 7994f50
Showing
7 changed files
with
203 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
) | ||
|
||
// EdgeVersion indicates the version of the edge server that the device is connected to. | ||
type EdgeVersion uint8 | ||
|
||
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 | ||
) | ||
|
||
// DeviceStatus is the status of a device. | ||
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"` | ||
} | ||
|
||
// GetDeviceStatus returns device status. | ||
func (cli *Client) GetDeviceStatus(ctx context.Context, deviceID string) (*DeviceStatus, error) { | ||
deviceStatus := new(DeviceStatus) | ||
|
||
path := fmt.Sprintf("/api/v2/device/%s/status", deviceID) | ||
|
||
if err := cli.Call(ctx, http.MethodGet, path, nil, deviceStatus); err != nil { | ||
return nil, err | ||
} | ||
|
||
return deviceStatus, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters