/
Responses.go
142 lines (117 loc) · 4 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
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
package models
import "time"
const (
// NotFoundError error from server
NotFoundError string = "Not found"
// ActionNotAllowed error from server
ActionNotAllowed string = "Action not allowed"
// WrongLength error from server
WrongLength string = "Wrong length"
// ServerError error from server
ServerError string = "Server Error"
// WrongInputFormatError wrong user input
WrongInputFormatError string = "Wrong inputFormat!"
// InvalidTokenError token is not valid
InvalidTokenError string = "Token not valid"
// InvalidCallbackURL token is not valid
InvalidCallbackURL string = "Callback url is invalid"
// BatchSizeTooLarge batch is too large
BatchSizeTooLarge string = "BatchSize soo large!"
// WrongIntegerFormat integer is probably no integer
WrongIntegerFormat string = "Number is string"
// MultipleSourceNameErr err name already exists
MultipleSourceNameErr string = "You can't have multiple sources with the same name"
// UserIsInvalidErr err if user is invalid
UserIsInvalidErr string = "user is invalid"
)
// ResponseStatus the status of response
type ResponseStatus uint8
const (
//ResponseError if there was an error
ResponseError ResponseStatus = 0
//ResponseSuccess if the response is successful
ResponseSuccess ResponseStatus = 1
)
const (
// HeaderStatus headername for status in response
HeaderStatus string = "X-Response-Status"
// HeaderStatusMessage headername for status in response
HeaderStatusMessage string = "X-Response-Message"
// HeaderContentType contenttype of response
HeaderContentType string = "Content-Type"
// HeaderFileName filename header
HeaderFileName string = "X-Filename"
// HeaderFileID fileid header
HeaderFileID string = "X-FileID"
// HeaderEncryption encryption header
HeaderEncryption string = "X-Encryption"
// HeaderRequest request content
HeaderRequest string = "Request"
// HeaderContentLength request content length
HeaderContentLength string = "ContentLength"
// HeaderChecksum files checksum
HeaderChecksum string = "Checksum"
)
// StringResponse response containing only one string
type StringResponse struct {
String string `json:"content"`
}
// StringSliceResponse response containing only one string slice
type StringSliceResponse struct {
Slice []string `json:"slice"`
}
// FileResponseItem file item for file response
type FileResponseItem struct {
ID uint `json:"id"`
Size int64 `json:"size"`
CreationDate time.Time `json:"creation"`
Name string `json:"name"`
PublicName string `json:"pubname"`
IsPublic bool `json:"isPub"`
Attributes FileAttributes `json:"attrib"`
Encryption string `json:"e"`
Checksum string `json:"checksum"`
}
// PublishResponse response for publishing a file
type PublishResponse struct {
PublicFilename string `json:"pubName"`
}
// BulkPublishResponse response for publishing a file
type BulkPublishResponse struct {
Files []UploadResponse `json:"files"`
}
// ListFileResponse response for list files
type ListFileResponse struct {
Files []FileResponseItem `json:"files"`
}
// UploadResponse response for uploading file
type UploadResponse struct {
FileID uint `json:"fileID"`
Filename string `json:"filename"`
PublicFilename string `json:"publicFilename,omitempty"`
Checksum string `json:"checksum"`
FileSize int64 `json:"size"`
Namespace string `json:"ns"`
}
// LoginResponse response for login
type LoginResponse struct {
Token string `json:"token"`
Namespace string `json:"ns"`
}
// CountResponse response containing a count of changed items
type CountResponse struct {
Count uint32 `json:"count"`
}
// IDsResponse response containing a list of ids
type IDsResponse struct {
IDs []uint `json:"ids"`
}
// UserAttributeDataResponse response for userattribute data
type UserAttributeDataResponse struct {
Namespace []Namespaceinfo `json:"nsData"`
}
// Namespaceinfo info for namespace
type Namespaceinfo struct {
Name string `json:"ns"`
Groups []string `json:"groups"`
}