NaasIntegration
What it is
A Python integration client for the Naas API (https://api.naas.ai) that:
- Authenticates using a bearer API key.
- Wraps common Naas resources (workspaces, plugins, ontologies, users, secrets, storage, assets, model completions).
- Optionally exposes the integration as LangChain
StructuredToolinstances viaas_tools().
Public API
NaasIntegrationConfiguration
Dataclass configuration for the integration.
api_key: str— Naas API key (used as Bearer token).workspace_id: str | None = None— optional default workspace forupload_asset().storage_name: str | None = None— optional default storage forupload_asset().base_url: str = "https://api.naas.ai"— API base URL.
NaasIntegration(configuration)
Main client class (inherits naas_abi_core.integration.integration.Integration).
Workspace
create_workspace(name: str, is_personal: bool = False, **kwargs) -> Dict
Creates a workspace; supports logo/color customization fields viakwargs.get_workspace(workspace_id: str) -> Dict
Fetches workspace details by ID.list_workspaces() -> Dict
Lists accessible workspaces.get_personal_workspace() -> str
Returns the ID of the first workspace markedis_personal; raisesValueErrorif none found.update_workspace(workspace_id: str, **kwargs) -> Dict
Updates workspace fields (name/logo/color fields).delete_workspace(workspace_id: str) -> Dict
Deletes a workspace.
Plugins
create_plugin(workspace_id: str, data: Dict) -> Dict
Creates a plugin; payload is JSON-stringified.get_plugin(workspace_id: str, plugin_id: Optional[str] = None) -> Dict
Gets a single plugin whenplugin_idis provided; otherwise lists plugins.list_plugins(workspace_id: str) -> Dict
Lists all plugins in a workspace.update_plugin(workspace_id: str, plugin_id: str, data: Dict) -> Dict
Updates a plugin; payload is JSON-stringified.delete_plugin(workspace_id: str, plugin_id: str) -> Dict
Deletes a plugin.search_plugin(key: str, value: str, plugins: List[Dict[str, str]] = [], workspace_id: Optional[str] = None) -> Optional[str]
Searches for a plugin whose JSON-decodedpayloadcontainskey == value. Ifpluginsis empty andworkspace_idis provided, it fetches plugins first. Returns the matching plugin ID orNone.
Ontologies
create_ontology(workspace_id: str, label: str, source: str, level: str, description: Optional[str] = None, download_url: Optional[str] = None, logo_url: Optional[str] = None, is_public: bool = False) -> Dictget_ontology(workspace_id: str, ontology_id: str = "") -> Dict
Uses query paramworkspace_id; addsidwhenontology_idis provided.list_ontologies(workspace_id: str) -> Dict
Requests page size 100, page number 0.update_ontology(workspace_id: str, ontology_id: str, download_url: Optional[str] = None, source: Optional[str] = None, level: Optional[str] = None, description: Optional[str] = None, logo_url: Optional[str] = None, is_public: bool = False) -> Dict
Builds a field mask from provided fields (only addsis_publicwhenTrue).delete_ontology(workspace_id: str, ontology_id: str) -> Dict
Workspace users
get_workspace_users(workspace_id: str) -> Dictinvite_workspace_user(workspace_id: str, role: str = "member", email: Optional[str] = None, user_id: Optional[str] = None) -> Dict
Requires eitheremailoruser_id; raisesValueErrorotherwise.get_workspace_user(workspace_id: str, user_id: str) -> Dictupdate_workspace_user(workspace_id: str, user_id: str, role: Optional[str] = None, status: Optional[str] = None) -> Dictdelete_workspace_user(workspace_id: str, user_id: str) -> Dict
Secrets
get_secret(secret_id: str) -> Dictlist_secrets() -> List[Dict]
Returns the"secrets"list from the API response (defaults to[]).list_secrets_names() -> List[str]create_secret(name: str, value: str) -> Dictupdate_secret(secret_id: str, value: str) -> Dictdelete_secret(secret_id: str) -> Dict
Storage
list_workspace_storage(workspace_id: str) -> Dictlist_workspace_storage_objects(workspace_id: str, storage_name: str, prefix: str) -> Dictcreate_workspace_storage(workspace_id: str, storage_name: str) -> Dictcreate_workspace_storage_credentials(workspace_id: str, storage_name: str) -> Dictget_storage_credentials(workspace_id: Optional[str] = None, storage_name: Optional[str] = None) -> Dict[str, Any]
Requires both args; lists storage, creates it if missing, then creates credentials.
Assets
create_asset(workspace_id: str, storage_name: str, object_name: str, visibility: str = "public", content_disposition: str = "inline", password: Optional[str] = None) -> Dictupload_asset(data: bytes, prefix: str, object_name: str, workspace_id: Optional[str] = None, storage_name: Optional[str] = None, visibility: str = "public", content_disposition: str = "inline", password: Optional[str] = None, version: Optional[str] = None, return_url: bool = False) -> Dict
Uploads bytes to Naas object storage viaObjectStorageFactory.ObjectStorageServiceNaas(...).put_object(...), then creates/gets an asset via HTTP. Ifreturn_url=True, returns{"asset_url": ...}.update_asset(workspace_id: str, asset_id: str, data: Dict) -> Dictget_asset(workspace_id: str, asset_id: str) -> Dict
Models
create_completion(model_id: str, prompt: str, system_prompt: Optional[str] = None, temperature: float = 0.3) -> Dict
Calls/model/{model_id}/completionand returns the first completion object:completion_response["completion"]["completions"][0].
Utility
get_user_id_from_jwt(jwt_token) -> Optional[str]
Decodes JWT without signature verification and returns the"sub"claim; logs errors and returnsNone.
as_tools(configuration: NaasIntegrationConfiguration) -> list
Factory that returns a list of LangChain StructuredTool objects mapping to many integration methods (workspace/plugin/ontology/users/secrets/storage). Schemas are defined with Pydantic models.