Services

The services module provides core service implementations for the CLI, including authentication, session management, Docker integration, and more.

Exceptions

Custom exceptions used throughout the SDK.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

exception kelvin.sdk.lib.exceptions.KSDKException(message='')[source]

Bases: Exception

Base KSDK Exception

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.KSDKFatal(message='')[source]

Bases: KSDKException

Raised when a fatal error occurs and the program cannot continue.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.AppException(message='')[source]

Bases: KSDKException

Raised when the a generic process fails.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.AppNameIsInvalid(message='')[source]

Bases: KSDKException

Raised when the provided application name is not valid (either a tuple or a different type)

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.KDockerException(message='')[source]

Bases: KSDKException

Raised when there is an issue with Docker.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.DependencyNotRunning(message='')[source]

Bases: KSDKException

Raised when a dependency is not running.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.DependencyNotInstalled(message='')[source]

Bases: KSDKException

Raised when a dependency is not installed.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.DataTypeException(message='')[source]

Bases: KSDKException

Raised when a process related to Datatype fails.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.DataTypeNameIsInvalid(message='')[source]

Bases: KSDKException

Raised when the provided datatype name is not valid (either a tuple or a different type)

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.EmulationException(message='')[source]

Bases: KSDKException

Raised when an Emulation process fails.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.InvalidBaseImageException(registry_url, docker_image_name)[source]

Bases: KSDKException

Raised when the provided docker image is not valid/supported by the current system.

Parameters:
  • registry_url (str)

  • docker_image_name (str)

exception kelvin.sdk.lib.exceptions.InvalidApplicationConfiguration(message='')[source]

Bases: KSDKException

Raised when the provided application configuration is not valid.

Parameters:

message (str)

exception kelvin.sdk.lib.exceptions.MandatoryConfigurationsException(validation_error, message=None)[source]

Bases: KSDKException

Raised when a mandatory configuration is missing from the metadata.

Parameters:
  • validation_error (ValidationError | None)

  • message (str | None)

exception kelvin.sdk.lib.exceptions.InvalidSchemaVersionException(min_version, current_version, latest_version)[source]

Bases: KSDKException

Raised when the schema version does not match the pre-established values.

Parameters:
  • min_version (str)

  • current_version (str)

  • latest_version (str)

exception kelvin.sdk.lib.exceptions.MissingTTYException(message='')[source]

Bases: KSDKException

Raised when tty interaction is not available

Parameters:

message (str)

Authentication

Credential Manager

Manages user credentials and secure storage.

class kelvin.sdk.lib.auth.credential_storage.TokenCredentials(access_token, access_expires_at, refresh_token=None, refresh_expires_at=None)[source]

Bases: object

Parameters:
  • access_token (str)

  • access_expires_at (int)

  • refresh_token (str | None)

  • refresh_expires_at (int | None)

access_token: str
access_expires_at: int
refresh_token: str | None = None
refresh_expires_at: int | None = None
class kelvin.sdk.lib.auth.credential_storage.CredentialStorage[source]

Bases: object

KEYRING_SERVICE_NAME = 'kelvin:kelvin-sdk'
EXPIRATION_THRESHOLD = 60
store_credentials(url, oauth_tokens)[source]

Store OAuth tokens in keyring.

Return type:

TokenCredentials

Parameters:

Parameters

urlstr

The platform URL to associate with these credentials

oauth_tokensDict

OAuth token response containing access_token, expires_in, refresh_token, refresh_expires_in, etc.

retrieve_credentials(url)[source]

Retrieve OAuth tokens from keyring.

Return type:

Optional[TokenCredentials]

Parameters:

url (str)

Parameters

urlstr

The platform URL to retrieve credentials for

Returns

Optional[TokenCredentials]

TokenCredentials object if found, None otherwise

clear_credentials(url)[source]

Clear stored OAuth credentials for a specific URL.

Return type:

None

Parameters:

url (str)

Parameters

urlstr

The platform URL to clear credentials for

Session

Session Manager

Manages user sessions and API client connections.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.session.session_manager.Singleton[source]

Bases: type

class kelvin.sdk.lib.session.session_manager.Server(request, client_address, server)[source]

Bases: BaseHTTPRequestHandler

