-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathfeatures.go
More file actions
74 lines (56 loc) · 1.77 KB
/
features.go
File metadata and controls
74 lines (56 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package v1
import (
"net/http"
"github.com/gin-gonic/gin"
dto "github.com/device-management-toolkit/console/internal/entity/dto/v1"
)
func (r *deviceManagementRoutes) getVersion(c *gin.Context) {
guid := c.Param("guid")
versionv1, _, err := r.d.GetVersion(c.Request.Context(), guid)
if err != nil {
r.l.Error(err, "http - v1 - GetVersion")
ErrorResponse(c, err)
return
}
c.JSON(http.StatusOK, versionv1)
}
func (r *deviceManagementRoutes) getFeatures(c *gin.Context) {
guid := c.Param("guid")
features, _, err := r.d.GetFeatures(c.Request.Context(), guid)
if err != nil {
r.l.Error(err, "http - v1 - getFeatures")
ErrorResponse(c, err)
return
}
v1Features := dto.GetFeaturesResponse{
Redirection: features.Redirection,
KVM: features.EnableKVM,
SOL: features.EnableSOL,
IDER: features.EnableIDER,
OptInState: features.OptInState,
UserConsent: features.UserConsent,
KVMAvailable: features.KVMAvailable,
OCR: features.OCR,
HTTPSBootSupported: features.HTTPSBootSupported,
WinREBootSupported: features.WinREBootSupported,
LocalPBABootSupported: features.LocalPBABootSupported,
RemoteErase: features.RemoteErase,
RemoteEraseSupported: features.RemoteEraseSupported,
}
c.JSON(http.StatusOK, v1Features)
}
func (r *deviceManagementRoutes) setFeatures(c *gin.Context) {
guid := c.Param("guid")
var features dto.Features
if err := c.ShouldBindJSON(&features); err != nil {
ErrorResponse(c, err)
return
}
features, _, err := r.d.SetFeatures(c.Request.Context(), guid, features)
if err != nil {
r.l.Error(err, "http - v1 - setFeatures")
ErrorResponse(c, err)
return
}
c.JSON(http.StatusOK, features)
}