update GET transactions?unfulfilled

- owners_after -> public_keys
- examples -> samples
This commit is contained in:
diminator 2016-12-26 17:23:22 +01:00 committed by tim
parent a8f8c7f4a9
commit d09a93f1a7
2 changed files with 47 additions and 76 deletions

View File

@ -9,6 +9,38 @@ from bigchaindb.common.transaction import Transaction
TPLS = {} TPLS = {}
TPLS['get-tx-id-request'] = """\
GET /transactions/%(txid)s HTTP/1.1
Host: example.com
"""
TPLS['get-tx-id-response'] = """\
HTTP/1.1 200 OK
Content-Type: application/json
X-BigchainDB-Timestamp: 1482766245
%(tx)s
"""
TPLS['get-tx-unfulfilled-request'] = """\
GET /transactions?fulfilled=false&public_keys=%(public_keys)s HTTP/1.1
Host: example.com
"""
TPLS['get-tx-unfulfilled-response'] = """\
HTTP/1.1 200 OK
Content-Type: application/json
[%(tx)s]
"""
TPLS['post-tx-request'] = """\ TPLS['post-tx-request'] = """\
POST /transactions/ HTTP/1.1 POST /transactions/ HTTP/1.1
Host: example.com Host: example.com
@ -32,7 +64,6 @@ Host: example.com
""" """
TPLS['get-tx-status-response'] = """\ TPLS['get-tx-status-response'] = """\
HTTP/1.1 200 OK HTTP/1.1 200 OK
Content-Type: application/json Content-Type: application/json
@ -43,20 +74,6 @@ Content-Type: application/json
""" """
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
X-BigchainDB-Timestamp: 1482766245
%(tx)s
"""
def main(): def main():
@ -75,7 +92,9 @@ def main():
for name, tpl in TPLS.items(): for name, tpl in TPLS.items():
path = os.path.join(base_path, name + '.http') path = os.path.join(base_path, name + '.http')
code = tpl % {'tx': tx_json, 'txid': tx.id} code = tpl % {'tx': tx_json,
'txid': tx.id,
'public_keys': tx.outputs[0].public_keys[0]}
with open(path, 'w') as handle: with open(path, 'w') as handle:
handle.write(code) handle.write(code)

View File

@ -54,12 +54,12 @@ Transactions
**Example request**: **Example request**:
.. literalinclude:: samples/get-tx-request.http .. literalinclude:: samples/get-tx-id-request.http
:language: http :language: http
**Example response**: **Example response**:
.. literalinclude:: samples/get-tx-response.http .. literalinclude:: samples/get-tx-id-response.http
:language: http :language: http
:resheader X-BigchainDB-Timestamp: A unix timestamp describing when a transaction was included into a valid block. The timestamp provided is taken from the block the transaction was included in. :resheader X-BigchainDB-Timestamp: A unix timestamp describing when a transaction was included into a valid block. The timestamp provided is taken from the block the transaction was included in.
@ -79,7 +79,7 @@ Transactions
queried correctly. Some of them include retrieving a list of transactions queried correctly. Some of them include retrieving a list of transactions
that include: that include:
* `Unfulfilled conditions <#get--transactions?fulfilled=false&owners_after=owners_after>`_ * `Unfulfilled conditions <#get--transactions?fulfilled=false&public_keys=public_keys>`_
* `A specific asset <#get--transactions?operation=CREATE|TRANSFER&asset_id=asset_id>`_ * `A specific asset <#get--transactions?operation=CREATE|TRANSFER&asset_id=asset_id>`_
* `Specific metadata <#get--transactions?&metadata_id=metadata_id>`_ * `Specific metadata <#get--transactions?&metadata_id=metadata_id>`_
@ -89,7 +89,7 @@ Transactions
:query boolean fulfilled: A flag to indicate if transaction's with fulfilled conditions should be returned. :query boolean fulfilled: A flag to indicate if transaction's with fulfilled conditions should be returned.
:query string owners_after: Public key able to validly spend an output of a transaction, assuming the user also has the corresponding private key. :query string public_keys: Public key able to validly spend an output of a transaction, assuming the user also has the corresponding private key.
:query string operation: One of the three supported operations of a transaction: ``GENESIS``, ``CREATE``, ``TRANSFER``. :query string operation: One of the three supported operations of a transaction: ``GENESIS``, ``CREATE``, ``TRANSFER``.
@ -100,12 +100,12 @@ Transactions
:statuscode 404: BigchainDB does not expose this endpoint. :statuscode 404: BigchainDB does not expose this endpoint.
.. http:get:: /transactions?fulfilled=false&owners_after={owners_after} .. http:get:: /transactions?fulfilled=false&public_keys={public_keys}
Get a list of transactions with unfulfilled conditions. Get a list of transactions with unfulfilled conditions.
If the querystring ``fulfilled`` is set to ``false`` and all conditions for If the querystring ``fulfilled`` is set to ``false`` and all conditions for
``owners_after`` happen to be fulfilled already, this endpoint will return ``public_keys`` happen to be fulfilled already, this endpoint will return
an empty list. an empty list.
This endpoint returns conditions only if the transaction they're in are This endpoint returns conditions only if the transaction they're in are
@ -113,67 +113,19 @@ Transactions
:query boolean fulfilled: A flag to indicate if transaction's with fulfilled conditions should be returned. :query boolean fulfilled: A flag to indicate if transaction's with fulfilled conditions should be returned.
:query string owners_after: Public key able to validly spend an output of a transaction, assuming the user also has the corresponding private key. :query string public_keys: Public key able to validly spend an output of a transaction, assuming the user also has the corresponding private key.
**Example request**: **Example request**:
.. sourcecode:: http
GET /transactions?fulfilled=false&owners_after=1AAAbbb...ccc HTTP/1.1 .. literalinclude:: samples/get-tx-unfulfilled-request.http
Host: example.com :language: http
**Example response**: **Example response**:
.. sourcecode:: http .. literalinclude:: samples/get-tx-unfulfilled-response.http
:language: http
HTTP/1.1 200 OK
Content-Type: application/json
[{
"transaction": {
"conditions": [
{
"cid": 0,
"condition": {
"uri": "cc:4:20:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkk:96",
"details": {
"signature": null,
"type": "fulfillment",
"type_id": 4,
"bitmask": 32,
"public_key": "1AAAbbb...ccc"
}
},
"amount": 1,
"owners_after": [
"1AAAbbb...ccc"
]
}
],
"operation": "CREATE",
"asset": {
"divisible": false,
"updatable": false,
"data": null,
"id": "aebeab22-e672-4d3b-a187-bde5fda6533d",
"refillable": false
},
"metadata": null,
"timestamp": "1477578978",
"fulfillments": [
{
"fid": 0,
"input": null,
"fulfillment": "cf:4:GG-pi3CeIlySZhQoJVBh9O23PzrOuhnYI7OHqIbHjkn2VnQaEWvecO1x82Qr2Va_JjFywLKIOEV1Ob9Ofkeln2K89ny2mB-s7RLNvYAVzWNiQnp18_nQEUsvwACEXTYJ",
"owners_before": [
"2ePYHfV3yS3xTxF9EE3Xjo8zPwq2RmLPFAJGQqQKc3j6"
]
}
]
},
"id": "2d431073e1477f3073a4693ac7ff9be5634751de1b8abaa1f4e19548ef0b4b0e",
"version": 1
}]
:resheader Content-Type: ``application/json`` :resheader Content-Type: ``application/json``