Package: sdk-api
SDK-APISDK-APIis a simple library to access various services of theSuperb 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-mpipinstallsdk-apiSDK-API officially supports Python 3.7+.UsageAuthenticationBefore 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.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.importsdk.apiclient=sdk.api.SDKClient()This however assumes access and refresh tokens are accessible via the enviroment variablesSDK_ACCESS_TOKEN, SDK_REFRESH_TOKEN.Using login credentialsimportsdk.apisdk.api.SDKClient(username='hasslethehoff',password='lookingforfreedom')ConfigurationBy default everything is configured for usage with the default instance of the SDK but comes with settings for various different instances as well.Setting Environmentimportsdk.apiclient=sdk.api.SDKClient(env='sdk-dev')client=sdk.api.SDKClient(env='sdk')Overwriting Settingsclient=sdk.api.SDKClient(domain='mydomain.ai',realm='my-realm',client_id='my-client-id',api_version='v13.37')ExamplesOrganizationsclient.organization_get_all()client.organization_get_by_id(1337)client.organization_get_by_name('my-organization')SpacesGet all Spaces to a given Organizationorganization_id=1234client.space_get_all(organization_id)client.space_get_by_id(organization_id,space_id)client.space_get_by_name(organization_id,space_name)IndexList all Indices accessible with given credentialsindices=client.index_get_all()Get specific documentdocument=client.index_get_document(index_name,doc_id)Write document to indexdocuments=[{"_id":123"name":"document01","value":"value"},{"_id":1337"name":"document01","value":"value"}]index_name="index"client.index_documents(documents,index_name)The (optional) field_idis parsed and used as document id to index to opensearch.List all indices filtered by organization, space and type accessible with given credentialsclient.index_filter_by_space("my-organization","my-space","index-type")use.*instead ofmy_spaceto get indices from all spaces in the given organizationindex_typeis eitherANALYSISorMEASUREMENTSCreate an application indexapplication_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 nameclient.application_index_delete("my-organization_my-space_analysis_my-application-index")StorageList files in Storagefiles=client.storage_list_blobs(org_name,space_name)Download files from Storage to local directoryfiles=['file01.txt''directory/file02.json',]client.storage_download_files(organization='my-organization',space='my-space',files=files,local_dir='tmp)