-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi_scheme.go
222 lines (193 loc) · 5.39 KB
/
api_scheme.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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
package koofrclient
import (
"path"
)
type TokenRequest struct {
Email string `json:"email"`
Password string `json:"password"`
}
type Token struct {
Token string
}
type MountType string
const (
MountDeviceType = "device"
MountExportType = "export"
MountImportType = "import"
)
type Mount struct {
Id string `json:"id"`
Name string `json:"name"`
Type MountType `json:"type"`
Origin string `json:"origin"`
SpaceTotal int64 `json:"spaceTotal"`
SpaceUsed int64 `json:"spaceUsed"`
Online bool `json:"online"`
Owner MountUser `json:"owner"`
Users []MountUser `json:"users"`
Groups []MountGroup `json:"groups"`
Version int `json:"version"`
Permissions MountPermissions `json:"permissions"`
IsPrimary bool `json:"isPrimary"`
IsShared bool `json:"isShared"`
}
type MountUser struct {
Id string `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Permissions MountPermissions `json:"permissions"`
}
type MountGroup struct {
Id string `json:"id"`
Name string `json:"name"`
Permissions MountPermissions `json:"permissions"`
}
type MountPermissions struct {
Read bool `json:"READ"`
Write bool `json:"write"`
Owner bool `json:"OWNER"`
Mount bool `json:"MOUNT"`
CreateReceiver bool `json:"CREATE_RECEIVER"`
CreateLink bool `json:"CREATE_LINK"`
Comment bool `json:"COMMENT"`
}
type DeviceProvider string
const (
StorageHubProvider = "storagehub"
StorageBlobProvider = "storageblob"
)
type Device struct {
Id string `json:"id"`
ApiKey string `json:"apiKey"`
Name string `json:"name"`
Status string `json:"status"`
SpaceTotal int64 `json:"spaceTotal"`
SpaceUsed int64 `json:"spaceUsed"`
SpaceFree int64 `json:"spaceFree"`
Version int `json:"version"`
Provider struct {
Name string `json:"name"`
Data interface{} `json:"data"`
} `json:"provider"`
ReadOnly bool `json:"readonly"`
RootMountId string `json:"rootMountId"`
}
type DeviceCreate struct {
Name string `json:"name"`
ProviderName DeviceProvider `json:"providerName"`
}
type DeviceUpdate struct {
Name string `json:"name"`
}
type FolderCreate struct {
Name string `json:"name"`
}
type FileCopy struct {
ToMountId string `json:"toMountId"`
TPath string `json:"toPath"`
Modified *int64 `json:"modified,omitempty"`
}
type FileMove struct {
ToMountId string `json:"toMountId"`
TPath string `json:"toPath"`
}
type FileSpan struct {
Start int64
End int64
}
type FileUpload struct {
Name string `json:"name"`
}
type PutOptions struct {
OverwriteIfModified *int64
OverwriteIfSize *int64
OverwriteIfHash *string
OverwriteIgnoreNonExisting bool
NoRename bool
ForceOverwrite bool
SetModified *int64
}
type CopyOptions struct {
SetModified *int64
}
type DeleteOptions struct {
RemoveIfModified *int64
RemoveIfSize *int64
RemoveIfHash *string
RemoveIfEmpty bool
}
type FileInfo struct {
Name string `json:"name"`
Type string `json:"type"`
Modified int64 `json:"modified"`
Size int64 `json:"size"`
ContentType string `json:"contentType"`
Path string `json:"path"`
Hash string `json:"hash"`
}
type FileTree struct {
FileInfo
Children []*FileTree `json:"children"`
}
func (tree *FileTree) Flatten() []FileInfo {
trees := []*FileTree{tree}
for i := 0; i < len(trees); i++ {
tree := trees[i]
for _, child := range tree.Children {
child.Name = path.Join(tree.Name, child.Name)
trees = append(trees, child)
}
}
infos := make([]FileInfo, len(trees))
for i, tree := range trees {
infos[i] = tree.FileInfo
}
return infos
}
type User struct {
Id string `json:"id"`
FirstName string `json:"firstName"`
LastName string `json:"lastName"`
Email string `json:"email"`
}
type Shared struct {
Name string `json:name`
Type MountType `json:type`
Modified int64 `json:modified`
Size int64 `json:size`
ContentType string `json:contentType`
Hash string `json:hash`
Mount Mount `json:mount`
Link Link `json:link`
Receiver Receiver `json:receiver`
}
type Link struct {
Id string `json:id`
Name string `json:name`
Path string `json:path`
Counter int64 `json:counter`
Url string `json:url`
ShortUrl string `json:shortUrl`
Hash string `json:hash`
Host string `json:host`
HasPassword bool `json:hasPassword`
Password string `json:password`
ValidFrom int64 `json:validFrom`
ValidTo int64 `json:validTo`
PasswordRequired bool `json:passwordRequired`
}
type Receiver struct {
Id string `json:id`
Name string `json:name`
Path string `json:path`
Counter int64 `json:counter`
Url string `json:url`
ShortUrl string `json:shortUrl`
Hash string `json:hash`
Host string `json:host`
HasPassword bool `json:hasPassword`
Password string `json:password`
ValidFrom int64 `json:validFrom`
ValidTo int64 `json:validTo`
Alert bool `json:alert`
}