log_message(format, *args)[source]

Log an arbitrary message.

This is used by all other logging functions. Override it if you have specific logging wishes.

The first argument, FORMAT, is a format string for the message to be logged. If the format string contains any % escapes requiring parameters, they should be specified as subsequent arguments (it’s just like printf!).

The client ip and current date/time are prefixed to every message.

Unicode control characters are replaced with escaped hex before writing the output to stderr.

Return type:

None

Parameters:
do_GET()[source]
Return type:

None

class kelvin.sdk.lib.session.session_manager.SessionManager[source]

Bases: object

Parameters:
auth_code: str | None = None
reset_session(full_reset=False, ignore_destructive_warning=False)[source]

Logs off the client all currently stored sessions.

Return type:

OperationResponse

Parameters:
  • full_reset (bool)

  • ignore_destructive_warning (bool)

Parameters

full_reset: bool, default=False

Indicates whether it should proceed with a full reset.

ignore_destructive_warning: bool, default=False

Ignore_destructive_warning: indicates whether it should ignore the destructive warning.

Returns

OperationResponse

An OperationResponse object encapsulating the result of the logout request.

reset_session_tokens(url=None)[source]

Reset stored tokens for the specified url.

Return type:

None

Parameters:

url (str | None)

Parameters

url: str, optional

The url to reset tokens for. If None, resets tokens for the current session.

logout_from_url(url=None)[source]

Logout from the specified url.

Return type:

None

Parameters:

url (str | None)

Parameters

url: str, optional

The url to logout from. If None, logs out from the current session.

full_reset(ignore_destructive_warning=False)[source]

Reset all configurations & cache used by Kelvin SDK.

Return type:

OperationResponse

Parameters:

ignore_destructive_warning (bool)

Parameters

ignore_destructive_warningbool

indicates whether or not the command should bypass the destructive prompt warning.

Returns

OperationResponse

an OperationResponse encapsulating the result of the reset operation.

browser_login(url)[source]
Return type:

OperationResponse

Parameters:

url (str)

login_with_stored_credentials(url)[source]

Logs the user into the provided url using stored credentials.

Return type:

bool

Parameters:

url (str)

Parameters

url: str

The url to log on.

Returns

bool

True if login was successful, False otherwise.

login_on_url(url, username=None, password=None, totp=None, client_id=None, client_secret=None, reset=False)[source]

Logs the user into the provided url.

Return type:

OperationResponse

Parameters:
  • url (str)

  • username (str | None)

  • password (str | None)

  • totp (str | None)

  • client_id (str | None)

  • client_secret (str | None)

  • reset (bool)

Parameters

url: str, optional

The url to log on.

username: str, optional

The username of the client site.

password: str, optional

The password corresponding to the username.

browser: bool, default=False

If set, opens a browser window to proceed with the authentication.

reset: bool, default=False

If set to True, will clear the existing configuration prior to the new session.

Returns

OperationResponse

An OperationResponse object encapsulating the result of the authentication request.

login_client_on_current_url(verbose=True)[source]

Login process

Return type:

Client

Parameters:

verbose (bool)

check_token_expiration(url, tokens)[source]

Check if the token is expired and refresh if needed.

Return type:

TokenCredentials

Parameters:

Parameters

url: str

The platform URL.

tokens: TokenCredentials

The current token credentials.

authentication_token(full, margin=10.0)[source]

Obtain an authentication authentication_token from the API.

Return type:

OperationResponse

Parameters:
get_global_ksdk_configuration()[source]

Attempt to retrieve the KelvinSDKGlobalConfiguration from specified file path.

Return type:

KelvinSDKGlobalConfiguration

Returns

KelvinSDKGlobalConfiguration

A KelvinSDKGlobalConfiguration object corresponding to the current configuration.

Retrieve, if existent, the complete url to the documentation page.

Return type:

Optional[str]

get_kelvin_system_information_for_display()[source]

Display system information as well as, if existent, the current session’s url.

Return type:

str

get_kelvin_system_information()[source]

Report the entire configuration set currently in use by Kelvin SDK.

Return type:

dict

get_docker_current_url()[source]
Return type:

str

get_current_session_metadata()[source]

