-
Notifications
You must be signed in to change notification settings - Fork 0
/
responses.go
93 lines (83 loc) · 2.42 KB
/
responses.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
package model
import (
"encoding/json"
"github.com/willie68/GoBlobStore/internal/config"
)
// GetConfigResponse REST response for config request
type GetConfigResponse struct {
TenantID string `json:"tenantid"`
// to be compatible
Created bool `json:"created"`
Backup config.Storage `json:"backup"`
LastError error `json:"lastError"`
Properties map[string]any `json:"properties"`
}
// MarshalJSON marshall this to JSON
func (r GetConfigResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type string `json:"type"`
TenantID string `json:"tenantid"`
Created bool `json:"created"`
Backup config.Storage `json:"backup"`
LastError error `json:"lastError"`
Properties map[string]any `json:"properties"`
}{
Type: "configResponse",
TenantID: r.TenantID,
Created: r.Created,
Backup: r.Backup,
LastError: r.LastError,
Properties: r.Properties,
})
}
// CreateResponse REST response for create response
type CreateResponse struct {
TenantID string `json:"tenantid"`
Backup string `json:"backup"`
}
// MarshalJSON marshall this to JSON
func (r CreateResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type string `json:"type"`
TenantID string `json:"tenantid"`
Backup string `json:"backup"`
}{
Type: "createResponse",
TenantID: r.TenantID,
Backup: r.Backup,
})
}
// DeleteResponse REST response for delete response
type DeleteResponse struct {
TenantID string `json:"tenantid"`
ProcessID string `json:"processid"`
}
// MarshalJSON marshall this to JSON
func (r DeleteResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type string `json:"type"`
TenantID string `json:"tenantid"`
ProcessID string `json:"processid"`
}{
Type: "deleteResponse",
TenantID: r.TenantID,
ProcessID: r.ProcessID,
})
}
// SizeResponse REST response for size response
type SizeResponse struct {
TenantID string `json:"tenantid"`
Size int64 `json:"size"`
}
// MarshalJSON marshall this to JSON
func (r SizeResponse) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Type string `json:"type"`
TenantID string `json:"tenantid"`
Size int64 `json:"size"`
}{
Type: "sizeResponse",
TenantID: r.TenantID,
Size: r.Size,
})
}