Skip to content

API Integration

Overview

The KelvinApp class comes with a full API integration library for utilizing all features on the Kelvin Platform.

Note

You can see the documentation on all API endpoints here.

It simplifies building, publishing, receiving, and filtering Kelvin messages and accessing Asset resources linked to your application.

Setup Environment

This method uses the default KelvinApp library for a seamless programming experience.

Secrets

First setup the secrets that you will use in the app.yaml.

Warning

For maximum security do not put your credentials directly into the app.yaml file.

Note

You can assign any name for your secret variable

Create Secrets
1
2
3
kelvin secret create docs-api-url --value="https://<YOUR_PLATFORM>.kelvin.ai"
kelvin secret create docs-api-username --value="example@kelvin.ai"
kelvin secret create docs-api-password --value="abigsecretpassword"

app.yaml

In the app.yaml file, declare these secrets as environment variables.

Add Environment Variables
1
2
3
4
5
6
7
8
9
  # System Settings
  system:
    environment_vars:
      - name: KELVIN_CLIENT__URL
        value: <% secrets.docs-api-url %>
      - name: KELVIN_CLIENT__USERNAME
        value: <% secrets.docs-api-username %>
      - name: KELVIN_CLIENT__PASSWORD
        value: <% secrets.docs-api-password %>

Python Example

You can now easily perform Kelvin API request in your Kelvin SmartApp™.

API request
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
import structlog
import asyncio

from kelvin.application import KelvinApp

async def main() -> None:
    logger = structlog.get_logger()
    app = KelvinApp()

    await app.connect()

    while True:
        result = await app.api.asset.list_assets()
        logger.debug(f"My APP results is {result}")
        await asyncio.sleep(10)


if __name__ == "__main__":
    asyncio.run(main())

All API requests use the app.api. stub.

Local Testing

The KelvinApp API integration scripts can be tested locally before the Application is uploaded to the Kelvin Platform.

This works slightly differently from a normal Kelvin SmartApp™ testing procedure as you do not need the simulator to simulate connection to the Kelvin Platform.

Warning

Using this method connects you directly to your actual Kelvin Platform.

ANY DATA MODIFICATIONS YOU MAKE WILL BE IMPLEMENTED ON THE KELVIN PLATFORM.

Setup

Before running your code, you need to set your environment variables from the terminal.

Note

Make sure your URL also contains the https:// at the beginning.

Environment Variables Setup for Python Script
1
2
3
export KELVIN_CLIENT__URL=https://<YOUR KELVIN URL>
export KELVIN_CLIENT__USERNAME=example@kelvin.ai
export KELVIN_CLIENT__PASSWORD="secret_PASSWORD"

Testing

Now you can test your Python script;

Note

If you also incorporate specific SDK APP capabilities, then you will need to test your script as a Kelvin SmartApp™. Full documentation is given here.

Testing Python Script
1
python main.py

SDK API Methods

For a full up to date list of options available and the descriptions of parameters, go to your local Kelvin Platform redocly documentation.

Note

You can do this by typing https://<YOUR PLATFORM URL>/api/spec/

Listed here are all the API request options available.

app.api.app_parameters
  • app.api.app_parameters.apply_parameters_schedule
  • app.api.app_parameters.create_parameters_schedule
  • app.api.app_parameters.delete_parameters_schedule
  • app.api.app_parameters.get_app_version_parameters_fallback_values
  • app.api.app_parameters.get_app_version_parameters_unique_values
  • app.api.app_parameters.get_parameters_schedule
  • app.api.app_parameters.list_app_parameters
  • app.api.app_parameters.list_app_version_parameter_values
  • app.api.app_parameters.list_app_version_parameters_history
  • app.api.app_parameters.list_parameters_schedule
  • app.api.app_parameters.model_post_init
  • app.api.app_parameters.update_app_version_parameters
  • app.api.app_parameters.update_app_version_parameters_defaults
app.api.app_workloads
  • app.api.app_workloads.add_workload_resources
  • app.api.app_workloads.apply_workloads
  • app.api.app_workloads.create_workload
  • app.api.app_workloads.delete_workloads
  • app.api.app_workloads.download_workload
  • app.api.app_workloads.get_workload
  • app.api.app_workloads.get_workload_logs
  • app.api.app_workloads.list_workloads
  • app.api.app_workloads.model_post_init
  • app.api.app_workloads.remove_workload_resources
  • app.api.app_workloads.start_workloads
  • app.api.app_workloads.stop_workloads
  • app.api.app_workloads.update_workload
  • app.api.app_workloads.update_workloads_bulk
