-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathapi-description.yaml
More file actions
330 lines (326 loc) · 10.5 KB
/
api-description.yaml
File metadata and controls
330 lines (326 loc) · 10.5 KB
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
openapi: "3.0.3"
info:
title: "Cryptify API"
description: "This is the cryptify server that manages encrypted files."
version: "1.0.0"
servers:
- url: http://localhost:8000
description: Development server
tags:
- name: "Health"
description: "Health check"
- name: "File upload"
description: "Upload files"
- name: "File download"
description: "Download files"
- name: "Usage"
description: "Upload usage quotas"
paths:
/health:
get:
tags:
- "Health"
summary: "Health check endpoint"
operationId: "health"
responses:
"200":
description: "Service is healthy"
content:
text/plain:
schema:
type: "string"
example: "OK"
/fileupload/init:
post:
tags:
- "File upload"
summary: "Initialize multipart file upload"
operationId: "initFileUpload"
requestBody:
content:
application/json:
schema:
type: "object"
required:
- recipient
- mailContent
- mailLang
- confirm
properties:
recipient:
type: "string"
format: "email"
example: "recipient@example.com"
description: "Email address of the recipient"
mailContent:
type: "string"
example: "Here is your encrypted file"
description: "Content to include in the email"
mailLang:
type: "string"
enum: ["EN", "NL"]
example: "EN"
description: "Email language (EN or NL)"
confirm:
type: "boolean"
example: true
description: "Whether to send a confirmation email to the sender"
responses:
"200":
description: "Successful operation"
headers:
cryptifytoken:
description: "Identifies the initial version of the file to be uploaded. Needs to be passed into the file part upload request."
required: true
schema:
type: "string"
content:
application/json:
schema:
type: "object"
properties:
uuid:
type: "string"
format: "uuid"
description: "Unique identifier for the file upload"
/fileupload/{uuid}:
put:
tags:
- "File upload"
summary: "Upload a file part"
operationId: "uploadFilePart"
parameters:
- in: "header"
name: "cryptifytoken"
description:
"Identifies the version of the upload file parts. Part of the header from the last fileupload response."
schema:
type: "string"
required: true
- in: "header"
name: "Content-Range"
description:
"Which offset of a file is sent, example: `bytes 200-1000/*`."
schema:
type: "string"
required: true
- in: "path"
name: "uuid"
required: true
description: "The unique identifier received when initializing file upload."
schema:
type: "string"
format: "uuid"
requestBody:
content:
application/octet-stream:
schema:
type: "string"
format: "binary"
responses:
"200":
description: "Successful operation."
headers:
cryptifytoken:
required: true
schema:
description: "Identifies the new version of the upload file parts. Needs to be passed into the next file part upload request."
type: "string"
"409":
description: "Server file parts cryptifytoken differs from cryptifytoken in request."
headers:
cryptifytoken:
required: true
schema:
description:
"Identifies the version of the upload file parts. Needs to be passed into the next file part upload request."
type: "string"
"400":
description: "One of the input parameters is incorrect."
content:
application/json:
schema:
type: "object"
properties:
message:
type: "string"
"404":
description: "Partially uploaded file does not exist."
"413":
description: "The upload exceeds the per-upload size limit (5 GB)."
content:
application/json:
schema:
$ref: "#/components/schemas/PayloadTooLarge"
/fileupload/finalize/{uuid}:
post:
tags:
- "File upload"
summary: "Finalize multipart file upload and send mail to recipient"
operationId: "finalizeFileUpload"
parameters:
- in: "header"
name: "Content-Range"
description:
"Indicates the final file size: `bytes */1073741824`."
schema:
type: "string"
required: true
- in: "path"
name: "uuid"
description: "The unique identifier received when initializing file upload."
required: true
schema:
type: "string"
format: "uuid"
responses:
"200":
description: "Successful operation"
"409":
description: "Server file parts cryptifytoken differs from cryptifytoken in request"
headers:
cryptifytoken:
required: true
schema:
description: "Identifies the version of the upload file parts. Needs to be passed into the next file part upload request."
type: "string"
"400":
description: "One of the input parameters is incorrect."
content:
application/json:
schema:
type: "object"
properties:
message:
type: "string"
"404":
description: "Partially upload file does not exist."
"413":
description: "The sender has exceeded the rolling 14-day upload limit (15 GB)."
content:
application/json:
schema:
$ref: "#/components/schemas/PayloadTooLarge"
"422":
description: "Data is missing to form complete file."
/usage:
get:
tags:
- "Usage"
summary: "Get rolling upload usage for a sender email"
description:
"Returns the bytes uploaded by the given email address in the last 14 days,
together with the applicable limits. Frontends use this to warn the user
before they hit the limit."
operationId: "getUsage"
parameters:
- in: "query"
name: "email"
description: "The sender email address to query."
required: true
schema:
type: "string"
format: "email"
responses:
"200":
description: "Usage information for the given email."
content:
application/json:
schema:
type: "object"
required:
- email
- used_bytes
- limit_bytes
- window_days
- per_upload_limit_bytes
properties:
email:
type: "string"
format: "email"
used_bytes:
type: "integer"
format: "int64"
description: "Bytes uploaded by this email in the rolling window."
limit_bytes:
type: "integer"
format: "int64"
description: "Rolling-window upload limit in bytes (15 GB)."
window_days:
type: "integer"
description: "Length of the rolling window in days."
per_upload_limit_bytes:
type: "integer"
format: "int64"
description: "Maximum size of a single upload in bytes (5 GB)."
resets_at:
type: "string"
format: "date-time"
nullable: true
description:
"RFC-3339 timestamp at which the oldest recorded upload
falls out of the rolling window, partially freeing quota.
Null if the sender has no recorded uploads."
/filedownload/{uuid}:
get:
tags:
- "File download"
summary: "Download a file"
operationId: "downloadFile"
parameters:
- in: "path"
name: "uuid"
required: true
description: "The unique identifier received when initializing file upload."
schema:
type: "string"
format: "uuid"
responses:
"200":
description: "Successful operation."
content:
application/cryptify+octet-stream:
schema:
type: "string"
format: "binary"
"400":
description: "One of the input parameters is incorrect."
content:
application/json:
schema:
type: "object"
properties:
message:
type: "string"
"404":
description: "Uploaded file does not exist."
components:
schemas:
PayloadTooLarge:
type: "object"
required:
- error
- limit
- used_bytes
- limit_bytes
properties:
error:
type: "string"
description: "Human-readable explanation of which limit was hit."
limit:
type: "string"
enum:
- "per_upload"
- "rolling_window"
description: "Which limit tripped the 413 response."
used_bytes:
type: "integer"
format: "int64"
description:
"Bytes already attributed to the sender in the relevant window.
For per_upload, this is the bytes already written for the current
upload before the rejected chunk."
limit_bytes:
type: "integer"
format: "int64"
description: "The limit value in bytes."