New Features

Python client update

Throughout this quarter, the Onesait Platform Python client library has been updated.

Taking advantage of the release of Onesait Platform version 7.0.0-Zelda, a number of updates to the library have been released.

Taking advantage of the release of version 7.0.0-Zelda of Onesait Platform, a series of updates of the library have been released, with two updates with many improvements, corresponding to versions 1.4.12 and 1.4.13 of our library. Currently the most recent version is 1.4.15, which includes minor changes to exception and log handling.

Here are the changes included:

Version 1.4.15
Version 1.4.14

In these versions, changes have been made related to exception handling and library registers.

Although no new methods or fixes are included, it is recommended to upgrade to the latest version available.

---------------------------------------------------

Version 1.4.13

The ApiManager class has been reviewed and it has been observed that the endpoints to which it pointed were not the correct ones. Therefore, they have been changed to others that offer the same functionality, but belonging to the Control Panel:

find: searches for a REST API, indicating the identification (name) and version. If found, it returns the API information; if not found, it returns an error. The endpoint was updated to /api/apis/{id}.
create: creates a new REST API, passing a JSON object as a parameter. Performs a POST to the /api/apis endpoint.
delete: deletes an API, providing the ID and version of the API to delete. The request is made to /api/apis/{identification}.
list: lists all APIs, both user and public, unless a specific user is specified. The request is made via a GET to /api/apis.
request: this function works correctly, so it is kept as it was.

---------------------------------------------------

Version 1.4.12

The following functions are performed in the DigitalClient class:

raw_query_file: makes a call to the /REST/Ontology/{ontology}/file endpoint of the Digital Broker, requesting as parameters the ontology (the Entity), the sentence to execute, the type of sentence (SQL or NATIVE) and the destination of the file to generate (DISK, S3_MINIO or URL). It is performed to generate a JSON file with the information about the query requested on an Entity.
query_file: makes the call to raw_query_file, handles the response and returns a success status together with the data obtained, or an error message in case of failure. It requires the same parameters as raw_query_file: the Entity (ontology), the statement to execute, the type of statement (SQL or NATIVE) and the destination of the file to generate (DISK, S3_MINIO or URL).
raw_query_file_status: makes a call to the /rest/ontology/file/{queryId}/status endpoint, requesting as parameter the queryId. If the request is successful, it can return two possible values: FINISHED or IN_PROGRESS.

query_file_status: calls the raw_query_file_status function, handles the response and returns a success status with the retrieved data or an error message in case of failure. It requires the same parameter as raw_query_file_status: the queryId. In addition, the parameters ‘timeout’ and ‘timesleep’ can be optionally provided. The function shall call raw_query_file_status repeatedly; if the response is IN_PROGRESS, it shall wait for the time specified in ‘timesleep’ before making the request again. This process shall be repeated until the response is FINISHED or the time limit set in ‘timeout’ is reached. By default, the timeout is 60 seconds and the timesleep is 5 seconds.

The following functions are performed in the FileManagerclass:

download_file_minio: makes a call to the control panel, to the /api/objectstorage endpoint, to download a file from MinIo, passing the ‘filepath’. Handles the response and, in case of success, saves the content in a parameter called ‘json_data’, for later use. In case of failure, it returns an error message.

to_pandasdataframe: takes the value of ‘json_data’ (or any other list or dictionary) that is collected by the previous function and ‘flattens’ its structure. This allows a better visualisation when creating the DataFrame with Pandas. You can specify the type of separator to use, although by default it will be the dot (‘.’).

Header Image: Hack a Boss

✍🏻 Author(s)

Leave a Reply