Returns the current session company metadata

Return type:

CompanyMetadata

refresh_metadata(url)[source]

Refresh metadata on request.

Return type:

SyncMetadata

Parameters:

url (str)

setup_logger(verbose=False, colored_logs=True)[source]

Sets up the logger based on the verbose flag.

Return type:

Any

Parameters:

Parameters

verbosebool

the flag indicating whether it should setup the logger in verbose mode.

colored_logs: bool, Default=False

Indicates whether all logs should be colored and ‘pretty’ formatted.

Returns

Any

the setup logger.

global_configuration_list(should_display=False)[source]

List all available configurations for the Kelvin-SDK

Return type:

OperationResponse

Parameters:

should_display (bool)

Parameters

should_display: bool, default=True

specifies whether or not the display should output data.

Returns

OperationResponse

An OperationResponse object encapsulating the yielded Kelvin tool configurations.

global_configuration_set(configuration, value)[source]

Set the specified configuration on the platform system.

Return type:

OperationResponse

Parameters:
  • configuration (str)

  • value (str)

Parameters

configuration: str

the configuration to change.

value: str

the value that corresponds to the provided configuration.

Returns

OperationResponse

An OperationResponse object encapsulating the result the configuration set operation.

global_configuration_unset(configuration)[source]

Unset the specified configuration from the platform system

Return type:

OperationResponse

Parameters:

configuration (str)

Parameters

configuration: str

the configuration to unset.

Returns

OperationResponse

an OperationResponse object encapsulating the result the configuration unset operation.

Session Storage

Persistent storage for session data.

class kelvin.sdk.lib.session.session_storage.SessionConfig(**data)[source]

Bases: KSDKModel

Parameters:
  • url (str | None)

  • ksdk_minimum_version (str | None)

  • ksdk_latest_version (str | None)

  • last_login (datetime | None)

  • docker_minimum_version (str | None)

  • docker_url (str | None)

  • docker_port (int | None)

  • extra_data (Any)

class Config[source]

Bases: object

extra = 'allow'
url: str | None
ksdk_minimum_version: str | None
ksdk_latest_version: str | None
last_login: datetime | None
docker_minimum_version: str | None
docker_url: str | None
docker_port: int | None
kelvin.sdk.lib.session.session_storage.session_config_from_metadata(metadata_json)[source]
Return type:

SessionConfig

Parameters:

metadata_json (dict)

kelvin.sdk.lib.session.session_storage.store_session(session_conf)[source]

Store session configuration

Return type:

None

Parameters:

session_conf (SessionConfig)

kelvin.sdk.lib.session.session_storage.load_session()[source]

Load session configuration

Return type:

Optional[SessionConfig]

kelvin.sdk.lib.session.session_storage.clear_session()[source]

Clear session configuration

Return type:

None

kelvin.sdk.lib.session.session_storage.store_metadata(metadata_json)[source]

Store metadata configuration

Return type:

None

Parameters:

metadata_json (dict)

kelvin.sdk.lib.session.session_storage.load_metadata()[source]

Load metadata configuration

Return type:

Optional[dict]

kelvin.sdk.lib.session.session_storage.clear_metadata()[source]

Clear metadata configuration

Return type:

None

Session Utilities

Helper functions for session management.

kelvin.sdk.lib.session.session_utils.warn_ksdk_version(session_conf)[source]
Return type:

None

Parameters:

session_conf (SessionConfig)

Docker

Docker Manager

Manages Docker operations for building and pushing application images.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

class kelvin.sdk.lib.docker.docker_manager.DockerManager[source]

Bases: object

login_to_docker_registry(registry_url, username, password)[source]
Return type:

None

Parameters:
  • registry_url (str)

  • username (str)

  • password (str)

static build_kelvin_app_dockerfile(kelvin_app_building_object)[source]

Build the docker file used in the creation of the docker image.

Return type:

bool

Parameters:

kelvin_app_building_object (KelvinAppBuildingObject)

Parameters

kelvin_app_building_objectKelvinAppBuildingObject

the KelvinAppBuildingObject with all the required variables to build an app.

Returns

bool

a boolean indicating whether the dockerfile was successfully built.

