-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloud.go
106 lines (86 loc) · 2.14 KB
/
cloud.go
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
package shelly
import (
"context"
"github.com/mongoose-os/mos/common/mgrpc"
"github.com/mongoose-os/mos/common/mgrpc/frame"
)
type CloudSetConfigRequest struct {
Config CloudConfig `json:"config"`
}
func (r *CloudSetConfigRequest) Method() string {
return "Cloud.SetConfig"
}
func (r *CloudSetConfigRequest) NewTypedResponse() *SetConfigResponse {
return &SetConfigResponse{}
}
func (r *CloudSetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *CloudSetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*SetConfigResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type CloudConfig struct {
// Enable is true if cloud connection is enabled, false otherwise
Enable bool `json:"enable"`
// Server is the name of the server to which the device is connected (optional).
Server *string `json:"server"`
}
type CloudGetConfigRequest struct{}
func (r *CloudGetConfigRequest) Method() string {
return "Cloud.GetConfig"
}
func (r *CloudGetConfigRequest) NewTypedResponse() *RPCEmptyResponse {
return &RPCEmptyResponse{}
}
func (r *CloudGetConfigRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *CloudGetConfigRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*RPCEmptyResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}
type CloudStatus struct {
Connected bool `json:"connected"`
}
type CloudGetStatusRequest struct{}
func (r *CloudGetStatusRequest) Method() string {
return "Cloud.GetStatus"
}
func (r *CloudGetStatusRequest) NewTypedResponse() *RPCEmptyResponse {
return &RPCEmptyResponse{}
}
func (r *CloudGetStatusRequest) NewResponse() any {
return r.NewTypedResponse()
}
func (r *CloudGetStatusRequest) Do(
ctx context.Context,
c mgrpc.MgRPC,
credsCallback mgrpc.GetCredsCallback,
) (
*RPCEmptyResponse,
*frame.Response,
error,
) {
resp := r.NewTypedResponse()
raw, err := Do(ctx, c, credsCallback, r, resp)
return resp, raw, err
}