Skip to main content

SAP AI API Client SDK

Project description

AI API Client SDK

Client SDK for AI API. This repo creates the ai_api_client_sdk library. Everything in ai_api_client_sdk folder will be packaged in the library.

The main client class is the AIAPIV2Client. Each instance of AIAPIV2Client has resource clients as properties. The resource client implementations can be found in folder resource_clients. The resources, response types etc. are represented by model classes. These can be found in folder models.

Usage

The user can use the library by creating an instance of AIAPIV2Client class. There are some required and optional parameters for the constructor of AIAPIV2Client class:

  • base_url (string) (required): The base URL of AI API. (i.e. https://api.ai.nonexistingcluster.com/v2/lm)
  • token_creator (optional) (Callable): This should be a function which returns a token for authorization. Either this function or auth_url, client_id and client_secret should be provided.
  • auth_url: URL for creating the authorization token (i.e. https://blabla.authentication.sap.hana.ondemand.com/oauth/token)
  • client_id (optional): clientid for xsuaa authentication
  • client_secret(optional): clientsecret for xsuaa authentication
  • resource_group (string) (optional): if provided, this will be used as default resource group id for requests to the AI API. The user can still provide resource_group with every request to the AI API, and that will override this one.

The AIAPIV2Client will have a property per resource (each one is an instance of a resource_client):

Each resource client has these functions (if supported for that resource) to send requests to the AI API:

  • create(*args, **kwargs): creates a resource
  • delete(*args, **kwargs): deletes a resource
  • get(*args, **kwargs): gets a single resource
  • modify(*args, **kwargs): patches a resource
  • query(*args, **kwargs): queries multiple resources

Example:

from ai_api_client_sdk.ai_api_v2_client import AIAPIV2Client

ai_api_v2_client = AIAPIV2Client(
    base_url="<BASE_URL>",
    auth_url="<AUTH_URL>",
    client_id="<CLIENT_ID>",
    client_secret="<CLIENT_SECRET>",
    resource_group="<RESOURCE_GROUP_ID>"
)

scenario = ai_api_v2_client.scenario.get(scenario_id="<SCENARIO_ID>")

Tests

The unit tests are simply python unit tests. They can be run via nosetests or directly from IDE.

The integration_tests are also python tests. They run against intwdf cluster. But they need resource group provisioned/deprovisioned before/after running them. If they are triggered via nosetsts the setUpModule() and tearDownModule() functions in corresponding __init__.py are properly discovered and called. However when running the integration tests from IDE, those are functions cannot be discovered. Therefore when running from local via IDE, the provisioning/deprovisioning should be done somewhere else. You can do so, by simple uncommenting the corresponding lines in setUpClass() and tearDownClass() functions in AIAPIV2ClientE2ETestBase class.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ai_api_client_sdk-1.13.0-py3-none-any.whl (79.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page