get_docker_images(labels=None, image_ids=None, image_parent_ids=None, image_names=None)[source]

Obtain a list of all docker images available in the system.

This image list can be narrowed down by using labels or an image name. By default, includes the standard: {‘source’: ‘ksdk’} labels.

Return type:

List[DockerImage]

Parameters:

Parameters

image_namesOptional[List[str]]

the names of the docker images to filter.

image_idsOptional[List[str]]

the ids of the docker images to filter.

image_parent_idsOptional[List[str]]
the ids of the parents

to filter.

labelsOptional[dict]

the labels used to selectively get containers.

Returns

List[DockerImage]

a list of DockerImage items.

build_kelvin_app_docker_image(kelvin_app_building_object)[source]

Build the docker image from the provided KelvinAppBuildingObject.

An exception is expected should any step of the process fail.

Return type:

bool

Parameters:

kelvin_app_building_object (KelvinAppBuildingObject)

Parameters

kelvin_app_building_objectKelvinAppBuildingObject

an object that contains the necessary variables to build a kelvin-type app.

Returns

bool

a boolean indicating whether the image was successfully built

build_docker_app_image(docker_build_object)[source]

Build the docker image from the provided DockerAppBuildingObject.

An exception is expected should any step of the process fail.

Return type:

bool

Parameters:

docker_build_object (DockerAppBuildingObject)

Parameters

docker_build_objectDockerAppBuildingObject

an object that contains the necessary variables to build a docker-type app.

Returns

bool

a boolean indicating whether the image was successfully built.

build_kelvin_v2_app_image(build_object)[source]

Build the docker image from the provided DockerAppBuildingObject.

An exception is expected should any step of the process fail.

Return type:

bool

Parameters:

build_object (ProjectBuildingObject)

Parameters

docker_build_objectDockerAppBuildingObject

an object that contains the necessary variables to build a docker-type app.

Returns

bool

a boolean indicating whether the image was successfully built.

ensure_docker_image_exists(docker_image)[source]

Using the base logged client, ensure that the provided image is valid either in the currently logged registry or the in the public one (DockerHub).

Return type:

str

Parameters:

docker_image (str)

Parameters

docker_imagestr

the docker image to be checked and downloaded.

Returns

str

a boolean indicating whether the images are valid in the currently logged registry or the public one.

pull_docker_image_from_registry(docker_image_name, auth_config=None, tag_local_name=False)[source]

Pull the specified docker image from the currently logged registry.

Return type:

str

Parameters:

Parameters

docker_image_nameDockerImageName

the name of the docker image to pull.

auth_configOptional[dict]

if set, will indicate whether the pulled image should be pulled from a public registry.

Returns

str

the name of the docker image pulled from the remote registry.

remove_docker_image(docker_image_name)[source]

Remove the specified docker image from the local system.

Raise an exception if the docker image was not successfully removed.

Return type:

bool

Parameters:

docker_image_name (str)

Parameters

docker_image_namestr

the name of the docker image to be removed.

Returns

bool

a boolean indicating whether the image was successfully removed.

prune_docker_images(filters=None)[source]

A simple wrapper around the client to prune dangling docker images.

Return type:

bool

Parameters:

filters (dict | None)

Parameters

filtersdict

the keywords used to filter out the prune operation.

Returns

bool

a bool indicating the images were successfully pruned.

check_if_docker_image_exists(docker_image_name, silent=False, raise_exception=False)[source]

Check whether the specified docker image exists on the local system.

Return type:

bool

Parameters:
  • docker_image_name (str)

  • silent (bool)

  • raise_exception (bool)

Parameters

docker_image_namestr

the name of the docker image to be checked.

silentbool

indicates whether logs should be displayed.

raise_exceptionbool

indicates whether or not it should raise if the provided image is not found.

Returns

bool

a boolean indicating whether the image exists on the local docker list.

extract_dir_from_docker_image(app_name, output_dir, container_dir='/opt/kelvin/app')[source]

Extract the content of the specified built application to the provided output directory.

Return type:

bool

Parameters:
  • app_name (str)

  • output_dir (str)

  • container_dir (str)

Parameters

app_namestr

the name of the application to unpack.

container_dir: str

The directory to extract from the container.

