Splight Docs
  • Welcome
  • Getting Started
    • Get Your Keys
    • API Introduction
  • Resources
    • Alert
    • Asset
    • Component
    • Compute Node
    • Dashboard
    • File
    • Function
  • Settings
    • Account
    • Organization
    • Users
    • Authorization
    • Preferences
  • Guides
    • Invite User
    • First Asset
    • Lib Examples
Powered by GitBook
On this page
  • Creating a Folder
  • Reading a Folder
  • Deleting a Folder
  • Reading a File
  • Deleting a File

Was this helpful?

  1. Resources

File

Maybe some Component needs to store files, or some Component needs files as inputs...the Files section is the correct place in these scenarios. For example, let's say you connect a camera that is pointing to the sky, and then you deploy an algorithm that every 10 seconds calculates the probability of a big cloud showing over your solar panels. Say this Component outputs such probability and the cloud picture with annotations. Then you will see that image in the Files section. You may also create a Dashboard to see how that image changes over time in real-time. Last but not least, when you upload a file in this section you can choose to encrypt it to keep your data secure. This works in case of VPN transferred files, for example.


Creating a Folder

To create a folder you only need to specify the name of the folder and the id of the parent folder. The id of the parent folder is optional, and if not specified, the folder will be created in the root directory.

curl --request POST \
  --url https://api.splight.com/v3/engine/file/folders/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
  --header 'content-type: application/json' \
  --data '{
    "name": "<name>",
    "parent": "<parent_id>"
    }'
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key

url = "https://api.splight.com/v3/engine/file/folders/"

payload = {
    "name": "<name>",
    "parent": "<parent_id>"
}
headers = {
    'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
    "content-type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
print(response.status_code)  # Should return 201 for successful creation

Reading a Folder

Listing all Folders

To list all folders, you can use the following endpoint. This will return a list of all folders in your account.

curl --request GET \
  --url https://api.splight.com/v3/engine/file/folders/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key

url = "https://api.splight.com/v3/engine/file/folders/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 200 for successful retrieval

Retrive a single Folder

To retrieve a single folder, you can use the folder ID in the URL. This will return detailed information about that specific folder.

curl --request GET \
  --url https://api.splight.com/v3/engine/file/folders/<folder_id>/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
FOLDER_ID = "<folder_id>"  # Replace with your folder ID

url = f"https://api.splight.com/v3/engine/file/folders/{FOLDER_ID}/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 200 for successful retrieval

Deleting a Folder

To delete a folder, you can use the following endpoint. This will remove the specified folder from your account.

curl --request DELETE \
  --url https://api.splight.com/v3/engine/file/folders/<folder_id>/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
FOLDER_ID = "<folder_id>"  # Replace with your folder ID

url = f"https://api.splight.com/v3/engine/file/folders/{FOLDER_ID}/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.delete(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 204 for successful deletion

Reading a File

Listing all Files from a Folder

To list all files, you can use the following endpoint. This will return a list of all files in your account.

curl --request GET \
  --url https://api.splight.com/v3/engine/file/files/ \
  --header 'authorization: Splight <access_id> <secret_key>' \

import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key

url = "https://api.splight.com/v3/engine/file/files/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 200 for successful retrieval

Retrive a single File

To retrieve a single file, you can use the file ID in the URL. This will return detailed information about that specific file.

curl --request GET \
  --url https://api.splight.com/v3/engine/file/files/<file_id>/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
FILE_ID = "<file_id>"  # Replace with your file ID

url = f"https://api.splight.com/v3/engine/file/files/{FILE_ID}/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.get(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 200 for successful retrieval

Deleting a File

To delete a file, you can use the following endpoint. This will remove the specified file from your account.

curl --request DELETE \
  --url https://api.splight.com/v3/engine/file/files/<file_id>/ \
  --header 'authorization: Splight <access_id> <secret_key>' \
import requests

ACCESS_ID = "<user_access_id>"  # Replace with your access ID
SECRET_KEY = "<user_secret_key>"  # Replace with your secret key
FILE_ID = "<file_id>"  # Replace with your file ID

url = f"https://api.splight.com/v3/engine/file/files/{FILE_ID}/"
headers = {
        'authorization': f'Splight {ACCESS_ID} {SECRET_KEY}',
}

response = requests.delete(url, headers=headers)
print(response.json())
print(response.status_code)  # Should return 204 for successful deletion
PreviousDashboardNextFunction

Last updated 15 days ago

Was this helpful?