Skip to content

Commit 77a1b76

Browse files
authored
Merge pull request #121 from graphsense/fix/ql-form
Expose include_sub_tx_identifiers in search endpoint
2 parents 8a07173 + 50e11b7 commit 77a1b76

File tree

6 files changed

+51
-6
lines changed

6 files changed

+51
-6
lines changed

clients/python/docs/GeneralApi.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ with graphsense.ApiClient(configuration) as api_client:
115115
q = "foo" # str | It can be (the beginning of) an address, a transaction or a label
116116
currency = "btc" # str | The cryptocurrency (e.g., btc) (optional)
117117
limit = 10 # int | Maximum number of search results (optional) if omitted the server will use the default value of 10
118+
include_sub_tx_identifiers = True # bool | Whether to include sub-transaction identifiers (optional) if omitted the server will use the default value of False
118119

119120
# example passing only required values which don't have defaults set
120121
try:
@@ -128,7 +129,7 @@ with graphsense.ApiClient(configuration) as api_client:
128129
# and optional values
129130
try:
130131
# Returns matching addresses, transactions and labels
131-
api_response = api_instance.search(q, currency=currency, limit=limit)
132+
api_response = api_instance.search(q, currency=currency, limit=limit, include_sub_tx_identifiers=include_sub_tx_identifiers)
132133
pprint(api_response)
133134
except graphsense.ApiException as e:
134135
print("Exception when calling GeneralApi->search: %s\n" % e)
@@ -142,6 +143,7 @@ Name | Type | Description | Notes
142143
**q** | **str**| It can be (the beginning of) an address, a transaction or a label |
143144
**currency** | **str**| The cryptocurrency (e.g., btc) | [optional]
144145
**limit** | **int**| Maximum number of search results | [optional] if omitted the server will use the default value of 10
146+
**include_sub_tx_identifiers** | **bool**| Whether to include sub-transaction identifiers | [optional] if omitted the server will use the default value of False
145147
**_preload_content** | **bool** | If False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. | [optional] default is True.
146148
**async_req** | **bool** | Execute request asynchronously | [optional] default is False.
147149

clients/python/graphsense/api/general_api.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def __search(
160160
Keyword Args:
161161
currency (str): The cryptocurrency (e.g., btc). [optional]
162162
limit (int): Maximum number of search results. [optional] if omitted the server will use the default value of 10
163+
include_sub_tx_identifiers (bool): Whether to include sub-transaction identifiers. [optional] if omitted the server will use the default value of False
163164
_return_http_data_only (bool): response data without head status
164165
code and headers. Default is True.
165166
_preload_content (bool): if False, the urllib3.HTTPResponse object
@@ -224,6 +225,7 @@ def __search(
224225
'q',
225226
'currency',
226227
'limit',
228+
'include_sub_tx_identifiers',
227229
],
228230
'required': [
229231
'q',
@@ -257,16 +259,20 @@ def __search(
257259
(str,),
258260
'limit':
259261
(int,),
262+
'include_sub_tx_identifiers':
263+
(bool,),
260264
},
261265
'attribute_map': {
262266
'q': 'q',
263267
'currency': 'currency',
264268
'limit': 'limit',
269+
'include_sub_tx_identifiers': 'include_sub_tx_identifiers',
265270
},
266271
'location_map': {
267272
'q': 'query',
268273
'currency': 'query',
269274
'limit': 'query',
275+
'include_sub_tx_identifiers': 'query',
270276
},
271277
'collection_format_map': {
272278
}

gsrest/service/general_service.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@ async def search_by_currency(request, currency, q, limit=10):
2626
return pydantic_search_result_by_currency_to_openapi(pydantic_result)
2727

2828

29-
async def search(request, q, currency=None, limit=10):
29+
async def search(request, q, currency=None, limit=10, include_sub_tx_identifiers=False):
3030
services = get_service_container(request)
3131
tagstore_groups = get_tagstore_access_groups(request)
3232

3333
pydantic_result = await services.general_service.search(
34-
q, tagstore_groups, currency, limit, include_sub_tx_identifiers=False
34+
q,
35+
tagstore_groups,
36+
currency,
37+
limit,
38+
include_sub_tx_identifiers=include_sub_tx_identifiers,
3539
)
3640

3741
return pydantic_search_result_to_openapi(pydantic_result)

openapi_server/controllers/general_controller.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ async def get_statistics(request: web.Request, ) -> web.Response:
9292
raise web.HTTPInternalServerError()
9393

9494

95-
async def search(request: web.Request, q, currency=None, limit=None) -> web.Response:
95+
async def search(request: web.Request, q, currency=None, limit=None, include_sub_tx_identifiers=None) -> web.Response:
9696
"""Returns matching addresses, transactions and labels
9797
9898
@@ -103,6 +103,8 @@ async def search(request: web.Request, q, currency=None, limit=None) -> web.Resp
103103
:type currency: str
104104
:param limit: Maximum number of search results
105105
:type limit: int
106+
:param include_sub_tx_identifiers: Whether to include sub-transaction identifiers
107+
:type include_sub_tx_identifiers: bool
106108
107109
"""
108110

@@ -127,11 +129,11 @@ async def search(request: web.Request, q, currency=None, limit=None) -> web.Resp
127129
request.app['request_config']['show_private_tags'] = show_private_tags
128130

129131
try:
130-
if 'currency' in ['','q','currency','limit']:
132+
if 'currency' in ['','q','currency','limit','include_sub_tx_identifiers']:
131133
if currency is not None:
132134
currency = currency.lower()
133135
result = service.search(request
134-
,q=q,currency=currency,limit=limit)
136+
,q=q,currency=currency,limit=limit,include_sub_tx_identifiers=include_sub_tx_identifiers)
135137
result = await result
136138

137139
for plugin in request.app['plugins']:

openapi_server/openapi/openapi.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ paths:
4545
maximum: 100
4646
type: integer
4747
style: form
48+
- description: Whether to include sub-transaction identifiers
49+
example: true
50+
explode: true
51+
in: query
52+
name: include_sub_tx_identifiers
53+
required: false
54+
schema:
55+
default: false
56+
type: boolean
57+
style: form
4858
responses:
4959
"200":
5060
content:
@@ -3167,6 +3177,17 @@ components:
31673177
maximum: 100
31683178
type: integer
31693179
style: form
3180+
include_sub_tx_identifiers:
3181+
description: Whether to include sub-transaction identifiers
3182+
example: true
3183+
explode: true
3184+
in: query
3185+
name: include_sub_tx_identifiers
3186+
required: false
3187+
schema:
3188+
default: false
3189+
type: boolean
3190+
style: form
31703191
operation:
31713192
description: The operation to execute in bulk
31723193
example: get_block

openapi_spec/graphsense.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ paths:
2929
- $ref: '#/components/parameters/currency_query'
3030
- $ref: '#/components/parameters/search_query'
3131
- $ref: '#/components/parameters/limit'
32+
- $ref: '#/components/parameters/include_sub_tx_identifiers'
3233
responses:
3334
"200":
3435
description: OK
@@ -1205,6 +1206,15 @@ components:
12051206
maximum: 100
12061207
description: Maximum number of search results
12071208
example: 10
1209+
include_sub_tx_identifiers:
1210+
in: query
1211+
name: include_sub_tx_identifiers
1212+
required: false
1213+
schema:
1214+
type: boolean
1215+
default: false
1216+
description: Whether to include sub-transaction identifiers
1217+
example: true
12081218
operation:
12091219
in: path
12101220
name: operation

0 commit comments

Comments
 (0)