output_dir: str

the output directory to output the extracted content.

clean_dirstr

clean the directory before extracting into it.

Returns

a boolean flag indicating the image was successfully unpacked.

get_docker_containers(target_all_containers=False, image_names=None, container_names=None, labels=None)[source]

Obtain a list of all docker containers available in the system.

This image list can be narrowed down by using labels or an image name. By default, includes the standard: {‘source’: ‘ksdk’} labels.

Return type:

List[DockerContainer]

Parameters:
  • target_all_containers (bool)

  • image_names (List[str] | None)

  • container_names (List[str] | None)

  • labels (dict | None)

Parameters

target_all_containersbool

if set to ‘True’, will target all containers, running or stopped alike.

image_namesOptional[List[str]]

the name of the docker image to filters the containers.

container_namesOptional[List[str]]

the name of the docker container to filter.

labelsOptional[dict]

the labels used to selectively get containers.

Returns

List[DockerContainer]

a list of DockerContainer items.

stop_containers(container_names=None, image_names=None)[source]

Internal function for stopping containers by either container name or image name.

Return type:

bool

Parameters:

Parameters

container_namesOptional[List[str]]

the name of the docker container to filter.

image_namesOptional[List[str]]

the name of the docker image to filters the containers.

Returns

bool

a bool indicating whether the container(s) was(were) successfully stopped

remove_container(container_name)[source]

Remove the provided container from the system.

Return type:

bool

Parameters:

container_name (str)

Parameters

container_namestr

the id of the container to be removed.

Returns

bool

a default boolean indicating the container was successfully removed.

prune_docker_containers(filters=None)[source]

A simple wrapper around the client to prune dangling docker containers.

Return type:

bool

Parameters:

filters (dict | None)

Parameters

filtersdict

the keywords used to filter out the prune operation.

Returns

bool

a symbolic return flag.

kelvin.sdk.lib.docker.docker_manager.get_docker_manager()[source]
Return type:

DockerManager

Docker Utilities

Helper functions for Docker operations.

kelvin.sdk.lib.docker.docker_utils.display_docker_progress(stream)[source]

When provided with a docker stream generator, display the overall progress of all layer involved.

Return type:

bool

Parameters:

stream (Generator)

Parameters

stream: Generator

a docker stream generator that outputs every entry of the process

Returns

bool

Return a bool indicating all progress info has been successfully displayed

kelvin.sdk.lib.docker.docker_utils.process_docker_image_progress_entry(entry)[source]

Print the docker image push progress entry from its rightful dict.

Return type:

List[DockerProgressEntry]

Parameters:

entry (bytes)

Parameters

entry: bytes

A dictionary containing the docker image progress entry.

Returns

List[DockerProgressEntry]

A list of docker progress entries the result of the processed entry object.

kelvin.sdk.lib.docker.docker_utils.process_docker_entry(entry)[source]

Print the datatype compilation entry from its raw string.

Return type:

str

Parameters:

entry (bytes)

Parameters

entry: bytes

A byte string containing the datatype compilation entry.

Returns

str

A string containing the result of the processed entry object.

kelvin.sdk.lib.docker.docker_utils.ensure_docker_is_running(function)[source]
Return type:

Any

Parameters:

function (Any)

kelvin.sdk.lib.docker.docker_utils.assess_docker_connection_exception(exc)[source]

Parse the provided exception and return a ‘pretty’ docker exception.

Return type:

KDockerException

Parameters:

exc (Exception)

Parameters

exc: Exception

the exception to verify.

Returns

Exception

an exception with the adequate result.

Apps

Local Apps Manager

Manages local application projects and builds.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

kelvin.sdk.lib.apps.local_apps_manager.app_create_from_parameters(app_dir, app_name, app_description, app_type, app_flavour, kelvin_app_lang)[source]

The entry point for the creation of an application. (Parameters)

  • Creates the directory that will contain the app app.

  • Creates all necessary base files for the development of the app.

Parameters

app_dir: str

the app’s targeted dir. Will contain all the application files.

app_name: str, optional

the name of the new app.

app_description: str, optional

the description of the new app.

app_type: ProjectType, optional

the type of the new application. # E.g. ‘docker’, ‘kelvin’.

