Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Rename AQL sample for accuracy (#6)
Browse files Browse the repository at this point in the history
* Rename AQL sample for accuracy

AQL cursors are not used in this sample.

* Update API parameter calls
  • Loading branch information
jthomperoo authored and asmith-IBM committed Jan 18, 2019
1 parent 5d3b460 commit 18a928f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<html>

<head>
<title>Ariel Cursor App</title>
<title>Ariel App</title>
<script src='./static/qjslib/qappfw.js'></script>
</head>

Expand Down Expand Up @@ -51,31 +51,31 @@ <h3>Start Search</h3>
<h3>Search Info</h3>
<input id='info_input' type='text' placeholder='Query'>
<br>
<input type='submit' value='Submit' onclick='request("info_input", "search_info?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("info_input", "search_info?search_id=")'>
<h3>Search Progress</h3>
<input id='progress_input' type='text' placeholder='Cursor ID'>
<input id='progress_input' type='text' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("progress_input", "progress?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("progress_input", "progress?search_id=")'>
<h3>Search Results</h3>
<input id='results_input' type='text' placeholder='Cursor ID'>
<input id='results_input' type='text' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("results_input", "results?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("results_input", "results?search_id=")'>
<h3>Delete Search</h3>
<input id='delete_input' type='text' placeholder='Cursor ID'>
<input id='delete_input' type='text' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("delete_input", "delete?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("delete_input", "delete?search_id=")'>
<h3>Cancel Search</h3>
<input id='cancel_input' type='text' placeholder='Cursor ID'>
<input id='cancel_input' type='text' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("cancel_input", "cancel?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("cancel_input", "cancel?search_id=")'>
<h3>Poll Search until Result</h3>
<input id='poll_input' type='text' name='query' placeholder='Cursor ID'>
<input id='poll_input' type='text' name='query' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("poll_input", "poll?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("poll_input", "poll?search_id=")'>
<h3>Save Search Results</h3>
<input id='save_input' type='text' name='query' placeholder='Cursor ID'>
<input id='save_input' type='text' name='query' placeholder='Search ID'>
<br>
<input type='submit' value='Submit' onclick='request("save_input", "save_results?cursor_id=")'>
<input type='submit' value='Submit' onclick='request("save_input", "save_results?search_id=")'>
<h3>List Searches</h3>
<input type='submit' value='Submit' onclick='request("", "searches")'>
<h3>Response</h3>
Expand Down
94 changes: 47 additions & 47 deletions template_ariel_cursor/app/views.py → template_ariel/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ def index():
@app.route('/delete')
def delete():
"""
Delete an Ariel cursor, removing it's results
Delete an Ariel search, removing it's results
"""
# Get the cursor ID from the request to this endpoint
# /delete?cursor_id=CURSOR_ID
cursor_id = request.args.get('cursor_id')
# Get the search ID from the request to this endpoint
# /delete?search_id=SEARCH_ID
search_id = request.args.get('search_id')
# Make an HTTP DELETE request to the Ariel searches endpoint specifying
# a cursor to delete
# /api/ariel/searches/CURSOR_ID
# a search to delete
# /api/ariel/searches/SEARCH_ID
response = qpylib.REST(
'DELETE',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
)
if response.ok:
Expand All @@ -69,19 +69,19 @@ def delete():
@app.route('/cancel')
def cancel():
"""
Mark an Ariel cursor as canceled, stopping it from processing further but retaining it's
Mark an Ariel search as canceled, stopping it from processing further but retaining it's
results
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# Get search ID
search_id = request.args.get('search_id')
# Parameter of ?status=CANCELED
params = {'status': 'CANCELED'}
# Make an HTTP POST request to the Ariel searches endpoint specifying
# a cursor to update the status of to 'CANCELED'
# /api/ariel/searches/CURSOR_ID?status=CANCELED
# a search to update the status of to 'CANCELED'
# /api/ariel/searches/SEARCH_ID?status=CANCELED
response = qpylib.REST(
'POST',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS,
params=params
)
Expand All @@ -95,18 +95,18 @@ def cancel():
@app.route('/save_results')
def save_results():
"""
Update an Ariel cursor to ensure that it's results are saved
Update an Ariel search to ensure that it's results are saved
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# Get search ID
search_id = request.args.get('search_id')
# Parameter of ?save_results=true
params = {'save_results': 'true'}
# Make an HTTP POST request to the Ariel searches endpoint specifying
# a cursor to update to have the results of of it's search saved
# /api/ariel/searches/CURSOR_ID?save_results=true
# a search to update to have the results of of it's search saved
# /api/ariel/searches/SEARCH_ID?save_results=true
response = qpylib.REST(
'POST',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS,
params=params
)
Expand All @@ -120,22 +120,22 @@ def save_results():
@app.route('/poll')
def poll():
"""
Repeatedly call the Ariel API to check if a cursor has finished processing
Repeatedly call the Ariel API to check if a search has finished processing
if it has, retrieve and return the results
Poll only as long as the timeout defined
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# Get search ID
search_id = request.args.get('search_id')
# Start time that the polling began at
init_time = time.time()
while init_time + TIMEOUT_MILLISECONDS > time.time():
# While within the timeout
# Poll with an HTTP GET request to the Ariel searches endpoint specifying
# a cursor to retrieve the information of
# /api/ariel/searches/CURSOR_ID
# a search to retrieve the information of
# /api/ariel/searches/SEARCH_ID
response = qpylib.REST(
'GET',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
).json()
if 'http_response' in response:
Expand All @@ -145,11 +145,11 @@ def poll():
if response['status'] == 'COMPLETED':
# If the status of the query is COMPLETED, the results can now be retrieved
# Make an HTTP GET request to the Ariel searches endpoint specifying
# a cursor to retrieve the results of
# /api/ariel/searches/CURSOR_ID/results
# a search to retrieve the results of
# /api/ariel/searches/SEARCH_ID/results
response = qpylib.REST(
'GET',
'{0}/{1}/results'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}/results'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
).json()
# Return the results
Expand All @@ -163,15 +163,15 @@ def poll():
@app.route('/progress')
def progress():
"""
Gets information about a cursor and returns details on the cursor status and progress
Gets information about a search and returns details on the search status and progress
of execution
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# HTTP GET to /api/ariel/searches/CURSOR_ID
# Get search ID
search_id = request.args.get('search_id')
# HTTP GET to /api/ariel/searches/SEARCH_ID
response = qpylib.REST(
'GET',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
).json()
if 'http_response' in response:
Expand All @@ -191,14 +191,14 @@ def progress():
@app.route('/results')
def results():
"""
Retrieves the results of a cursor
Retrieves the results of a search
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# HTTP GET to /api/ariel/searches/CURSOR_ID/results
# Get search ID
search_id = request.args.get('search_id')
# HTTP GET to /api/ariel/searches/SEARCH_ID/results
response = qpylib.REST(
'GET',
'{0}/{1}/results'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}/results'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
).json()
# Return the response
Expand All @@ -208,10 +208,10 @@ def results():
@app.route('/search')
def search():
"""
Creates a new cursor with the query provided, returns a cursor ID to allow further
cursor interaction, such as retrieving results
Creates a new search with the query provided, returns a search ID to allow further
search interaction, such as retrieving results
"""
# Get cursor ID
# Get search ID
query = request.args.get('query')
# Parameter of ?query_expression=QUERY
params = {'query_expression': query}
Expand All @@ -229,7 +229,7 @@ def search():
@app.route('/searches')
def searches():
"""
Lists existing cursors on the Ariel DB, including ones that have completed execution
Lists existing searchs on the Ariel DB, including ones that have completed execution
"""
# HTTP GET to /api/ariel/searches
response = qpylib.REST(
Expand All @@ -244,14 +244,14 @@ def searches():
@app.route('/search_info')
def search_info():
"""
Gets information about a cursor, such as status, progress and other meta data
Gets information about a search, such as status, progress and other meta data
"""
# Get cursor ID
cursor_id = request.args.get('cursor_id')
# HTTP GET to /api/ariel/searches/CURSOR_ID
# Get search ID
search_id = request.args.get('search_id')
# HTTP GET to /api/ariel/searches/SEARCH_ID
response = qpylib.REST(
'GET',
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, cursor_id),
'{0}/{1}'.format(ARIEL_SEARCHES_ENDPOINT, search_id),
headers=JSON_HEADERS
).json()
# Return the response
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"version": "1.0",
"name": "Ariel Cursor Sample",
"description": "Application to query the Ariel API and show use of cursors",
"name": "Ariel Sample",
"description": "Application to query the Ariel API",
"copyright": "Licensed Materials - Property of IBM 5725I71-CC011829 (C) Copyright IBM Corp. 2017, 2018. All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.",
"uuid": "fb8ebc63-3ef7-409e-9f10-b45af09296e8",
"areas": [
{
"url": "index",
"text": "Ariel Cursor Sample",
"text": "Ariel Sample",
"required_capabilities": [
"ADMIN"
],
"id": "QArielCursorSample",
"description": "Ariel Cursor Sample"
"id": "QArielSample",
"description": "Ariel Sample"
}
]
}

0 comments on commit 18a928f

Please sign in to comment.