Skip to content

Commit 94f5b71

Browse files
committed
add docs for share post endpoint
1 parent cab521c commit 94f5b71

File tree

5 files changed

+152
-3
lines changed

5 files changed

+152
-3
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,4 +192,5 @@ endif
192192
.PHONY: markdown-docs
193193
markdown-docs:
194194
swagger generate spec -o ./swagger.yaml -w ./code/go/0chain.net -m
195+
sed -i '' "s/in\:\ form/in\:\ formData/g" ./swagger.yaml
195196
swagger generate markdown -f ./swagger.yaml --output=swagger.md

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,61 @@ func RevokeShare(ctx context.Context, r *http.Request) (interface{}, error) {
847847
return resp, nil
848848
}
849849

850+
// swagger:route POST /v1/marketplace/shareinfo/{allocation} shareinfo
851+
// shareinfo is the handler to respond to share file requests from clients
852+
//
853+
// parameters:
854+
// +name: allocation
855+
// description: TxHash of the allocation in question.
856+
// in: path
857+
// required: true
858+
// type: string
859+
// +name: X-App-Client-ID
860+
// description: The ID/Wallet address of the client sending the request.
861+
// in: header
862+
// type: string
863+
// required: true
864+
// +name: X-App-Client-Key
865+
// description: The key of the client sending the request.
866+
// in: header
867+
// type: string
868+
// required: true
869+
// +name: ALLOCATION-ID
870+
// description: The ID of the allocation in question.
871+
// in: header
872+
// type: string
873+
// required: true
874+
// +name: X-App-Client-Signature
875+
// description: Digital signature of the client used to verify the request.
876+
// in: header
877+
// type: string
878+
// required: true
879+
// +name: X-App-Client-Signature-V2
880+
// description: Digital signature of the client used to verify the request. Overrides X-App-Client-Signature if provided.
881+
// in: header
882+
// type: string
883+
// +name: encryption_public_key
884+
// description: Public key of the referee client in case of private sharing. Used for proxy re-encryption.
885+
// in: form
886+
// type: string
887+
// +name: available_after
888+
// description: Time after which the file will be accessible for sharing.
889+
// in: form
890+
// type: string
891+
// +name: auth_ticket
892+
// description: Body of the auth ticket used to verify the file access. Follows the structure of [`AuthTicket`](#auth-ticket)
893+
// in: form
894+
// type: string
895+
// required: true
896+
//
897+
// responses:
898+
//
899+
// 200:
900+
// description: "Generic map response `map[string]interface{}`"
901+
// examples:
902+
// {"message": "Share info added successfully"}
903+
// 400:
904+
850905
func InsertShare(ctx context.Context, r *http.Request) (interface{}, error) {
851906

852907
ctx = setupHandlerContext(ctx, r)

code/go/0chain.net/blobbercore/readmarker/authticket.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const (
1313
NinetyDays = common.Timestamp(90 * 24 * time.Hour)
1414
)
1515

16-
// swagger:model AuthTicke
16+
// swagger:model AuthTicket
1717
type AuthTicket struct {
1818
ClientID string `json:"client_id"`
1919
OwnerID string `json:"owner_id"`

swagger.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Documentation of the blobber API.
4141
| GET | /v1/file/objecttree/{allocation} | [referencepath](#referencepath) | |
4242
| GET | /v1/file/refs/{allocation} | [refshandler](#refshandler) | |
4343
| GET | /v1/file/rename/{allocation} | [renameallocation](#renameallocation) | |
44+
| POST | /v1/marketplace/shareinfo/{allocation} | [shareinfo](#shareinfo) | |
4445

4546

4647

@@ -612,6 +613,47 @@ Status: Internal Server Error
612613

613614
###### <span id="renameallocation-500-schema"></span> Schema
614615

616+
### <span id="shareinfo"></span> shareinfo (*shareinfo*)
617+
618+
```
619+
POST /v1/marketplace/shareinfo/{allocation}
620+
```
621+
622+
shareinfo is the handler to respond to share file requests from clients
623+
624+
#### Parameters
625+
626+
| Name | Source | Type | Go type | Separator | Required | Default | Description |
627+
|------|--------|------|---------|-----------| :------: |---------|-------------|
628+
| allocation | `path` | string | `string` | || | TxHash of the allocation in question. |
629+
| ALLOCATION-ID | `header` | string | `string` | || | The ID of the allocation in question. |
630+
| X-App-Client-ID | `header` | string | `string` | || | The ID/Wallet address of the client sending the request. |
631+
| X-App-Client-Key | `header` | string | `string` | || | The key of the client sending the request. |
632+
| X-App-Client-Signature | `header` | string | `string` | || | Digital signature of the client used to verify the request. |
633+
| X-App-Client-Signature-V2 | `header` | string | `string` | | | | Digital signature of the client used to verify the request. Overrides X-App-Client-Signature if provided. |
634+
| auth_ticket | `formData` | string | `string` | || | Body of the auth ticket used to verify the file access. Follows the structure of [`AuthTicket`](#auth-ticket) |
635+
| available_after | `formData` | string | `string` | | | | Time after which the file will be accessible for sharing. |
636+
| encryption_public_key | `formData` | string | `string` | | | | Public key of the referee client in case of private sharing. Used for proxy re-encryption. |
637+
638+
#### All responses
639+
| Code | Status | Description | Has headers | Schema |
640+
|------|--------|-------------|:-----------:|--------|
641+
| [200](#shareinfo-200) | OK | | | [schema](#shareinfo-200-schema) |
642+
| [400](#shareinfo-400) | Bad Request | | | [schema](#shareinfo-400-schema) |
643+
644+
#### Responses
645+
646+
647+
##### <span id="shareinfo-200"></span> 200
648+
Status: OK
649+
650+
###### <span id="shareinfo-200-schema"></span> Schema
651+
652+
##### <span id="shareinfo-400"></span> 400
653+
Status: Bad Request
654+
655+
###### <span id="shareinfo-400-schema"></span> Schema
656+
615657
## Models
616658

617659
### <span id="auth-ticket"></span> AuthTicket

swagger.yaml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
basePath: /
22
definitions:
3-
AuthTicke:
3+
AuthTicket:
44
properties:
55
actual_file_hash:
66
type: string
@@ -37,7 +37,6 @@ definitions:
3737
timestamp:
3838
$ref: '#/definitions/Timestamp'
3939
type: object
40-
x-go-name: AuthTicket
4140
x-go-package: github.com/0chain/blobber/code/go/0chain.net/blobbercore/readmarker
4241
CommitResult:
4342
properties:
@@ -847,6 +846,58 @@ paths:
847846
description: ""
848847
"500":
849848
description: ""
849+
/v1/marketplace/shareinfo/{allocation}:
850+
post:
851+
description: shareinfo is the handler to respond to share file requests from clients
852+
operationId: shareinfo
853+
parameters:
854+
- description: TxHash of the allocation in question.
855+
in: path
856+
name: allocation
857+
required: true
858+
type: string
859+
- description: The ID/Wallet address of the client sending the request.
860+
in: header
861+
name: X-App-Client-ID
862+
required: true
863+
type: string
864+
- description: The key of the client sending the request.
865+
in: header
866+
name: X-App-Client-Key
867+
required: true
868+
type: string
869+
- description: The ID of the allocation in question.
870+
in: header
871+
name: ALLOCATION-ID
872+
required: true
873+
type: string
874+
- description: Digital signature of the client used to verify the request.
875+
in: header
876+
name: X-App-Client-Signature
877+
required: true
878+
type: string
879+
- description: Digital signature of the client used to verify the request. Overrides X-App-Client-Signature if provided.
880+
in: header
881+
name: X-App-Client-Signature-V2
882+
type: string
883+
- description: Public key of the referee client in case of private sharing. Used for proxy re-encryption.
884+
in: formData
885+
name: encryption_public_key
886+
type: string
887+
- description: Time after which the file will be accessible for sharing.
888+
in: formData
889+
name: available_after
890+
type: string
891+
- description: Body of the auth ticket used to verify the file access. Follows the structure of [`AuthTicket`](#auth-ticket)
892+
in: formData
893+
name: auth_ticket
894+
required: true
895+
type: string
896+
responses:
897+
"200":
898+
description: ""
899+
"400":
900+
description: ""
850901
schemes:
851902
- https
852903
swagger: "2.0"

0 commit comments

Comments
 (0)