TrimbleCloud.DataOcean3
Data Ocean SDK for Python. This SDK provides a set of APIs for managing files and directories in Data Ocean.
Getting Started
Installation
This package is available on Trimble Artifactory PyPI registry.
You can install with pip:
pip install TrimbleCloud.DataOcean3Data Ocean Endpoints
| Environment | Base URL Endpoint |
|---|---|
| Stage | https://cloud.stage.api.trimblecloud.com/dataocean/api/3.0 |
| Production | https://cloud.api.trimble.com/dataocean/api/3.0 |
Usage
Create the client
from TrimbleCloud.Authentication.OpenIdEndpointProvider import OpenIdEndpointProviderfrom TrimbleCloud.Authentication.ClientCredentialTokenProvider import ClientCredentialTokenProviderfrom TrimbleCloud.Authentication.BearerTokenHttpClientProvider import BearerTokenHttpClientProviderfrom TrimbleCloud.DataOcean3.DataOcean3Client import DataOcean3Client
endpointProvider = OpenIdEndpointProvider("https://stage.id.trimblecloud.com/.well-known/openid-configuration")tokenProvider = ClientCredentialTokenProvider(endpointProvider, "client_id", "client_secret").with_scopes(["scope"])httpClientProvider = BearerTokenHttpClientProvider( tokenProvider, "https://cloud.stage.api.trimblecloud.com/dataocean/api/3.0")
client = DataOcean3Client(httpClientProvider)Get Started with Directories
Create a directory
The following example shows how to create a directory with the specified path and access control list (ACL). Please refer API reference for more details.
directory = await client.Directories.Create({ "path": "/path/to/directory", "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" } })Get a directory
The following example shows how to get a directory by its ID.
directory = await client.Directories.Read("directory_id")Get a directory by path
The following example shows how to get a directory by its path.
directory = await client.Directories.ReadByPath("/path/to/directory")Update a directory
The following example shows how to update a directory by its ID.
directory = await client.Directories.Update("directory_id", { "path": "/path/to/directory", "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" } })Update a directory by path
The following example shows how to update a directory by its path.
directory = await client.Directories.UpdateByPath("/path/to/directory", { "path": "/path/to/directory", "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" } })Delete a directory
The following example shows how to delete a directory by its ID.
await client.Directories.Delete("directory_id")Delete a directory by path
The following example shows how to delete a directory by its path.
await client.Directories.DeleteByPath("/path/to/directory")List directories
The following example shows how to list directories.
directories = await client.Directories.GetDirectoriesList().GetItems()List directories by path
The following example shows how to list directories by path.
directories = await client.Directories.GetDirectoriesListByPath("/path/to/directory").GetItems()Get File List
The following example shows how to get a list of files in a directory by its ID.
files = await client.Directories.GetFileList("directory_id").GetItems()Get File List by path
The following example shows how to get a list of files in a directory by its path.
files = await client.Directories.GetFileListByPath("/path/to/directory").GetItems()Copy a directory
The following example shows how to copy a directory by its ID.
directory = await client.Directories.Copy("directory_id", { "path": "/path/to/directory", "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" } })Copy a directory by path
The following example shows how to copy a directory by its path.
directory = await client.Directories.CopyByPath("/path/to/directory", { "path": "/path/to/directory", "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" } })Get Started with Files
Create a file
The following example shows how to create a file with the specified path and access control list (ACL). Please refer API reference for more details.
file = await client.Files.Create({ "path": "/path/to/file.txt", "restricted_access": true, "regions": [ "us1" ], "fileset": false, "path_template": "{country}/{city}.kml", "expires_at": null, "multipart": false, "response_headers": { "response-content-type": "image/jpeg", "response-content-disposition": "inline", "response-cache-control": "max-age=3000" }, "metadata": { "author": "Brandon Skari", "language": "Suomi" }, "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" }, "master_id": "b0cb3ba7-18e6-442e-b1d9-25d5fd3b41de" }, "response": { "brief": false })Get a file
The following example shows how to get a file by its ID.
file = await client.Files.Read("file_id")Get a file by path
The following example shows how to get a file by its path.
file = await client.Files.ReadByPath("/path/to/file.txt")Update a file
The following example shows how to update a file by its ID.
file = await client.Files.Update("file_id", { "path": "/path/to/file.txt", "restricted_access": true, "regions": [ "us1" ], "fileset": false, "path_template": "{country}/{city}.kml", "expires_at": null, "multipart": false, "response_headers": { "response-content-type": "image/jpeg", "response-content-disposition": "inline", "response-cache-control": "max-age=3000" }, "metadata": { "author": "Brandon Skari", "language": "Suomi" }, "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" }, "master_id": "b0cb3ba7-18e6-442e-b1d9-25d5fd3b41de" }, "response": { "brief": false })Update a file by path
The following example shows how to update a file by its path.
file = await client.Files.UpdateByPath("/path/to/file.txt", { "path": "/path/to/file.txt", "restricted_access": true, "regions": [ "us1" ], "fileset": false, "path_template": "{country}/{city}.kml", "expires_at": null, "multipart": false, "response_headers": { "response-content-type": "image/jpeg", "response-content-disposition": "inline", "response-cache-control": "max-age=3000" }, "metadata": { "author": "Brandon Skari", "language": "Suomi" }, "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" }, "master_id": "b0cb3ba7-18e6-442e-b1d9-25d5fd3b41de" }, "response": { "brief": false })Delete a file
The following example shows how to delete a file by its ID.
await client.Files.Delete("file_id")Delete a file by path
The following example shows how to delete a file by its path.
await client.Files.DeleteByPath("/path/to/file.txt")Copy a file
The following example shows how to copy a file by its ID.
file = await client.Files.Copy("file_id", { "path": "/path/to/file.txt", "restricted_access": true, "regions": [ "us1" ], "fileset": false, "path_template": "{country}/{city}.kml", "expires_at": null, "multipart": false, "response_headers": { "response-content-type": "image/jpeg", "response-content-disposition": "inline", "response-cache-control": "max-age=3000" }, "metadata": { "author": "Brandon Skari", "language": "Suomi" }, "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" }, "master_id": "b0cb3ba7-18e6-442e-b1d9-25d5fd3b41de" }, "response": { "brief": false })Copy a file by path
The following example shows how to copy a file by its path.
file = await client.Files.CopyByPath("/path/to/file.txt", { "path": "/path/to/file.txt", "restricted_access": true, "regions": [ "us1" ], "fileset": false, "path_template": "{country}/{city}.kml", "expires_at": null, "multipart": false, "response_headers": { "response-content-type": "image/jpeg", "response-content-disposition": "inline", "response-cache-control": "max-age=3000" }, "metadata": { "author": "Brandon Skari", "language": "Suomi" }, "acl": { "trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w", "trn:tid:user:6529d0b3-5856-41ab-88b3-86f7955cddf1": "r", "trn:tid:user:7529d0b3-5856-41ab-88b3-86f7955cddf1;trn:profilex:group:all_applications": "r", "trn:tid:device:8529d0b3-5856-41ab-88b3-86f7955cddf1;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "d", "trn:profilex:group:all_devices;trn:tid:application:f85bc802-5481-4581-b972-c4652d595ec7": "w" }, "master_id": "b0cb3ba7-18e6-442e-b1d9-25d5fd3b41de" }, "response": { "brief": false })Request Scan
The following example shows how to request a scan for a file by its ID.
await client.Files.RequestScan("file_id")Request Scan by path
The following example shows how to request a scan for a file by its path.
await client.Files.RequestScanByPath("/path/to/file.txt")Get Fileset Manifest
The following example shows how to get a fileset manifest for a file by its ID.
manifest = await client.Files.GetFilesetManifest("file_id")Get Fileset Manifest by path
The following example shows how to get a fileset manifest for a file by its path.
manifest = await client.Files.GetFilesetManifestByPath("/path/to/file.txt")Get File version list
The following example shows how to get a file version list by its ID.
versions = await client.Files.GetVersionsList("file_id").GetItems()Get File version list by path
The following example shows how to get a file version list by its path.
versions = await client.Files.GetVersionsListByPath("/path/to/file.txt").GetItems()