Skip to main content
Version: 1.5.1

Methods

Instantiation

SdkAPI

Create a new Spire Linux Agent Client.

from oort_sdk_client import SdkApi

agent = SdkApi()

SendFile

Sends a file from the payload to the ground via the API.

from oort_sdk_client.models import SendFileRequest, RetrieveFileRequest

req = SendFileRequest(
destination="ground",
topic="my-topic",
filepath="/path/to/file")
resp = agent.send_file(req)

print("File sent successfully, UUID is {}".format(resp.uuid)))

Arguments

TypeDescription
SendFileRequestSendFileRequest Object

Return value

TypeDescription
SendFileResponseContains the UUID assigned for this file transfer

QueryAvailableFiles

Queries files that have been uplinked from the ground to the payload.

from oort_sdk_client import SdkApi

agent = SdkApi()

topic = "my-topic"

available = agent.query_available_files(topic)

for item in available.files:
print("Available file: {item.id} -- {item.path}".format(item=item))

Arguments

TypeDescription
stringThe topic to check for available files.

Return value

TypeDescription
AvailableFilesResponseAvailableFilesResponse Object

RetrieveFile

Retrieve a file returned from QueryAvailableFiles

import os

from oort_sdk_client import SdkApi
from oort_sdk_client.models import RetrieveFileRequest

agent = SdkApi()

topic = "my-topic"

# download files that are available in the agent's inbox. Please note that this is not production-level code, and is
# typically done as part of the signaling configure step. Please refer to the examples in the customer documentation that
# has been provided separely
available_files = agent.query_available_files(topic).files
if not available.files:
print("No files available for retreival")
for new_file_info in available_files:
# Delivery Hints are set when uploading a file through the Tasking API
dest_path = new_file_info.delivery_hints.dest_path
mode = int(f"0o{new_file_info.delivery_hints.mode}", 8)
print(f"Retrieving {new_file.id} in {dest_path}")

# The oort agent will not create intermediate directories when extracting a file, so we need to create them ourselves
os.makedirs(os.path.dirname(dest_path), mode=0o755, exist_ok=True)

req = RetrieveFileRequest(
id=new_file_info.id,
save_path=dest_path)
rfinfo = agent.retrieve_file(req)

# We will set the file mode based on the delivery hints
os.chmod(dest_path, mode)

Retrieve an available file from the Data Pipeline API.

Arguments

TypeDescription
RetrieveFileRequestRetrieveFileRequest Object

Return value

TypeDescription
FileInfoDetails about the file retrieved