diff --git a/README.md b/README.md index c3a29bc..2d59296 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,5 @@ Documentation can be found at [https://traversys.github.io/Tideway/](https://tra | 0.1.1 | Updated to API v1.2
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
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.
Search Bulk will now return the full response on failure | diff --git a/docs/index.md b/docs/index.md index a148f35..c5e696e 100644 --- a/docs/index.md +++ b/docs/index.md @@ -49,4 +49,5 @@ $ python -m pip install tideway | 0.1.1 | Updated to API v1.2
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
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.
Search Bulk will now return the full response on failure | diff --git a/docs/quickstart/initiation.md b/docs/quickstart/initiation.md index a418215..8684f16 100644 --- a/docs/quickstart/initiation.md +++ b/docs/quickstart/initiation.md @@ -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. \ No newline at end of file diff --git a/setup.py b/setup.py index 6c7cf6f..132a1c2 100644 --- a/setup.py +++ b/setup.py @@ -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.", diff --git a/tideway/data.py b/tideway/data.py index 8719807..ada81c7 100644 --- a/tideway/data.py +++ b/tideway/data.py @@ -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): ''' diff --git a/tideway/discoRequests.py b/tideway/discoRequests.py index 93289d1..beb3957 100644 --- a/tideway/discoRequests.py +++ b/tideway/discoRequests.py @@ -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"): diff --git a/tideway/main.py b/tideway/main.py index 8d7fc5a..b8f7bd9 100644 --- a/tideway/main.py +++ b/tideway/main.py @@ -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 = {}