httpfs.yaml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613
  1. openapi: 3.0.3
  2. tags:
  3. - name: fs
  4. info:
  5. title: SFTPGo HTTPFs
  6. description: |
  7. SFTPGo can use custom storage backend implementations compliant with the API defined here.
  8. HTTPFs is a work in progress and makes no API stability promises.
  9. version: 0.1.0
  10. license:
  11. name: AGPL-3.0-only
  12. url: 'https://www.gnu.org/licenses/agpl-3.0.en.html'
  13. servers:
  14. - url: /v1
  15. security:
  16. - ApiKeyAuth: []
  17. - BasicAuth: []
  18. paths:
  19. /stat/{name}:
  20. parameters:
  21. - name: name
  22. in: path
  23. description: object name
  24. required: true
  25. schema:
  26. type: string
  27. get:
  28. tags:
  29. - fs
  30. summary: Describes the named object
  31. operationId: stat
  32. responses:
  33. 200:
  34. description: successful operation
  35. content:
  36. application/json:
  37. schema:
  38. $ref: '#/components/schemas/FileInfo'
  39. 401:
  40. $ref: '#/components/responses/Unauthorized'
  41. 403:
  42. $ref: '#/components/responses/Forbidden'
  43. 404:
  44. $ref: '#/components/responses/NotFound'
  45. 500:
  46. $ref: '#/components/responses/InternalServerError'
  47. default:
  48. $ref: '#/components/responses/DefaultResponse'
  49. /open/{name}:
  50. parameters:
  51. - name: name
  52. in: path
  53. description: object name
  54. required: true
  55. schema:
  56. type: string
  57. - name: offset
  58. in: query
  59. description: 'offset, in bytes, from the start. If not specified 0 must be assumed'
  60. required: false
  61. schema:
  62. type: integer
  63. format: int64
  64. get:
  65. tags:
  66. - fs
  67. summary: Opens the named file for reading
  68. operationId: open
  69. responses:
  70. '200':
  71. description: successful operation
  72. content:
  73. '*/*':
  74. schema:
  75. type: string
  76. format: binary
  77. 401:
  78. $ref: '#/components/responses/Unauthorized'
  79. 403:
  80. $ref: '#/components/responses/Forbidden'
  81. 404:
  82. $ref: '#/components/responses/NotFound'
  83. 500:
  84. $ref: '#/components/responses/InternalServerError'
  85. 501:
  86. $ref: '#/components/responses/NotImplemented'
  87. default:
  88. $ref: '#/components/responses/DefaultResponse'
  89. /create/{name}:
  90. parameters:
  91. - name: name
  92. in: path
  93. description: object name
  94. required: true
  95. schema:
  96. type: string
  97. - name: flags
  98. in: query
  99. description: 'flags to use for opening the file, if omitted O_RDWR|O_CREATE|O_TRUNC must be assumed. Supported flags: https://pkg.go.dev/os#pkg-constants'
  100. required: false
  101. schema:
  102. type: integer
  103. format: int32
  104. - name: checks
  105. in: query
  106. description: 'If set to `1`, the parent directory must exist before creating the file'
  107. required: false
  108. schema:
  109. type: integer
  110. format: int32
  111. post:
  112. tags:
  113. - fs
  114. summary: Creates or opens the named file for writing
  115. operationId: create
  116. requestBody:
  117. content:
  118. '*/*':
  119. schema:
  120. type: string
  121. format: binary
  122. required: true
  123. responses:
  124. 201:
  125. $ref: '#/components/responses/OKResponse'
  126. 401:
  127. $ref: '#/components/responses/Unauthorized'
  128. 403:
  129. $ref: '#/components/responses/Forbidden'
  130. 404:
  131. $ref: '#/components/responses/NotFound'
  132. 500:
  133. $ref: '#/components/responses/InternalServerError'
  134. 501:
  135. $ref: '#/components/responses/NotImplemented'
  136. default:
  137. $ref: '#/components/responses/DefaultResponse'
  138. /rename/{name}:
  139. parameters:
  140. - name: name
  141. in: path
  142. description: object name
  143. required: true
  144. schema:
  145. type: string
  146. - name: target
  147. in: query
  148. description: target name
  149. required: true
  150. schema:
  151. type: string
  152. patch:
  153. tags:
  154. - fs
  155. summary: Renames (moves) source to target
  156. operationId: rename
  157. responses:
  158. 200:
  159. $ref: '#/components/responses/OKResponse'
  160. 401:
  161. $ref: '#/components/responses/Unauthorized'
  162. 403:
  163. $ref: '#/components/responses/Forbidden'
  164. 404:
  165. $ref: '#/components/responses/NotFound'
  166. 500:
  167. $ref: '#/components/responses/InternalServerError'
  168. 501:
  169. $ref: '#/components/responses/NotImplemented'
  170. default:
  171. $ref: '#/components/responses/DefaultResponse'
  172. /remove/{name}:
  173. parameters:
  174. - name: name
  175. in: path
  176. description: object name
  177. required: true
  178. schema:
  179. type: string
  180. delete:
  181. tags:
  182. - fs
  183. summary: Removes the named file or (empty) directory.
  184. operationId: delete
  185. responses:
  186. 200:
  187. $ref: '#/components/responses/OKResponse'
  188. 401:
  189. $ref: '#/components/responses/Unauthorized'
  190. 403:
  191. $ref: '#/components/responses/Forbidden'
  192. 404:
  193. $ref: '#/components/responses/NotFound'
  194. 500:
  195. $ref: '#/components/responses/InternalServerError'
  196. 501:
  197. $ref: '#/components/responses/NotImplemented'
  198. default:
  199. $ref: '#/components/responses/DefaultResponse'
  200. /mkdir/{name}:
  201. parameters:
  202. - name: name
  203. in: path
  204. description: object name
  205. required: true
  206. schema:
  207. type: string
  208. post:
  209. tags:
  210. - fs
  211. summary: Creates a new directory with the specified name
  212. operationId: mkdir
  213. responses:
  214. 200:
  215. $ref: '#/components/responses/OKResponse'
  216. 401:
  217. $ref: '#/components/responses/Unauthorized'
  218. 403:
  219. $ref: '#/components/responses/Forbidden'
  220. 404:
  221. $ref: '#/components/responses/NotFound'
  222. 500:
  223. $ref: '#/components/responses/InternalServerError'
  224. 501:
  225. $ref: '#/components/responses/NotImplemented'
  226. default:
  227. $ref: '#/components/responses/DefaultResponse'
  228. /chmod/{name}:
  229. parameters:
  230. - name: name
  231. in: path
  232. description: object name
  233. required: true
  234. schema:
  235. type: string
  236. - name: mode
  237. in: query
  238. required: true
  239. schema:
  240. type: integer
  241. patch:
  242. tags:
  243. - fs
  244. summary: Changes the mode of the named file
  245. operationId: chmod
  246. responses:
  247. 200:
  248. $ref: '#/components/responses/OKResponse'
  249. 401:
  250. $ref: '#/components/responses/Unauthorized'
  251. 403:
  252. $ref: '#/components/responses/Forbidden'
  253. 404:
  254. $ref: '#/components/responses/NotFound'
  255. 500:
  256. $ref: '#/components/responses/InternalServerError'
  257. 501:
  258. $ref: '#/components/responses/NotImplemented'
  259. default:
  260. $ref: '#/components/responses/DefaultResponse'
  261. /chtimes/{name}:
  262. parameters:
  263. - name: name
  264. in: path
  265. description: object name
  266. required: true
  267. schema:
  268. type: string
  269. - name: access_time
  270. in: query
  271. required: true
  272. schema:
  273. type: string
  274. format: date-time
  275. - name: modification_time
  276. in: query
  277. required: true
  278. schema:
  279. type: string
  280. format: date-time
  281. patch:
  282. tags:
  283. - fs
  284. summary: Changes the access and modification time of the named file
  285. operationId: chtimes
  286. responses:
  287. 200:
  288. $ref: '#/components/responses/OKResponse'
  289. 401:
  290. $ref: '#/components/responses/Unauthorized'
  291. 403:
  292. $ref: '#/components/responses/Forbidden'
  293. 404:
  294. $ref: '#/components/responses/NotFound'
  295. 500:
  296. $ref: '#/components/responses/InternalServerError'
  297. 501:
  298. $ref: '#/components/responses/NotImplemented'
  299. default:
  300. $ref: '#/components/responses/DefaultResponse'
  301. /truncate/{name}:
  302. parameters:
  303. - name: name
  304. in: path
  305. description: object name
  306. required: true
  307. schema:
  308. type: string
  309. - name: size
  310. in: query
  311. required: true
  312. description: 'new file size in bytes'
  313. schema:
  314. type: integer
  315. format: int64
  316. patch:
  317. tags:
  318. - fs
  319. summary: Changes the size of the named file
  320. operationId: truncate
  321. responses:
  322. 200:
  323. $ref: '#/components/responses/OKResponse'
  324. 401:
  325. $ref: '#/components/responses/Unauthorized'
  326. 403:
  327. $ref: '#/components/responses/Forbidden'
  328. 404:
  329. $ref: '#/components/responses/NotFound'
  330. 500:
  331. $ref: '#/components/responses/InternalServerError'
  332. 501:
  333. $ref: '#/components/responses/NotImplemented'
  334. default:
  335. $ref: '#/components/responses/DefaultResponse'
  336. /readdir/{name}:
  337. parameters:
  338. - name: name
  339. in: path
  340. description: object name
  341. required: true
  342. schema:
  343. type: string
  344. get:
  345. tags:
  346. - fs
  347. summary: Reads the named directory and returns the contents
  348. operationId: readdir
  349. responses:
  350. 200:
  351. description: successful operation
  352. content:
  353. application/json:
  354. schema:
  355. type: array
  356. items:
  357. $ref: '#/components/schemas/FileInfo'
  358. 401:
  359. $ref: '#/components/responses/Unauthorized'
  360. 403:
  361. $ref: '#/components/responses/Forbidden'
  362. 404:
  363. $ref: '#/components/responses/NotFound'
  364. 500:
  365. $ref: '#/components/responses/InternalServerError'
  366. 501:
  367. $ref: '#/components/responses/NotImplemented'
  368. default:
  369. $ref: '#/components/responses/DefaultResponse'
  370. /dirsize/{name}:
  371. parameters:
  372. - name: name
  373. in: path
  374. description: object name
  375. required: true
  376. schema:
  377. type: string
  378. get:
  379. tags:
  380. - fs
  381. summary: Returns the number of files and the size for the named directory including any sub-directory
  382. operationId: dirsize
  383. responses:
  384. 200:
  385. description: successful operation
  386. content:
  387. application/json:
  388. schema:
  389. type: object
  390. properties:
  391. files:
  392. type: integer
  393. description: 'Total number of files'
  394. size:
  395. type: integer
  396. format: int64
  397. description: 'Total size of files'
  398. 401:
  399. $ref: '#/components/responses/Unauthorized'
  400. 403:
  401. $ref: '#/components/responses/Forbidden'
  402. 404:
  403. $ref: '#/components/responses/NotFound'
  404. 500:
  405. $ref: '#/components/responses/InternalServerError'
  406. 501:
  407. $ref: '#/components/responses/NotImplemented'
  408. default:
  409. $ref: '#/components/responses/DefaultResponse'
  410. /mimetype/{name}:
  411. parameters:
  412. - name: name
  413. in: path
  414. description: object name
  415. required: true
  416. schema:
  417. type: string
  418. get:
  419. tags:
  420. - fs
  421. summary: Returns the mime type for the named file
  422. operationId: mimetype
  423. responses:
  424. 200:
  425. description: successful operation
  426. content:
  427. application/json:
  428. schema:
  429. type: object
  430. properties:
  431. mime:
  432. type: string
  433. 401:
  434. $ref: '#/components/responses/Unauthorized'
  435. 403:
  436. $ref: '#/components/responses/Forbidden'
  437. 404:
  438. $ref: '#/components/responses/NotFound'
  439. 500:
  440. $ref: '#/components/responses/InternalServerError'
  441. 501:
  442. $ref: '#/components/responses/NotImplemented'
  443. default:
  444. $ref: '#/components/responses/DefaultResponse'
  445. /statvfs/{name}:
  446. parameters:
  447. - name: name
  448. in: path
  449. description: object name
  450. required: true
  451. schema:
  452. type: string
  453. get:
  454. tags:
  455. - fs
  456. summary: Returns the VFS stats for the specified path
  457. operationId: statvfs
  458. responses:
  459. 200:
  460. description: successful operation
  461. content:
  462. application/json:
  463. schema:
  464. $ref: '#/components/schemas/StatVFS'
  465. 401:
  466. $ref: '#/components/responses/Unauthorized'
  467. 403:
  468. $ref: '#/components/responses/Forbidden'
  469. 404:
  470. $ref: '#/components/responses/NotFound'
  471. 500:
  472. $ref: '#/components/responses/InternalServerError'
  473. 501:
  474. $ref: '#/components/responses/NotImplemented'
  475. default:
  476. $ref: '#/components/responses/DefaultResponse'
  477. components:
  478. responses:
  479. OKResponse:
  480. description: successful operation
  481. content:
  482. application/json:
  483. schema:
  484. $ref: '#/components/schemas/ApiResponse'
  485. BadRequest:
  486. description: Bad Request
  487. content:
  488. application/json:
  489. schema:
  490. $ref: '#/components/schemas/ApiResponse'
  491. Unauthorized:
  492. description: Unauthorized
  493. content:
  494. application/json:
  495. schema:
  496. $ref: '#/components/schemas/ApiResponse'
  497. Forbidden:
  498. description: Forbidden
  499. content:
  500. application/json:
  501. schema:
  502. $ref: '#/components/schemas/ApiResponse'
  503. NotFound:
  504. description: Not Found
  505. content:
  506. application/json:
  507. schema:
  508. $ref: '#/components/schemas/ApiResponse'
  509. NotImplemented:
  510. description: Not Implemented
  511. content:
  512. application/json:
  513. schema:
  514. $ref: '#/components/schemas/ApiResponse'
  515. Conflict:
  516. description: Conflict
  517. content:
  518. application/json:
  519. schema:
  520. $ref: '#/components/schemas/ApiResponse'
  521. RequestEntityTooLarge:
  522. description: Request Entity Too Large, max allowed size exceeded
  523. content:
  524. application/json:
  525. schema:
  526. $ref: '#/components/schemas/ApiResponse'
  527. InternalServerError:
  528. description: Internal Server Error
  529. content:
  530. application/json:
  531. schema:
  532. $ref: '#/components/schemas/ApiResponse'
  533. DefaultResponse:
  534. description: Unexpected Error
  535. content:
  536. application/json:
  537. schema:
  538. $ref: '#/components/schemas/ApiResponse'
  539. schemas:
  540. ApiResponse:
  541. type: object
  542. properties:
  543. message:
  544. type: string
  545. description: 'message, can be empty'
  546. error:
  547. type: string
  548. description: error description if any
  549. FileInfo:
  550. type: object
  551. properties:
  552. name:
  553. type: string
  554. description: base name of the file
  555. size:
  556. type: integer
  557. format: int64
  558. description: length in bytes for regular files; system-dependent for others
  559. mode:
  560. type: integer
  561. description: |
  562. File mode and permission bits. More details here: https://golang.org/pkg/io/fs/#FileMode.
  563. Let's see some examples:
  564. - for a directory mode&2147483648 != 0
  565. - for a symlink mode&134217728 != 0
  566. - for a regular file mode&2401763328 == 0
  567. last_modified:
  568. type: string
  569. format: date-time
  570. StatVFS:
  571. type: object
  572. properties:
  573. bsize:
  574. type: integer
  575. description: file system block size
  576. frsize:
  577. type: integer
  578. description: fundamental fs block size
  579. blocks:
  580. type: integer
  581. description: number of blocks
  582. bfree:
  583. type: integer
  584. description: free blocks in file system
  585. bavail:
  586. type: integer
  587. description: free blocks for non-root
  588. files:
  589. type: integer
  590. description: total file inodes
  591. ffree:
  592. type: integer
  593. description: free file inodes
  594. favail:
  595. type: integer
  596. description: free file inodes for non-root
  597. fsid:
  598. type: integer
  599. description: file system id
  600. flag:
  601. type: integer
  602. description: bit mask of f_flag values
  603. namemax:
  604. type: integer
  605. description: maximum filename length
  606. securitySchemes:
  607. BasicAuth:
  608. type: http
  609. scheme: basic
  610. ApiKeyAuth:
  611. type: apiKey
  612. in: header
  613. name: X-API-KEY