app_flavour: ApplicationFlavour, optional

the flavour of the new application. # E.g. ‘default’, ‘injector’, ‘extractor’.

kelvin_app_lang: ApplicationLanguage, optional

the language the new app will be written on. For kelvin apps only. # E.g. python.

Returns

OperationResponse

an OperationResponse object wrapping the result of the creation of the application.

rtype:

OperationResponse

Parameters:
Return type:

OperationResponse

kelvin.sdk.lib.apps.local_apps_manager.project_create(project_creation_parameters)[source]

The entry point for the creation of an application. (Parameters)

  • Creates the directory that will contain the app app.

  • Creates all necessary base files for the development of the app.

Parameters

project_creation_parameters: ProjectCreationParametersObject

the object containing all the required variables for App creation.

Returns

OperationResponse

an OperationResponse object wrapping the result of the creation of the application.

rtype:

OperationResponse

Parameters:

project_creation_parameters (ProjectCreationParametersObject)

Return type:

OperationResponse

kelvin.sdk.lib.apps.local_apps_manager.legacy_project_build(build_obj)[source]
Return type:

OperationResponse

Parameters:

build_obj (ProjectBuildingObject)

kelvin.sdk.lib.apps.local_apps_manager.project_build(app_dir, fresh_build=False, build_for_upload=False, docker_registry='', archs=[], build_args={}, app_config_obj=None, skip_schema_validation=False)[source]

The entry point for the building of an application.

Attempts to read the application content

Return type:

OperationResponse

Parameters:
  • app_dir (str)

  • fresh_build (bool)

  • build_for_upload (bool)

  • docker_registry (str)

  • archs (List[str])

  • build_args (Dict[str, str])

  • app_config_obj (AppConfigObj | None)

  • skip_schema_validation (bool)

Parameters

app_dirstr

The path where the application is hosted.

fresh_buildbool

If specified, will remove any cache and rebuild the application from scratch.

build_for_uploadbool

Indicates whether the package object aims for an upload.

docker_registry: str

The docker registry to push the image to.

archsList[str]

A list of architectures to build for.

build_args: Dict[str, str]

Build arguments to pass to the docker build command.

skip_schema_validation: bool

If specified, will skip schema validation during the build process.

Returns

OperationResponse

An OperationResponse object wrapping the result of the application build process.

kelvin.sdk.lib.apps.local_apps_manager.app_image_unpack(app_name_with_version, output_dir, container_dir=None)[source]

Extract the content of an image into a target directory.

Return type:

OperationResponse

Parameters:
  • app_name_with_version (str)

  • output_dir (str)

  • container_dir (str | None)

Parameters

app_name_with_version: str

the name of the image to unpack the app from.

container_dir: str

The directory to extract from the container.

output_dir: str

the output directory to output the extracted content.

Returns

OperationResponse

an OperationResponse object wrapping the result of the image extraction operation.

kelvin.sdk.lib.apps.local_apps_manager.app_config(app_config_file_path)[source]

Yields the loaded json/dict for the provided configuration file path. (Parameters)

Return type:

OperationResponse

Parameters:

app_config_file_path (str)

Parameters

app_config_file_path: str

the object containing all the required variables for App creation.

Returns

kelvin.sdk.lib.models.operation.OperationResponse

an OperationResponse object wrapping the json of the app configuration file.

kelvin.sdk.lib.apps.local_apps_manager.app_image_remove(app_name_with_version)[source]

Remove the specified application from the existing image list (in the docker instance).

Return type:

OperationResponse

Parameters:

app_name_with_version (str)

Parameters

app_name_with_version: str

the app to be removed. Must include the version.

Returns

OperationResponse

an OperationResponse object wrapping the result of the application image removal operation.

kelvin.sdk.lib.apps.local_apps_manager.get_local_appregistry_images(should_display=False)[source]

Retrieve the list of all application images available on the local registry.

Return type:

OperationResponse

Parameters:

should_display (bool)

Parameters

should_display: bool

specifies whether or not output data should be displayed.

Returns

kelvin.sdk.lib.models.operation.OperationResponse

an OperationResponse object wrapping the app images available on the local registry.

Schema

Schema Manager

