Skip to main content

A Python API wrapping services of the Superb Data Kraken (SDK)

Project description

SDK-API

SDK-API is a simple library to access various services of the Superb Data Kraken (SDK) platform. It abstracts accessing services and resources of the SDK with a Python client object managing Authorization, Fetching and Indexing data.

It is primarily intended for use in an Jupyter Hub environment within the platform itself, but can be configured for different environments as well.

Installation and Supported Versions

$ python -m pip install sdk-api

SDK-API officially supports Python 3.7+.

Usage

Authentication

Before using the api, it is necessary to authenticate against the OIDC provider of the SDK. This is done at instantiation time of the client object. There are two ways to do this.

  1. Using system environment variables. This is the default case which should be used in a Jupyter environment. Simply instantiating the client object is enough in this case.

    import sdk.api
    client = sdk.api.SDKClient()
    

    This however assumes access and refresh tokens are accessible via the enviroment variables SDK_ACCESS_TOKEN, SDK_REFRESH_TOKEN.

  2. Using login credentials

    import sdk.api
    sdk.api.SDKClient(username='hasslethehoff', password='lookingforfreedom')
    

Configuration

By default everything is configured for usage with the default instance of the SDK but comes with settings for various different instances as well.

Setting Environment

import sdk.api
client = sdk.api.SDKClient(env='sdk-dev')
client = sdk.api.SDKClient(env='sdk')

Overwriting Settings

client = sdk.api.SDKClient(domain='mydomain.ai', realm='my-realm', client_id='my-client-id', api_version='v13.37')

Examples

Organizations

client.organization_get_all()
client.organization_get_by_id(1337)
client.organization_get_by_name('my-organization')

Spaces

Get all Spaces to a given Organization

organization_id = 1234
client.space_get_all(organization_id)
client.space_get_by_id(organization_id, space_id)
client.space_get_by_name(organization_id, space_name)

Index

List all Indices accessible with given credentials

indices = client.index_get_all()

Get specific document

document = client.index_get_document(index_name, doc_id)

Write document to index

documents = [
   {
      "_id": 123
      "name": "document01",
      "value": "value"
   },
   {
      "_id": 1337
      "name": "document01",
      "value": "value"
   }
]
index_name = "index" 
client.index_documents(documents, index_name)

The (optional) field _id is parsed and used as document id to index to opensearch.

List all indices filtered by organization, space and type accessible with given credentials

client.index_filter_by_space("my-organization", "my-space", "index-type")

use .* instead of my_space to get indices from all spaces in the given organization

index_type is either ANALYSIS or MEASUREMENTS

Create an application index

application_index = {
   "organizationName": "my-organization",
   "spaceName": "my-space",
   "customName": "my-application-index",
   "indexType": "ANALYSIS",
   "mappings": {}
}
client.application_index_create(application_index)

Delete an application index by name

client.application_index_delete("my-organization_my-space_analysis_my-application-index")

Storage

List files in Storage

files = client.storage_list_blobs(org_name, space_name)

Download files from Storage to local directory

files = [
   'file01.txt'
   'directory/file02.json',
]
client.storage_download_files(organization='my-organization', space='my-space', files=files, local_dir='tmp)

Project details


Download files

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

Source Distribution

sdk-api-0.2.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdk_api-0.2.1-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file sdk-api-0.2.1.tar.gz.

File metadata

  • Download URL: sdk-api-0.2.1.tar.gz
  • Upload date:
  • Size: 13.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for sdk-api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 2c6a8301ab0963b970e2717ea51e334cf85a96bf2ebcb1f6d0acc3f3b0df5ee7
MD5 a0b2aafd76f7a182fd646f1bd1194dac
BLAKE2b-256 f0fcc3c80ac2e49a5ec8bca242192986b110f2a2c6fbf399f292883bbebf5cbb

See more details on using hashes here.

File details

Details for the file sdk_api-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: sdk_api-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for sdk_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4052ca45c270d8b9a08fb701ebec3f1b648cbe256bcedc5fd8919b0125f7d7a1
MD5 e8509c3382da5bb2096da61efc407009
BLAKE2b-256 a955aadc646ac506f1dc78bd0238ec03f04738f81c9e7b3906d67ba8ec3348a1

See more details on using hashes here.

Supported by

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