Skip to content

Examples

Example 1 - Start an event trigger and wait for the execution to finish

from tth.client import APIKeyClient


hub_address = "http://tth-address.cloud"
api_key_value = "apiKeyValue"
trigger_id = 1
trigger_parameters = {"parameter_name": "parameter_value"}

# create API Key client
client = APIKeyClient(hub_address, api_key_value)

# start event trigger
execution_id = client.trigger.start(trigger_id, trigger_parameters)

# obtain details of started execution
execution_info = client.execution.get_info(execution_id)
print(execution_info)

# obtain execution status
execution_status = client.execution.get_status(execution_id)
print(execution_status)

# wait for execution to finish
execution_status = client.execution.wait_until_finished(execution_id)
print(execution_status)

Example 2 - Upload a report and check report info

from tth.client import APIKeyClient


hub_address = "http://tth-address.cloud"
api_key_value = "apiKeyValue"

# create API Key client
client = APIKeyClient(hub_address, api_key_value)

# upload new report
allure_report_path = "location_to_allure_report"
execution_id = 1
report_id = client.report.upload_report(allure_report_path, execution_id)

# obtain details of uploaded report
report_data = client.report.get_info(report_id)
print(report_data)

Example 3 - Upload an artifact and download an artifact

from tth.client import APIKeyClient


hub_address = "http://tth-address.cloud"
api_key_value = "apiKeyValue"

# create API Key client
client = APIKeyClient(hub_address, api_key_value)

# upload new artifact
file_to_upload_path = "location_to_file"
artifact_id = client.artifact.upload_artifact(file_to_upload_path)

# download existing artifact
downloaded_file_name = "downloaded_file.txt"
downloaded_file_path = client.artifact.download_artifact(artifact_id, downloaded_file_name)
print(downloaded_file_path)