Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
make html
runs generation scripts for documentation, generates http…
… server examples
- Loading branch information
Showing
7 changed files
with
121 additions
and
473 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
""" Script to build http examples for http server api docs """ | ||
|
||
import json | ||
import os | ||
import os.path | ||
|
||
from bigchaindb.common.transaction import Asset, Transaction | ||
|
||
|
||
TPLS = {} | ||
|
||
TPLS['post-tx-request'] = """\ | ||
POST /transactions/ HTTP/1.1 | ||
Host: example.com | ||
Content-Type: application/json | ||
%(tx)s | ||
""" | ||
|
||
|
||
TPLS['post-tx-response'] = """\ | ||
HTTP/1.1 201 Created | ||
Content-Type: application/json | ||
%(tx)s | ||
""" | ||
|
||
|
||
TPLS['get-tx-status-request'] = """\ | ||
GET /transactions/%(txid)s/status HTTP/1.1 | ||
Host: example.com | ||
""" | ||
|
||
|
||
TPLS['get-tx-status-response'] = """\ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
{ | ||
"status": "valid" | ||
} | ||
""" | ||
|
||
|
||
TPLS['get-tx-request'] = """\ | ||
GET /transactions/%(txid)s HTTP/1.1 | ||
Host: example.com | ||
""" | ||
|
||
|
||
TPLS['get-tx-response'] = """\ | ||
HTTP/1.1 200 OK | ||
Content-Type: application/json | ||
%(tx)s | ||
""" | ||
|
||
|
||
def main(): | ||
""" Main function """ | ||
pub = '9RaWxppkP9UyYWA7NJb5FcgkzfJNPfvPX3FCNw2T5Pwb' | ||
asset = Asset(None, 'e6969f87-4fc9-4467-b62a-f0dfa1c85002') | ||
tx = Transaction.create([pub], [([pub], 1)], asset=asset) | ||
tx_json = json.dumps(tx.to_dict(), indent=2, sort_keys=True) | ||
|
||
base_path = os.path.join(os.path.dirname(__file__), | ||
'source/drivers-clients/samples') | ||
|
||
if not os.path.exists(base_path): | ||
os.makedirs(base_path) | ||
|
||
for name, tpl in TPLS.items(): | ||
path = os.path.join(base_path, name + '.http') | ||
code = tpl % {'tx': tx_json, 'txid': tx.id} | ||
with open(path, 'w') as handle: | ||
handle.write(code) | ||
|
||
|
||
def setup(*_): | ||
""" Fool sphinx into think it's an extension muahaha """ | ||
main() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.