Skip to content

TrimbleCloud.DataOcean3

Data Ocean SDK for Python. This SDK provides a set of APIs for managing files and directories in Data Ocean.

This package is available on Trimble Artifactory PyPI registry. You can install with pip:

Terminal window
pip install TrimbleCloud.DataOcean3
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
from TrimbleCloud.Authentication.OpenIdEndpointProvider import OpenIdEndpointProvider
from TrimbleCloud.Authentication.ClientCredentialTokenProvider import ClientCredentialTokenProvider
from TrimbleCloud.Authentication.BearerTokenHttpClientProvider import BearerTokenHttpClientProvider
from 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)

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"
}
})

The following example shows how to get a directory by its ID.

directory = await client.Directories.Read("directory_id")

The following example shows how to get a directory by its path.

directory = await client.Directories.ReadByPath("/path/to/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"
}
})

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"
}
})

The following example shows how to delete a directory by its ID.

await client.Directories.Delete("directory_id")

The following example shows how to delete a directory by its path.

await client.Directories.DeleteByPath("/path/to/directory")

The following example shows how to list directories.

directories = await client.Directories.GetDirectoriesList().GetItems()

The following example shows how to list directories by path.

directories = await client.Directories.GetDirectoriesListByPath("/path/to/directory").GetItems()

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()

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()

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"
}
})

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"
}
})

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
})

The following example shows how to get a file by its ID.

file = await client.Files.Read("file_id")

The following example shows how to get a file by its path.

file = await client.Files.ReadByPath("/path/to/file.txt")

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
})

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
})

The following example shows how to delete a file by its ID.

await client.Files.Delete("file_id")

The following example shows how to delete a file by its path.

await client.Files.DeleteByPath("/path/to/file.txt")

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
})

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
})

The following example shows how to request a scan for a file by its ID.

await client.Files.RequestScan("file_id")

The following example shows how to request a scan for a file by its path.

await client.Files.RequestScanByPath("/path/to/file.txt")

The following example shows how to get a fileset manifest for a file by its ID.

manifest = await client.Files.GetFilesetManifest("file_id")

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")

The following example shows how to get a file version list by its ID.

versions = await client.Files.GetVersionsList("file_id").GetItems()

The following example shows how to get a file version list by its path.

versions = await client.Files.GetVersionsListByPath("/path/to/file.txt").GetItems()