Skip to content

Commit

Permalink
v0.1.5
Browse files Browse the repository at this point in the history
* Merge from Main into Dev (#7)

* Update to 0.1.4

* v0.1.4
Include headers for unformatted search_bulk()

* Updated known issues

* v0.1.5_dev.01

- Updated Authorisation Bearer string for API v1.3 support
- Added check for search_bulk() and return the same response as search() in the event of failure
  • Loading branch information
codefitz authored Oct 1, 2021
1 parent c52dcfb commit f16f4dc
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@ Documentation can be found at [https://traversys.github.io/Tideway/](https://tra
| 0.1.1 | Updated to API v1.2<br>Added `help()`, `search_bulk()` | search call retains last parameters for `offset`, `results_id` | |
| 0.1.2 | Bug Fixes | Bulk search with larger limit than dataset will fail on missing `next_offset` | Fixed issue with `offset` and `results_id` values<br>Fixed issue with bulk search parameter lower limit. |
| 0.1.3 | Bug Fixes | | Added check for `next_offset`. |
| 0.1.4 | Search bulk update | Discovery 12.3 (21.3) enforces strict case for "Bearer" header - api calls will not current work. | Now includes headers for non-formatted search. |
| 0.1.4 | Search bulk update | Discovery 12.3 (21.3) enforces strict case for "Bearer" header - api calls will not current work. | Now includes headers for non-formatted search. |
| 0.1.5 | Updated to support Discovery 12.3 (API version 1.3) | | Fixed issue with Bearer capitalisation.<br>Search Bulk will now return the full response on failure |
3 changes: 2 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ $ python -m pip install tideway
| 0.1.1 | Updated to API v1.2<br>Added `help()`, `search_bulk()` | search call retains last parameters for `offset`, `results_id` | |
| 0.1.2 | Bug Fixes | Bulk search with larger limit than dataset will fail on missing `next_offset` | Fixed issue with `offset` and `results_id` values<br>Fixed issue with bulk search parameter lower limit. |
| 0.1.3 | Bug Fixes | | Added check for `next_offset`. |
| 0.1.4 | Search bulk update | Discovery 12.3 (21.3) enforces strict case for "Bearer" header - api calls will not current work. | Now includes headers for non-formatted search. |
| 0.1.4 | Search bulk update | Discovery 12.3 (21.3) enforces strict case for "Bearer" header - api calls will not current work. | Now includes headers for non-formatted search. |
| 0.1.5 | Updated to support Discovery 12.3 (API version 1.3) | | Fixed issue with Bearer capitalisation.<br>Search Bulk will now return the full response on failure |
2 changes: 1 addition & 1 deletion docs/quickstart/initiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ Upon initiation the following parameters can be used:
| - | - | - | - | -
| target | Required | String | | The Hostname, FQDN or IP Address of the Discovery instance.
| token | Required | String | | The authentication token of the API user. It is not necessary to include the "bearer" pre-text.
| api_version | | String | "1.2" | This should be the supported version of the API. Discovery 12.2 supports 1.0, 1.1 and 1.2.
| api_version | | String | "1.3" | This should be the supported version of the API. Discovery 12.3 supports API versions up to 1.3.
| ssl_verify | | Boolean | False | Choose whether to query the API using a valid SSL certificate. If you are using self-signed HTTPS then you should leave this with the default value.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="tideway",
version="0.1.4",
version="0.1.5",
author="Wes Moskal-Fitzpatrick",
author_email="wes@traversys.io",
description="library for BMC Discovery API Interface.",
Expand Down
51 changes: 27 additions & 24 deletions tideway/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,33 @@ def searchQuery(self, body, offset=None, results_id=None, format=None, limit = 1
def search_bulk(self, query, format = None, limit = 100, delete = False):
'''Performs a bulk search, will loop through paginated results until the limit is reached and return a JSON object.'''
initial = Data.search(self, query, None, None, format, limit, delete)
init_results = initial.json()
results = init_results[0]
all_results = []
if 'headings' in results:
headings = results['headings']
all_results.append(headings)
for item in results['results']:
all_results.append(item)
if 'results_id' and 'next_offset' in results:
total = init_results[0]['count']
res_id = results['results_id']
next_offset=results['next_offset']
total = int(total / next_offset)
for count in range(0,total):
s = Data.search(self, query, next_offset, res_id, format, limit, delete)
json_results = s.json()
records = json_results[0]['results']
for item in records:
all_results.append(item)
if 'next_offset' in json_results[0]:
next_offset=json_results[0]['next_offset']
else:
break
return json.loads(json.dumps(all_results))
if initial.ok:
init_results = initial.json()
results = init_results[0]
all_results = []
if 'headings' in results:
headings = results['headings']
all_results.append(headings)
for item in results['results']:
all_results.append(item)
if 'results_id' and 'next_offset' in results:
total = init_results[0]['count']
res_id = results['results_id']
next_offset=results['next_offset']
total = int(total / next_offset)
for count in range(0,total):
s = Data.search(self, query, next_offset, res_id, format, limit, delete)
json_results = s.json()
records = json_results[0]['results']
for item in records:
all_results.append(item)
if 'next_offset' in json_results[0]:
next_offset=json_results[0]['next_offset']
else:
break
return json.loads(json.dumps(all_results))
else:
return initial

def candidate(self, body):
'''
Expand Down
2 changes: 1 addition & 1 deletion tideway/discoRequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def url_and_headers(target,token,api_endpoint,response):
url = target + api_endpoint
headers = {"Accept": response, "Authorization":"bearer " + str(token) }
headers = {"Accept": response, "Authorization":"Bearer " + str(token) }
return url, headers

def discoRequest(appliance, api_endpoint, response="application/json"):
Expand Down
2 changes: 1 addition & 1 deletion tideway/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Appliance:
'''An appliance instance.'''

def __init__(self, target, token, limit = 100, delete = False, api_version = "1.2", ssl_verify = False):
def __init__(self, target, token, limit = 100, delete = False, api_version = "1.3", ssl_verify = False):
self.target = target
self.token = token
self.params = {}
Expand Down

0 comments on commit f16f4dc

Please sign in to comment.