Skip to content
This repository has been archived by the owner on Apr 29, 2020. It is now read-only.

Commit

Permalink
Added block and its subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLitt committed Jan 30, 2016
1 parent 849c065 commit 9982e58
Showing 1 changed file with 370 additions and 3 deletions.
373 changes: 370 additions & 3 deletions apiary.apib
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,379 @@ MerkleDAG.
## wantlist

# Group block
Manipulate raw IPFS blocks.

## get
+ Request No Methods

## put
#### curl

## stat
curl -i http://localhost:5001/api/v0/block

+ Body

```
curl -i http://localhost:5001/api/v0/block
```

+ Response 400

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:23:38 GMT
Transfer-Encoding: chunked
```

+ Attributes (Error)
- Message: "This command can't be called directly. Try one of its subcommands."
- Code: 1

+ Body

```
{
"Message": "This command can't be called directly. Try one of its subcommands.",
"Code": 1
}
```

## get [GET /block/get{?arg}]

Store data as a raw ipfs block.

+ Parameters
+ arg (Multihash, required) - hash of the block to be fetched

+ Request No Arguments

#### curl

curl -i http://localhost:5001/api/v0/block/stat

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat
```

+ Response 400

+ Headers

```
Date: Fri, 29 Jan 2016 21:46:01 GMT
Content-Length: 26
Content-Type: text/plain; charset=utf-8
```

+ Body

```
Argument 'key' is required
```

+ Request Invalid Argument

#### curl

curl -i http://localhost:5001/api/v0/block/stat?arg=

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat?arg=
```

+ Response 500

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:46:59 GMT
Transfer-Encoding: chunked
```

+ Attributes (Error)
- Message: "Not a valid hash"
- Code: 0

+ Body

```
{
"Message": "Not a valid hash",
"Code": 0
}
```

+ Request With Valid Argument

#### curl

curl -i http://localhost:5001/api/v0/block/stat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat?arg=QmT78zSuBmuS4z925WZfrqQ1qHaJ56DQaTfyMUF7F8ff5o
```

+ Response 200 (text/plain)

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: text/plain
Trailer: X-Stream-Error
Transfer-Encoding: chunked
X-Stream-Output: 1
Date: Fri, 29 Jan 2016 21:42:59 GMT
Transfer-Encoding: chunked
```

+ Body

```
hello world
```

## put [POST /block/put{?arg}]
Stores input as an IPFS block

ipfs block put is a plumbing command for storing raw ipfs blocks.

+ Parameters
+ arg (string, required) - The data to be stored as an IPFS block.

+ Request No Arguments

#### curl

curl -i http://localhost:5001/api/v0/block/put

+ Body

```
curl -i http://localhost:5001/api/v0/block/put
```

+ Response 400

+ Headers

```
Date: Fri, 29 Jan 2016 21:48:34 GMT
Content-Length: 32
Content-Type: text/plain; charset=utf-8
```

+ Body

```
File argument 'data' is required
```

+ Request Invalid Argument (multipart/form-data)

#### curl

curl -i -F "data=invalid" http://localhost:5001/api/v0/block/put

+ Body

```
curl -i -F "data=invalid" http://localhost:5001/api/v0/block/put
```

+ Response 500

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:59:43 GMT
Transfer-Encoding: chunked
```

+ Attributes (Error)
- Message: "mime: no media type"
- Code: 0

+ Body

```
{
"Message": "mime: no media type",
"Code": 0
}
```

+ Request Valid Argument (multipart/form-data)

#### curl

curl -i -F "data=@test" http://localhost:5001/api/v0/block/put

+ Body

```
curl -i -F "data=@test" http://localhost:5001/api/v0/block/put
```

+ Response 200

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:56:18 GMT
Transfer-Encoding: chunked
```

+ Attributes (object)
- Key: "QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp" (Multihash)
- Size: 12 (number)

+ Body

```
{
"Key": "QmZjTnYw2TFhn9Nn7tjmPSoTBoY7YRkwPzwSrSbabY24Kp",
"Size": 12
}
```

## stat [GET /block/stat?{arg}]
Retrieve information on a raw ipfs block.

+ Parameters
+ arg (Multihash, required) - Hash of the block to retrieve stats on.

+ Request No Arguments

#### curl

curl -i http://localhost:5001/api/v0/block/stat

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat
```

+ Response 400

+ Headers

```
Date: Fri, 29 Jan 2016 21:25:34 GMT
Content-Length: 26
Content-Type: text/plain; charset=utf-8
```

+ Body

```
Argument 'key' is required
```

+ Request Invalid Argument

#### curl

curl -i http://localhost:5001/api/v0/block/stat/arg=

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat/arg=
```

+ Response 400

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:27:22 GMT
Transfer-Encoding: chunked
```

+ Attributes (Error)
- Message: "Not a valid hash"
- Code: 0

+ Body

```
{
"Message": "Not a valid hash",
"Code": 0
}
```

+ Request Valid Argument

#### curl

curl -i http://localhost:5001/api/v0/block/stat?arg=QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ

+ Body

```
curl -i http://localhost:5001/api/v0/block/stat?arg=QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ
```

+ Response 200

+ Headers

```
Access-Control-Allow-Headers: X-Stream-Ouptut, X-Chunked-Output
Access-Control-Expose-Headers: X-Stream-Ouptut, X-Chunked-Output
Content-Type: application/json
Trailer: X-Stream-Error
Transfer-Encoding: chunked
Date: Fri, 29 Jan 2016 21:40:38 GMT
Transfer-Encoding: chunked
```

+ Attributes (object)
+ Key (Multihash)
+ Size (number) - the size of the block in bytes

+ Body

```
{
"Key": "QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ",
"Size": 55
}
```

# Group bootstrap

Expand Down

0 comments on commit 9982e58

Please sign in to comment.