Manages application schema validation and generation.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

kelvin.sdk.lib.schema.schema_manager.generate_base_schema_template(project_creation_parameters_object)[source]

Generate the base schema template. Attempt to retrieve the latest schema version and generate the default from it.

Return type:

dict

Parameters:

project_creation_parameters_object (ProjectCreationParametersObject)

Parameters

project_creation_parameters_objectProjectCreationParametersObject

the app creation parameters object used to generate the default schema.

Returns

dict

A dict containing the default app creation object.

kelvin.sdk.lib.schema.schema_manager.build_kelvin_app_block(project_creation_parameters_object)[source]

Creates the app configuration for the kelvin apps

Return type:

dict

Parameters:

project_creation_parameters_object (ProjectCreationParametersObject)

Parameters

project_creation_parameters_objectProjectCreationParametersObject

the app creation parameters object used to generate the default schema.

Returns

dict

The schema app block for kelvin apps

kelvin.sdk.lib.schema.schema_manager.validate_app_schema_from_app_config_file(app_config=None, app_config_file_path=None)[source]

When provided with an app configuration file, retrieve the schema for that version and validate it. Fetches schema on-demand without caching.

Return type:

bool

Parameters:
  • app_config (Dict | None)

  • app_config_file_path (KPath | None)

Parameters

app_configOptional[Dict]

the alternative app configuration to the app_config_file_path.

app_config_file_pathOptional[KPath]

the path to the app configuration.

Returns

bool

A boolean indicating whether or not the schema complies with the provided spec.

kelvin.sdk.lib.schema.schema_manager.schema_validate(file_path, schema_file_path, full_schema_errors=True)[source]

Validate a file against a schema.

Return type:

OperationResponse

Parameters:
  • file_path (str)

  • schema_file_path (str | None)

  • full_schema_errors (bool)

Parameters

file_pathstr

The path to the file to validate.

schema_file_pathOptional[str]

The path to the schema file to validate the file against.

full_schema_errorsbool

Indicates whether or not it should log the complete stack trace.

Returns

OperationResponse

an OperationResponse object encapsulating the result of the file schema validation.

kelvin.sdk.lib.schema.schema_manager.schema_get(schema_file_path=None)[source]

Yield the the content of a schema.

Return type:

OperationResponse

Parameters:

schema_file_path (str | None)

Parameters

schema_file_pathOptional[str]

The path to the schema file to yield.

Returns

OperationResponse

an OperationResponse object encapsulating the result of the file schema validation.

kelvin.sdk.lib.schema.schema_manager.get_latest_app_schema_version()[source]

Retrieve the latest app schema version and persist it to the configured schema directory.

Return type:

Tuple[str, dict, KPath]

Returns

A Tuple containing:
  1. latest spec version

  2. the corresponding schema

  3. the path to the persisted schema.

System Report

System Report Manager

Generates system reports and diagnostics information.

Copyright 2021 Kelvin Inc.

Licensed under the Kelvin Inc. Developer SDK License Agreement (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.kelvininc.com/developer-sdk-license

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

kelvin.sdk.lib.system_report.system_report_manager.kelvin_support_report(app_config, report_file=None, generate_report_file=True)[source]

Report the user’s system information and log records for support purposes.

Return type:

OperationResponse

Parameters:
  • app_config (str | None)

  • report_file (KPath | None)

  • generate_report_file (bool)

Parameters

app_config: Optional[str]

the path to the application’s configuration file.

report_file: Optional[KPath]

the path to the desired output report file.

generate_report_file: bool

if set to true, will generate the report file to the default location.

Returns

OperationResponse:

an OperationResponse object encapsulating the host machine’s system report.

kelvin.sdk.lib.system_report.system_report_manager.kelvin_system_information(display=True, log_type=LogType.KSDK)[source]

Report the entire configuration set currently in use by Kelvin SDK.

Return type:

OperationResponse

Parameters:

Parameters

displaybool

indicates whether the information should be logged

log_typeLogType

the output log type of the output type. Applicable only if ‘display’ is true and for display purposes.

Returns

kelvin.sdk.lib.models.operation.OperationResponse

an OperationResponse object encapsulating provided system information and the currently logged platform.