app.api.apps
  • app.api.apps.create_app_version
  • app.api.apps.delete_app
  • app.api.apps.delete_app_resources
  • app.api.apps.delete_app_version
  • app.api.apps.deploy_app_version
  • app.api.apps.disable_app_resources
  • app.api.apps.enable_app_resources
  • app.api.apps.get_app
  • app.api.apps.get_app_version
  • app.api.apps.list_app_resources
  • app.api.apps.list_apps
  • app.api.apps.list_apps_context
  • app.api.apps.model_post_init
  • app.api.apps.patch_app
  • app.api.apps.patch_app_version
  • app.api.apps.update_app_version
app.api.asset
  • app.api.asset.create_asset
  • app.api.asset.create_asset_bulk
  • app.api.asset.create_asset_type
  • app.api.asset.delete_asset
  • app.api.asset.delete_asset_bulk
  • app.api.asset.delete_asset_type
  • app.api.asset.delete_asset_type_bulk
  • app.api.asset.get_asset
  • app.api.asset.get_asset_status_count
  • app.api.asset.get_asset_status_current
  • app.api.asset.get_asset_type
  • app.api.asset.list_asset_types
  • app.api.asset.list_asset_types_advanced
  • app.api.asset.list_assets
  • app.api.asset.list_assets_advanced
  • app.api.asset.model_post_init
  • app.api.asset.update_asset
  • app.api.asset.update_asset_type
app.api.asset_insights
  • app.api.asset_insights.get_asset_insights
  • app.api.asset_insights.model_post_init
app.api.control_change
  • app.api.control_change.create_control_change
  • app.api.control_change.delete_control_change
  • app.api.control_change.get_control_change
  • app.api.control_change.get_control_change_clustering
  • app.api.control_change.get_control_change_last
  • app.api.control_change.get_control_change_range
  • app.api.control_change.list_control_changes
  • app.api.control_change.model_post_init
app.api.custom_actions
  • app.api.custom_actions.create_custom_action
  • app.api.custom_actions.create_custom_actions_type
  • app.api.custom_actions.delete_custom_action
  • app.api.custom_actions.delete_custom_action_type
  • app.api.custom_actions.get_custom_action
  • app.api.custom_actions.get_custom_actions_type
  • app.api.custom_actions.list_custom_actions
  • app.api.custom_actions.list_custom_actions_types
  • app.api.custom_actions.model_post_init
  • app.api.custom_actions.update_custom_actions_type
app.api.data_quality
  • app.api.data_quality.create_bulk_data_quality
  • app.api.data_quality.create_data_quality
  • app.api.data_quality.data_quality_simulate
  • app.api.data_quality.delete_bulk_data_quality
  • app.api.data_quality.delete_data_quality
  • app.api.data_quality.get_data_quality
  • app.api.data_quality.list_data_quality
  • app.api.data_quality.model_post_init
  • app.api.data_quality.update_bulk_data_quality
  • app.api.data_quality.update_data_quality
app.api.data_tag
  • app.api.data_tag.create_data_tag
  • app.api.data_tag.create_tag
  • app.api.data_tag.delete_data_tag
  • app.api.data_tag.delete_tag
  • app.api.data_tag.get_data_tag
  • app.api.data_tag.get_tag
  • app.api.data_tag.list_data_tag
  • app.api.data_tag.list_tag
  • app.api.data_tag.model_post_init
  • app.api.data_tag.update_data_tag
  • app.api.data_tag.update_tag
app.api.datastreams
  • app.api.datastreams.create_bulk_data_stream
  • app.api.datastreams.create_bulk_data_stream_unit
  • app.api.datastreams.create_data_stream
  • app.api.datastreams.create_data_stream_semantic_type
  • app.api.datastreams.create_data_stream_unit
  • app.api.datastreams.delete_bulk_data_stream
  • app.api.datastreams.delete_data_stream
  • app.api.datastreams.delete_data_stream_semantic_type
  • app.api.datastreams.delete_data_stream_unit
  • app.api.datastreams.get_data_stream
  • app.api.datastreams.get_data_stream_context
  • app.api.datastreams.get_data_stream_semantic_type
  • app.api.datastreams.get_data_stream_unit
  • app.api.datastreams.list_data_stream_contexts
  • app.api.datastreams.list_data_streams
  • app.api.datastreams.list_data_streams_data_types
  • app.api.datastreams.list_data_streams_semantic_types
  • app.api.datastreams.list_data_streams_units
  • app.api.datastreams.model_post_init
  • app.api.datastreams.update_data_stream
  • app.api.datastreams.update_data_stream_semantic_type
  • app.api.datastreams.update_data_stream_unit
app.api.filestorage
  • app.api.filestorage.delete_file
  • app.api.filestorage.download_file
  • app.api.filestorage.get_file
  • app.api.filestorage.list_files
  • app.api.filestorage.model_post_init
  • app.api.filestorage.upload_file
app.api.guardrails
  • app.api.guardrails.create_bulk_guardrails
  • app.api.guardrails.create_guardrail
  • app.api.guardrails.delete_bulk_guardrails
  • app.api.guardrails.delete_guardrail
  • app.api.guardrails.get_guardrail
  • app.api.guardrails.list_guardrails
  • app.api.guardrails.model_post_init
  • app.api.guardrails.update_guardrail
