Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

CluedIn

cluedin is a Python client for CluedIn API.

Installation

From PyPi:

pip install cluedin

Quick start

CluedIn context configuration

Create a JSON file with context configuration to your CluedIn instance:

In this file, parameters have the following meaning:

  • protocol - http if your CluedIn instance is not secured with a TLS certicate. Otherwise, https by default.
  • domain – CluedIn instance domain without the Organization prefix.
  • org_name – the name of Organization (a.k.a. Organization prefix).
  • user_email – the user's email.
  • user_password – the user's password.
  • verify_tlsfalse, if an unknown CA signs the TLS certificate. Otherwise, true by default.

Here is an example of a file for a CluedIn instance running locally from a Home repository:

{
    "protocol": "http",
    "domain": "127.0.0.1.nip.io",
    "org_name": "foobar",
    "user_email": "admin@foobar.com",
    "user_password": "Foobar23!"
}

We add the protocol, but we can skip this parameter if the URL starts with https. Likewise, we can skip verify_tls because it only makes sense for HTTPs URLs.

Alternatively, to provide email and password, you can obtain an API access token from CluedIn UI and provide it in the file:

{
    "protocol": "http",
    "domain": "127.0.0.1.nip.io",
    "org_name": "foobar",
    "access_token": "..."
}

When the configuration file exists, you can export its path to an environment variable:

export CLUEDIN_CONTEXT=~/.cluedin/home.json

Now, you can load this file from your Python code and get an access token (if not already provided):

import cluedin

context = Context.from_json_file(os.environ['CLUEDIN_CONTEXT'])
context.get_token()

You could also do it without the context file:

context = {
    "protocol": "http",
    "domain": "127.0.0.1.nip.io",
    "org_name": "foobar",
    "user_email": "admin@foobar.com",
    "user_password": "Foobar23!"
}

context = Context.from_dict(context)
context.get_token()

GraphQL

Get entities:

context = Context.from_json_file(os.environ['CLUEDIN_CONTEXT'])
context.get_token()

query = """
    query searchEntities($cursor: PagingCursor, $query: String, $pageSize: Int) {
      search(query: $query, sort: DATE, cursor: $cursor, pageSize: $pageSize) {
        totalResults
        cursor
        entries {
          id
          name
          entityType
        }
      }
    }
"""

variables = {
    "query": "*",
    "pageSize": 10_000
}

# it's important to request cursor in your GraphQL query,
# so cluedin.gql.entries would be able to request and return all pages
entities = cluedin.gql.entries(context, query, variables):

API

Environment

  • CLUEDIN_REQUEST_TIMEOUT_IN_SECONDS - CluedIn API request timeout (in seconds). If not set, then it defaults to 300 (5 minutes).

Context

  • Context.from_dict(cls, context_dict: dict) -> Context – creates a new Context object from a dict.
  • Context.from_json_file(file_path: str) -> Context – creates a new Context object from a JSON-file.

Account

  • cluedin.account.get_users(context: Context, org_id: str = None) -> list – returns all users for Organization.
  • cluedin.account.is_organization_available_response(context: Context, org_name: str) -> dict – checks if a given Organization name is available. This method returns a JSON-response serialized into a dict.
  • cluedin.account.is_organization_available(context: Context, org_name: str) -> bool – checks if a given Organization name is available. Returns a Boolean.
  • cluedin.account.is_user_available_response(context: Context, user_email: str, org_name: str) -> dict – checks, if a user with a given email can be created or this email is already reserved. This method returns a JSON-response serialized into a dict.
  • cluedin.account.is_user_available(context: Context, user_email: str, org_name: str) -> bool – checks, if a user with a given email can be created or this email is already reserved. This method returns a JSON-response serialized into a dict. Returns a Boolean.

GraphQL

  • cluedin.gql.gql(context: Context, query: str, variables: dict = None) -> dict – sends a GraphQL request and returns a response.
  • cluedin.gql.entries(context: Context, query: str, variables: dict = None) -> list – returns entries from a GraphQL search query. If cursor is requested in the GraphQL query (see the example above and tests), then it proceeds to next pages to return all results.

JWT

  • cluedin.jwt.get_jwt_payload(jwt: str) -> dict – parses a JWT (JSON Web Token, a.k.a. access token or API token), and returns its payload serialized into a dict.

Public API

  • cluedin.public.post_clue(context: Context, clue: str, content_type: str = 'application/xml') -> str – posts a clue in XML or JSON format. This method returns an operation result as a string.
  • cluedin.public.restore_user_entities(context: Context) -> list – if you accidentally deleted /Infrastructure/User entities, this method gets all users and restores entities for those who miss them.

Download files

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

Source Distribution

cluedin-2.0.0rc1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

cluedin-2.0.0rc1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file cluedin-2.0.0rc1.tar.gz.

File metadata

  • Download URL: cluedin-2.0.0rc1.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.4.0

File hashes

Hashes for cluedin-2.0.0rc1.tar.gz
Algorithm Hash digest
SHA256 00876ef39cf55f3d8b62d6c76218bd4192a06d2a3580db63e71a6786785cdc70
MD5 6789fc39c1743522ec5ae6bd191fe52e
BLAKE2b-256 498f7bc91b1d2d723ffcdd6a2bd1f84547246d310ae606f23fb93baf220eb9ed

See more details on using hashes here.

File details

Details for the file cluedin-2.0.0rc1-py3-none-any.whl.

File metadata

  • Download URL: cluedin-2.0.0rc1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.4.0

File hashes

Hashes for cluedin-2.0.0rc1-py3-none-any.whl
Algorithm Hash digest
SHA256 885e60ee977864ac3fe098c6654c167253fc2b7f99bed3c8890e66a18a5a6c30
MD5 b36b43be1d749823abb5e64c576e81d1
BLAKE2b-256 5a0d57c165a1748b085e2e3ac3659b06ea36b86f609efd55ebfcae01105b0e72

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