Skip to content

Commit 9b36af8

Browse files
committed
fix api docs
1 parent 1120022 commit 9b36af8

File tree

5 files changed

+199
-61
lines changed

5 files changed

+199
-61
lines changed

code/go/0chain.net/blobbercore/handler/handler.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ func AllocationHandler(ctx context.Context, r *http.Request) (interface{}, error
387387

388388
// swagger:route GET /v1/file/meta/{allocation} GetFileMeta
389389
// Get file meta data.
390-
// Retrieve file meta data from the blobber.
390+
// Retrieve file meta data from the blobber. Retrieves a generic map of string keys and values.
391391
//
392392
// parameters:
393393
// +name: allocation
@@ -1007,7 +1007,7 @@ func RefsHandler(ctx context.Context, r *http.Request) (interface{}, error) {
10071007
return response, nil
10081008
}
10091009

1010-
// swagger:route GET /v1/file/refs/{allocation} GetRecentRefs
1010+
// swagger:route GET /v1/file/refs/recent/{allocation} GetRecentRefs
10111011
// Get recent references.
10121012
// Retrieve recent references added to an allocation, starting at a specific date, organized in a paginated table.
10131013
//
@@ -1726,7 +1726,7 @@ func RevokeShare(ctx context.Context, r *http.Request) (interface{}, error) {
17261726

17271727
// swagger:route POST /v1/marketplace/shareinfo/{allocation} PostShareInfo
17281728
// Share a file.
1729-
// Handle share file requests from clients.
1729+
// Handle share file requests from clients. Returns generic mapping.
17301730
//
17311731
// parameters:
17321732
// +name: allocation
@@ -1775,9 +1775,6 @@ func RevokeShare(ctx context.Context, r *http.Request) (interface{}, error) {
17751775
// responses:
17761776
//
17771777
// 200:
1778-
// description: "Generic map response `map[string]interface{}`"
1779-
// examples:
1780-
// {"message": "Share info added successfully"}
17811778
// 400:
17821779

17831780
func InsertShare(ctx context.Context, r *http.Request) (interface{}, error) {

code/go/0chain.net/blobbercore/handler/handler_playlist.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"github.com/0chain/blobber/code/go/0chain.net/core/common"
99
)
1010

11-
// swagger:route GET /v1/file/playlist/{allocation} GetPlaylist
11+
// swagger:route GET /v1/playlist/latest/{allocation} GetPlaylist
1212
// Get playlist.
1313
// Loads playlist from a given path in an allocation.
1414
//

code/go/0chain.net/blobbercore/handler/object_operation_handler.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ func (fsh *StorageHandler) RedeemReadMarker(ctx context.Context, r *http.Request
258258
// swagger:route GET /v1/file/download/{allocation} GetDownloadFile
259259
// Download a file.
260260
//
261-
// Download Handler (downloadFile).
261+
// Download Handler (downloadFile). The response is either a byte stream or a FileDownloadResponse, which contains the file data or the thumbnail data, and the merkle proof if the download is verified.
262+
// This depends on the "X-Verify-Download" header. If the header is set to "true", the response is a FileDownloadResponse, otherwise it is a byte stream.
262263
//
263264
// parameters:
264265
// +name: allocation
@@ -340,7 +341,7 @@ func (fsh *StorageHandler) RedeemReadMarker(ctx context.Context, r *http.Request
340341
//
341342
// responses:
342343
//
343-
// 200: FileDownloadResponse | []byte
344+
// 200: FileDownloadResponse
344345
// 400:
345346

346347
func (fsh *StorageHandler) DownloadFile(ctx context.Context, r *http.Request) (interface{}, error) {

swagger.md

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ Documentation of the blobber API.
4444
| GET | /v1/file/list/{allocation} | [get list files](#get-list-files) | List files. |
4545
| GET | /v1/marketplace/shareinfo/{allocation} | [get list share info](#get-list-share-info) | List shared files. |
4646
| GET | /v1/file/objecttree/{allocation} | [get object tree](#get-object-tree) | Get path object tree. |
47-
| GET | /v1/file/playlist/{allocation} | [get playlist](#get-playlist) | Get playlist. |
47+
| GET | /v1/playlist/latest/{allocation} | [get playlist](#get-playlist) | Get playlist. |
4848
| GET | /v1/playlist/file/{allocation} | [get playlist file](#get-playlist-file) | Get playlist file. |
49-
| GET | /v1/file/refs/{allocation} | [get recent refs](#get-recent-refs) | Get recent references. |
49+
| GET | /v1/file/refs/recent/{allocation} | [get recent refs](#get-recent-refs) | Get recent references. |
5050
| GET | /v1/file/referencepath/{allocation} | [get reference path](#get-reference-path) | Get reference path. |
51+
| GET | /v1/file/refs/{allocation} | [get refs](#get-refs) | Get references. |
5152
| POST | /v1/connection/commit/{allocation} | [post commit](#post-commit) | Commit operation. |
5253
| POST | /v1/connection/create/{allocation} | [post connection](#post-connection) | Store connection in DB. |
5354
| POST | /v1/file/copy/{allocation} | [post copy](#post-copy) | Copy a file. |
@@ -353,7 +354,8 @@ Status: OK
353354
GET /v1/file/download/{allocation}
354355
```
355356

356-
Download Handler (downloadFile).
357+
Download Handler (downloadFile). The response is either a byte stream or a FileDownloadResponse, which contains the file data or the thumbnail data, and the merkle proof if the download is verified.
358+
This depends on the "X-Verify-Download" header. If the header is set to "true", the response is a FileDownloadResponse, otherwise it is a byte stream.
357359

358360
#### Parameters
359361

@@ -379,13 +381,13 @@ Download Handler (downloadFile).
379381
#### All responses
380382
| Code | Status | Description | Has headers | Schema |
381383
|------|--------|-------------|:-----------:|--------|
382-
| [200](#get-download-file-200) | OK | | []byte | | [schema](#get-download-file-200-schema) |
384+
| [200](#get-download-file-200) | OK | FileDownloadResponse | | [schema](#get-download-file-200-schema) |
383385
| [400](#get-download-file-400) | Bad Request | | | [schema](#get-download-file-400-schema) |
384386

385387
#### Responses
386388

387389

388-
##### <span id="get-download-file-200"></span> 200 - | []byte
390+
##### <span id="get-download-file-200"></span> 200 - FileDownloadResponse
389391
Status: OK
390392

391393
###### <span id="get-download-file-200-schema"></span> Schema
@@ -405,7 +407,7 @@ Status: Bad Request
405407
GET /v1/file/meta/{allocation}
406408
```
407409

408-
Retrieve file meta data from the blobber.
410+
Retrieve file meta data from the blobber. Retrieves a generic map of string keys and values.
409411

410412
#### Parameters
411413

@@ -698,7 +700,7 @@ Status: Internal Server Error
698700
### <span id="get-playlist"></span> Get playlist. (*GetPlaylist*)
699701

700702
```
701-
GET /v1/file/playlist/{allocation}
703+
GET /v1/playlist/latest/{allocation}
702704
```
703705

704706
Loads playlist from a given path in an allocation.
@@ -800,7 +802,7 @@ Status: Internal Server Error
800802
### <span id="get-recent-refs"></span> Get recent references. (*GetRecentRefs*)
801803

802804
```
803-
GET /v1/file/refs/{allocation}
805+
GET /v1/file/refs/recent/{allocation}
804806
```
805807

806808
Retrieve recent references added to an allocation, starting at a specific date, organized in a paginated table.
@@ -899,6 +901,64 @@ Status: Internal Server Error
899901

900902
###### <span id="get-reference-path-500-schema"></span> Schema
901903

904+
### <span id="get-refs"></span> Get references. (*GetRefs*)
905+
906+
```
907+
GET /v1/file/refs/{allocation}
908+
```
909+
910+
Retrieve references of all the decendents of a given path including itself, organized in a paginated table.
911+
912+
#### Parameters
913+
914+
| Name | Source | Type | Go type | Separator | Required | Default | Description |
915+
|------|--------|------|---------|-----------| :------: |---------|-------------|
916+
| allocation | `path` | string | `string` | || | allocation ID |
917+
| ALLOCATION-ID | `header` | string | `string` | || | The ID of the allocation in question. |
918+
| X-App-Client-ID | `header` | string | `string` | || | The ID/Wallet address of the client sending the request. |
919+
| X-App-Client-Key | `header` | string | `string` | || | The key of the client sending the request. |
920+
| X-App-Client-Signature | `header` | string | `string` | | | | Digital signature of the client used to verify the request if the X-Version is not "v2" |
921+
| X-App-Client-Signature-V2 | `header` | string | `string` | | | | Digital signature of the client used to verify the request if the X-Version is "v2" |
922+
| auth_token | `query` | string | `string` | | | | The auth ticket for the file to show meta data of if the client does not own it. Check File Sharing docs for more info. |
923+
| fileType | `query` | string | `string` | | | | Type of the references to list. Can be "f" for file or "d" for directory. Both will be retrieved if not provided. |
924+
| level | `query` | integer | `int64` | | | | Level of the references to list (number of parents of the reference). Can be "0" for root level or "1" for first level and so on. All levels will be retrieved if not provided. |
925+
| offsetDate | `query` | string | `string` | | | | Date of the file to start the listing from. Used in case the user needs to list refs updated at some period of time. |
926+
| offsetPath | `query` | string | `string` | | | | Path of the file to start the listing from. Used for pagination. |
927+
| pageLimit | `query` | integer | `int64` | | | | Number of records to show per page. Default is 20. |
928+
| path | `query` | string | `string` | | | | Path of the file needed to get reference path of. Required only if no "paths" are provided. |
929+
| path_hash | `query` | string | `string` | | | | Hash of the path of the file to be copied. Required only if `path` is not provided. |
930+
| refType | `query` | string | `string` | || | Can be "updated" (along with providing `updateDate` and `offsetDate`) to retrieve refs with updated_at date later than the provided date in both fields, or "regular" otherwise. |
931+
| updateDate | `query` | string | `string` | | | | Same as offsetDate but both should be provided. |
932+
933+
#### All responses
934+
| Code | Status | Description | Has headers | Schema |
935+
|------|--------|-------------|:-----------:|--------|
936+
| [200](#get-refs-200) | OK | RefResult | | [schema](#get-refs-200-schema) |
937+
| [400](#get-refs-400) | Bad Request | | | [schema](#get-refs-400-schema) |
938+
| [500](#get-refs-500) | Internal Server Error | | | [schema](#get-refs-500-schema) |
939+
940+
#### Responses
941+
942+
943+
##### <span id="get-refs-200"></span> 200 - RefResult
944+
Status: OK
945+
946+
###### <span id="get-refs-200-schema"></span> Schema
947+
948+
949+
950+
[RefResult](#ref-result)
951+
952+
##### <span id="get-refs-400"></span> 400
953+
Status: Bad Request
954+
955+
###### <span id="get-refs-400-schema"></span> Schema
956+
957+
##### <span id="get-refs-500"></span> 500
958+
Status: Internal Server Error
959+
960+
###### <span id="get-refs-500-schema"></span> Schema
961+
902962
### <span id="post-commit"></span> Commit operation. (*PostCommit*)
903963

904964
```
@@ -1359,7 +1419,7 @@ Status: Internal Server Error
13591419
POST /v1/marketplace/shareinfo/{allocation}
13601420
```
13611421

1362-
Handle share file requests from clients.
1422+
Handle share file requests from clients. Returns generic mapping.
13631423

13641424
#### Parameters
13651425

@@ -2051,7 +2111,6 @@ it can be used as a scan destination, similar to [NullString].
20512111
|------|------|---------|:--------:| ------- |-------------|---------|
20522112
| List | [][ReferencePath](#reference-path)| `[]*ReferencePath` | | | | |
20532113
| Meta | map of any | `map[string]interface{}` | | | | |
2054-
| Ref | [Ref](#ref)| `Ref` | | | | |
20552114

20562115

20572116

@@ -2068,7 +2127,6 @@ it can be used as a scan destination, similar to [NullString].
20682127
|------|------|---------|:--------:| ------- |-------------|---------|
20692128
| List | [][ReferencePath](#reference-path)| `[]*ReferencePath` | | | | |
20702129
| Meta | map of any | `map[string]interface{}` | | | | |
2071-
| Ref | [Ref](#ref)| `Ref` | | | | |
20722130
| Version | string| `string` | | | | |
20732131
| latest_write_marker | [WriteMarker](#write-marker)| `WriteMarker` | | | | |
20742132

0 commit comments

Comments
 (0)