app.api.instance
  • app.api.instance.delete_instance_setting
  • app.api.instance.get_instance_audit_log
  • app.api.instance.get_instance_settings
  • app.api.instance.get_instance_settings_kelvin_cluster
  • app.api.instance.get_instance_status
  • app.api.instance.list_instance_audit_logs
  • app.api.instance.list_instance_settings
  • app.api.instance.model_post_init
  • app.api.instance.update_instance_settings
  • app.api.instance.update_instance_settings_kelvin_cluster
app.api.orchestration
  • app.api.orchestration.apply_orchestration_clusters_edge_apps_version
  • app.api.orchestration.create_orchestration_clusters
  • app.api.orchestration.delete_orchestration_clusters
  • app.api.orchestration.download_orchestration_cluster_provision_binary
  • app.api.orchestration.get_orchestration_clusters
  • app.api.orchestration.get_orchestration_clusters_manifests
  • app.api.orchestration.get_orchestration_clusters_nodes
  • app.api.orchestration.get_orchestration_clusters_provision
  • app.api.orchestration.list_orchestration_clusters
  • app.api.orchestration.list_orchestration_clusters_node
  • app.api.orchestration.list_orchestration_clusters_service
  • app.api.orchestration.model_post_init
  • app.api.orchestration.update_orchestration_clusters
  • app.api.orchestration.update_orchestration_clusters_edge_apps_version_force
app.api.properties
  • app.api.properties.create_property
  • app.api.properties.delete_property
  • app.api.properties.delete_property_values
  • app.api.properties.get_property
  • app.api.properties.get_property_unique_values
  • app.api.properties.get_property_values
  • app.api.properties.list_properties
  • app.api.properties.model_post_init
  • app.api.properties.property_range_get
  • app.api.properties.update_property_values
app.api.recommendation
  • app.api.recommendation.create_recommendation
  • app.api.recommendation.create_recommendation_type
  • app.api.recommendation.delete_recommendation
  • app.api.recommendation.delete_recommendation_type
  • app.api.recommendation.get_recommendation
  • app.api.recommendation.get_recommendation_clustering
  • app.api.recommendation.get_recommendation_last
  • app.api.recommendation.get_recommendation_range
  • app.api.recommendation.get_recommendation_type
  • app.api.recommendation.list_recommendation_types
  • app.api.recommendation.list_recommendations
  • app.api.recommendation.model_post_init
  • app.api.recommendation.update_recommendation_accept
  • app.api.recommendation.update_recommendation_reject
  • app.api.recommendation.update_recommendation_type
app.api.secret
  • app.api.secret.create_secret
  • app.api.secret.delete_secret
  • app.api.secret.list_secrets
  • app.api.secret.model_post_init
  • app.api.secret.update_secret
app.api.thread
  • app.api.thread.create_thread
  • app.api.thread.create_thread_reply
  • app.api.thread.delete_thread
  • app.api.thread.delete_thread_reply
  • app.api.thread.get_thread
  • app.api.thread.list_threads
  • app.api.thread.model_post_init
  • app.api.thread.update_thread
  • app.api.thread.update_thread_follow
  • app.api.thread.update_thread_reply
  • app.api.thread.update_thread_seen
app.api.timeseries
  • app.api.timeseries.create_timeseries
  • app.api.timeseries.download_timeseries_range
  • app.api.timeseries.get_timeseries_last
  • app.api.timeseries.get_timeseries_range
  • app.api.timeseries.list_timeseries
  • app.api.timeseries.model_post_init
app.api.user
  • app.api.user.delete_shared_settings
  • app.api.user.delete_user_settings
  • app.api.user.get_shared_settings
  • app.api.user.get_user
  • app.api.user.get_user_me
  • app.api.user.get_user_settings
  • app.api.user.list_shared_settings
  • app.api.user.list_user_settings
  • app.api.user.list_users
  • app.api.user.model_post_init
  • app.api.user.update_shared_settings
  • app.api.user.update_user_settings
app.api.user_authorization
  • app.api.user_authorization.create_group
  • app.api.user_authorization.create_role
  • app.api.user_authorization.create_role_policy
  • app.api.user_authorization.delete_group
  • app.api.user_authorization.delete_role
  • app.api.user_authorization.delete_role_policy
  • app.api.user_authorization.get_group
  • app.api.user_authorization.get_role
  • app.api.user_authorization.get_role_policy
  • app.api.user_authorization.list_groups
  • app.api.user_authorization.list_role_policies
  • app.api.user_authorization.list_roles
  • app.api.user_authorization.model_post_init
  • app.api.user_authorization.update_group
  • app.api.user_authorization.update_role
  • app.api.user_authorization.update_role_policy