From 18a928f5e78d9039e11179d5df8f295ae37fd08e Mon Sep 17 00:00:00 2001 From: jthomperoo Date: Fri, 18 Jan 2019 11:48:20 +0000 Subject: [PATCH] Rename AQL sample for accuracy (#6) * Rename AQL sample for accuracy AQL cursors are not used in this sample. * Update API parameter calls --- .../app/templates/index.html | 28 +++--- .../app/views.py | 94 +++++++++---------- .../manifest.json | 10 +- 3 files changed, 66 insertions(+), 66 deletions(-) rename {template_ariel_cursor => template_ariel}/app/templates/index.html (83%) rename {template_ariel_cursor => template_ariel}/app/views.py (72%) rename {template_ariel_cursor => template_ariel}/manifest.json (66%) diff --git a/template_ariel_cursor/app/templates/index.html b/template_ariel/app/templates/index.html similarity index 83% rename from template_ariel_cursor/app/templates/index.html rename to template_ariel/app/templates/index.html index 73ec010..b199869 100644 --- a/template_ariel_cursor/app/templates/index.html +++ b/template_ariel/app/templates/index.html @@ -8,7 +8,7 @@ - Ariel Cursor App + Ariel App @@ -51,31 +51,31 @@

Start Search

Search Info


- +

Search Progress

- +
- +

Search Results

- +
- +

Delete Search

- +
- +

Cancel Search

- +
- +

Poll Search until Result

- +
- +

Save Search Results

- +
- +

List Searches

Response

diff --git a/template_ariel_cursor/app/views.py b/template_ariel/app/views.py similarity index 72% rename from template_ariel_cursor/app/views.py rename to template_ariel/app/views.py index 807ace3..e53a6a5 100644 --- a/template_ariel_cursor/app/views.py +++ b/template_ariel/app/views.py @@ -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: @@ -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 ) @@ -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 ) @@ -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: @@ -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 @@ -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: @@ -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 @@ -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} @@ -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( @@ -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 diff --git a/template_ariel_cursor/manifest.json b/template_ariel/manifest.json similarity index 66% rename from template_ariel_cursor/manifest.json rename to template_ariel/manifest.json index 82a448c..60419c2 100644 --- a/template_ariel_cursor/manifest.json +++ b/template_ariel/manifest.json @@ -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" } ] } \ No newline at end of file