-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add support for /devices end point include examples
- Loading branch information
Showing
3 changed files
with
133 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package models | ||
|
||
// EdgeDeviceAPI is the entity that represents and Edge Device | ||
// It is a combination of the data of a Device owned by Inventory API | ||
// and the Device data saved on Edge API | ||
type EdgeDeviceAPI struct { | ||
*Device | ||
DeviceName string `example:"device_name"` // The device name | ||
LastSeen string `example:"2023-07-19T08:09:08.084004+00:00"` // Last datetime that device updated | ||
Booted bool `example:"true"` // Booted status is referring to the LastDeployment of this device | ||
} | ||
|
||
// DeviceGroupAPI is a record of Edge Devices Groups | ||
// Account is the account associated with the device group | ||
// Type is the device group type and must be "static" or "dynamic" | ||
type DeviceGroupAPI struct { | ||
Name string `json:"Name" example:"device_group name"` // The device group name` | ||
Type string `json:"Type" example:"static"` // The device group type`` | ||
Devices []Device `faker:"-" json:"Devices"` // Devices that belong to the group | ||
ValidUpdate bool `json:"ValidUpdate" example:"true"` // indicate if the update is valid | ||
} | ||
|
||
// UpdateTransactionAPI represents the combination of an OSTree commit and a set of Inventory | ||
type UpdateTransactionAPI struct { | ||
Model | ||
Commit *Commit `json:"Commit"` | ||
CommitID uint `json:"CommitID" example:"1754"` // Commit ID of device | ||
OldCommits []Commit `json:"OldCommits"` // Old Commit ID if the device has one | ||
Devices []Device `json:"Devices"` // List of Devices | ||
Tag string `json:"Tag" example:"device_tag"` // Tag og Device if device has one | ||
Status string `json:"Status" example:"SUCCESS"` // Status of device | ||
RepoID *uint `json:"RepoID" example:"2256"` // Repo ID | ||
Repo *Repo `json:"Repo"` | ||
ChangesRefs bool `json:"ChangesRefs" example:"false"` | ||
DispatchRecords []DispatchRecord `json:"DispatchRecords"` | ||
} | ||
|
||
// DeviceDetailsAPI is a Device with Image and Update transactions | ||
// It contains data from multiple tables on the database | ||
type DeviceDetailsAPI struct { | ||
Device EdgeDeviceAPI `json:"Device,omitempty"` // Details of device like name, LastSeen and more | ||
Image *ImageInfo `json:"ImageInfo"` // Information of device's image | ||
UpdateTransactions *[]UpdateTransactionAPI `json:"UpdateTransactions,omitempty"` | ||
DevicesGroups *[]DeviceGroupAPI `json:"DevicesGroups,omitempty"` // Device's groups | ||
Updating *bool `json:"DeviceUpdating,omitempty" example:"true"` // If there is update to device | ||
} | ||
|
||
// DeviceDetailsListAPI is the list of devices with details from Inventory and Edge API | ||
type DeviceDetailsListAPI struct { | ||
Total int `json:"total" example:"40"` // total number of device | ||
Count int `json:"count" example:"40"` // total number of device | ||
Devices []DeviceDetailsAPI `json:"data"` // List of Devices | ||
} | ||
|
||
// DeviceDeviceGroupAPI is a struct of device group name and id needed for DeviceView | ||
type DeviceDeviceGroupAPI struct { | ||
ID uint | ||
Name string | ||
} | ||
|
||
// DeviceViewAPI is the device information needed for the UI | ||
type DeviceViewAPI struct { | ||
DeviceID uint `json:"DeviceID" example:"1913277"` // ID of device | ||
DeviceName string `json:"DeviceName" example:"device_name"` // Name of device | ||
DeviceUUID string `json:"DeviceUUID"` | ||
ImageID uint `json:"ImageID" example:"323241"` // ID of image | ||
ImageName string `json:"ImageName" example:"image_name"` // Name of image | ||
LastSeen EdgeAPITime `json:"LastSeen" example:"2023-07-19T08:09:08.084004+00:00"` // Last datetime that device updated` | ||
UpdateAvailable bool `json:"UpdateAvailable" example:"true"` // indicate if there is update to device | ||
Status string `json:"Status" example:"SUCCESS"` // Status of device | ||
ImageSetID uint `json:"ImageSetID" example:"323234341"` // ID of image set | ||
DeviceGroups []DeviceDeviceGroupAPI `json:"DeviceGroups"` // Device's groups | ||
DispatcherStatus string `json:"DispatcherStatus"` | ||
DispatcherReason string `json:"DispatcherReason"` | ||
} | ||
|
||
// DeviceViewListAPI is the list of devices for a given account, formatted for the UI | ||
type DeviceViewListAPI struct { | ||
Total int64 `json:"total" example:"40"` // total number of device` | ||
Devices []DeviceViewAPI `json:"devices"` // List of Devices | ||
} |
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