Package: cluedin
CluedIncluedinis a Python client forCluedInAPI.InstallationFromPyPi:pipinstallcluedinQuick startCluedIn context configurationCreate a JSON file with context configuration to your CluedIn instance:In this file, parameters have the following meaning:protocol-httpif your CluedIn instance is not secured with a TLS certicate. Otherwise,httpsby 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_tls–false, if an unknown CA signs the TLS certificate. Otherwise,trueby default.Here is an example of a file for a CluedIn instance running locally from aHomerepository:{"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 withhttps. Likewise, we can skipverify_tlsbecause 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:exportCLUEDIN_CONTEXT=~/.cluedin/home.jsonNow, you can load this file from your Python code and get an access token (if not already provided):importcluedincontext=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()GraphQLGet 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: FIELDS,cursor: $cursor,pageSize: $pageSizesortFields: {field: "id", direction: ASCENDING}) {totalResultscursorentries {idnameentityType}}}"""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 pagesentities=cluedin.gql.entries(context,query,variables):APIEnvironmentCLUEDIN_REQUEST_TIMEOUT_IN_SECONDS- CluedIn API request timeout (in seconds). If not set, then it defaults to300(5 minutes).ContextContext.from_dict(cls, context_dict: dict) -> Context– creates a newContextobject from adict.Context.from_json_file(file_path: str) -> Context– creates a newContextobject from a JSON-file.Accountcluedin.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 adict.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 adict.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 adict. Returns a Boolean.cluedin.account.get_invitation_code(context: Context, email: str) -> str– returns an invitation code for a given email.cluedin.account.create_organization(context: Context, user_email: str, password: str, org_name: str, org_sub_domain: str = None, email_domain: str = None, allow_email_domain_signup: bool = True, new_account_access_key: str = None) -> dict- creates a new Organization. This method returns a JSON-response serialized into adict.cluedin.account.create_user(context: Context, user_email: str, user_password: str) -> requests.models.Response– creates a new user. This method returnsrequests.models.Response.cluedin.account.create_admin_user(context: Context, user_email: str, user_password: str) -> requests.models.Response– creates a new admin user. This method returnsrequests.models.Response.cluedin.account.get_user(context: Context, user_id: str = None) -> dict– returns a user by ID. Ifuser_idis nor provided, the current user is returned. This method returns a JSON-response serialized into adict.Entitycluedin.entity.get_entity_blob(context: Context, entity_id: str) -> str– returns an entity blob by ID.cluedin.entity.get_entity_as_clue(context: Context, entity_id: str) -> str– returns an entity as a clue by ID.GraphQLcluedin.gql.gql(context: Context, query: str, variables: dict = None) -> dict– sends a GraphQL request and returns a response.cluedin.gql.org_gql(context: Context, query: str, variables: dict = None) -> dict– sends a GraphQL request to Organization endpoint and returns a response.cluedin.gql.entries(context: Context, query: str, variables: dict = None, flat=False) -> 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. IfflatisTrue, then it flattens thepropertiesdictionary of each returned entity.JSONdump(file: str, obj: Any) -> None– serialize obj as a JSON formatted stream to file.load(file: str) -> Any– deserialize file to a Python object.JWTcluedin.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 adict.Public APIcluedin.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/Userentities, this method gets all users and restores entities for those who miss them.Vocabularycluedin.vocab.get_vocab_keys(context: Context) -> list– gets all vocabulary keys.