This repository was archived by the owner on Apr 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathresponse.go
151 lines (130 loc) · 4.34 KB
/
response.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
package edgecli
import (
"time"
)
type SuccessResponse struct {
Code int `json:"-"`
Message string `json:"message"`
Data interface{} `json:"data"`
}
func (err SuccessResponse) Error() string {
return err.Message
}
func NewSuccessResponse(message string, data ...interface{}) error {
res := SuccessResponse{
Code: 200,
Message: message,
}
if len(data) == 1 {
res.Data = data[0]
} else if len(data) > 1 {
res.Data = data
} else {
res.Data = nil
}
return res
}
type ErrorResponse struct {
Code int `json:"-"`
Message string `json:"message"`
Errors interface{} `json:"errors"`
}
func (err ErrorResponse) Error() string {
return err.Message
}
type AuthTokenResponse struct {
Token string `json:"token"`
}
type ResetPasswordResponse struct {
Email string `json:"email"`
}
type IdentityResponse struct {
Provider string `json:"provider"`
Enabled bool `json:"enabled"`
MetaData map[string]string `json:"metadata"`
}
type ProfileResponse struct {
ID string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Picture string `json:"picture"`
Identities []*IdentityResponse `json:"identities"`
}
type DeviceResponse struct {
ID string `json:"id"`
Name string `json:"name"`
OS string `json:"os"`
VirtualNetworks []*DeviceVirtualNetworkResponse `json:"virtual_networks,omitempty"`
Subnets []*DeviceSubnetRouteResponse `json:"subnets,omitempty"`
}
type DeviceVirtualNetworkResponse struct {
ID string `json:"id"`
Name string `json:"name"`
VirtualIP string `json:"virtual_ip"`
LastSeen time.Time `json:"last_seen"`
Online bool `json:"online"`
}
type DeviceSubnetRouteResponse struct {
ID string `json:"id"`
IP string `json:"ip"`
MacAddr string `json:"mac_addr"`
SubnetMask string `json:"subnet_mask"`
Devices []*SubnetRouteDeviceResponse `json:"devices"`
}
type SubnetRouteDeviceResponse struct {
ID string `json:"id"`
Name string `json:"name"`
IP string `json:"ip"`
MacAddr string `json:"mac_addr"`
Manufacturer string `json:"manufacturer"`
}
type ServerResponse struct {
ID string `json:"id,omitempty"`
Name string `json:"name"`
Country string `json:"country"`
Host string `json:"host,omitempty"`
}
type VirtualNetworkResponse struct {
ID string `json:"id"`
Name string `json:"name"`
IPRange string `json:"ip_range"`
Role int `json:"role"`
Server *ServerResponse `json:"server,omitempty"`
Devices []*VirtualNetworkDeviceResponse `json:"devices,omitempty"`
Users []*VirtualNetworkUserResponse `json:"users,omitempty"`
}
type VirtualNetworkDeviceResponse struct {
ID string `json:"id"`
Name string `json:"name"`
VirtualIP string `json:"virtual_ip"`
LastSeen time.Time `json:"last_seen"`
Online bool `json:"online"`
}
type JoinVirtualNetworkResponse struct {
CommunityName string `json:"community_name"`
SecretKey string `json:"secret_key"`
VirtualIP string `json:"virtual_ip"`
SubnetMask string `json:"subnet_mask"`
Server *ServerResponse `json:"server"`
}
type SecurityKeyResponse struct {
UUID string `json:"uuid"`
Key string `json:"key"`
KeyType int16 `json:"key_type"`
ExpiredAt time.Time `json:"expired_at"`
CreatedAt time.Time `json:"created_at"`
}
type VirtualNetworkUserResponse struct {
UUID string `json:"uuid"`
Email string `json:"email"`
Name string `json:"name"`
Role int `json:"role,omitempty"`
JoinedAt time.Time `json:"joined_at,omitempty"`
}
type InvitationResponse struct {
UUID string `json:"uuid"`
User *VirtualNetworkUserResponse `json:"user,omitempty"`
InvitedBy string `json:"invited_by"`
InvitedAt time.Time `json:"invited_at"`
VirtualNetwork string `json:"virtual_network"`
}