{"created":"created ID","description":"the description provided","files":"the number of the files in the datset","id":"dataset's ID","lastUsed":0,"name":"name of the dataset","sizeInBytes":"size of the dataset","state":"DATA_ASSET_STATE_DRAFT","tags":"the tags provided","custom_metadata":{k-v pairs}"type":"DATA_ASSET_TYPE_DATASET"}
{"created": 1633277005,"description": "a descriptive description","files": 0,"id": "fea84ebf-b58b-4ad2-994d-7169dc3880fb","last_used": 0,"name": "my dataset","size": 0,"state": "DATA_ASSET_STATE_DRAFT","tags": ["t1","t2" ],"custom_metadata":{"some Field":"one","another_field":1,"dateField":1676246400 },"type": "DATA_ASSET_TYPE_DATASET"}
Example of creating a new data asset:
Create a data asset from a computation (capture result API)
CURL Example
curl -H "Content-Type: application/json" -u ${CUSTOM_KEY}: -X POST https://acmecorp.codeocean.com/api/v1/data_assets --data-raw '{
"name": "Data asset From API",
"description": "An example for creating data asset from CO API",
"mount": "some-folder",
"tags": [ "keyword1", "keyword2" ],
"source": {
"computation": {
"id": "some-computation-id"
}
}
}'
To use this example, please change the domain to your VPC instead of acmecorp, change ${CUSTOM_KEY} to your API token, and replace some-computation-id with the computation id of the result you'd like to capture as a data asset.
Create a data asset from a public AWS bucket - no credentials are provided
To use this example, please change the domain to your VPC instead of acmecorp-edge, and change ${CUSTOM_KEY} to your API token.
Since this example is pulling a dataset from a private bucket, you will need to change the "aws" part accordingly.
Create data asset with custom fields
curl -H "Content-Type: application/json" -u USER_API_TOKEN: -X POST https://codeocean.com/api/v1/data_assets --data-raw '{
"name": "Data asset From API",
"description": "An example for creating data asset from CO API",
"mount": "some-folder",
"tags": [ "keyword1", "keyword2" ],
"custom_metadata":{
"some Field": "one",
"another_field": 1,
"dateField": 1676246400
},
"source": {
"computation": {
"id": "some-computation-id"
}
}
}'
The examples here are executed from a capsule that utilizes the secret management feature. The API token was added as "Custom Key" and the AWS credential was added as "AWS Cloud Credential"
{"created": float64 - data asset creation time,"description": string - data asset descriptionw description","files": int64 - total number of files in the data asset if available,"id": string - the data asset internal id,"lastUsed": float64 - the last time the data asset was used in seconds since epoch,"name": string - data asset name,"size": int64 - the total size in bytes of the data asset if available,"state": string - data asset state - draft / ready / failed,"tags": array of string tags,"custom_metadata": { k-v pairs },"type": string - dataset / result }
Example of updating data asset metadata:
Request Example
curl -X PUT 'https://acmecorp.codeocean/api/v1/data_assets/{data asset id}' \
-u \'${CUSTOM_KEY}:\' \
-H 'Content-Type: application/json' \
--data-raw '{
"name": "modified name",
"description": "a new description",
"tags": ["aaa","bbb","ccc"],
"mount": "newmount"
}'
To use this example, please change the domain to your VPC instead of acmecorp, and change ${CUSTOM_KEY} to your API token and the data asset's id accordingly.
To use this example, please change the domain to your VPC instead of acmecorp, change ${CUSTOM_KEY} to your API token, and replace {data-asset_id} with the id of the data asset you'd like to archive/unarchive.
A folder under the capsule data folder, where the data asset files are found.
tags*
array
Keywords to search the data asset by.
source*
String
Where the data asset originated. Currently only AWS is supported.
source.aws*
String
Describes the S3 bucket from which the data asset was created.
source.aws.access_key_id
String
The AWS key ID used to access the S3 bucket. Not required if it is a public S3 bucket.
source.aws.secret_access_key
String
The AWS secret access key ID used to access the S3 bucket. Not required if it is a public S3 bucket.
source.aws.bucket*
String
The S3 bucket from which the data asset will be created.
source.aws.prefix*
boolean
The folder in the S3 bucket from which the data asset is created. This is only relevant when copying the files over to Code Ocean (keep_on_external_storage=false).
source.aws.keep_on_External_storage*
boolean
When set to true, the data asset files will not be copied over to Code Ocean. The prefix property will be ignored and the entire S3 bucket will be used.
source.aws.index_data*
boolean
When this property is true Code Ocean will index the files in the remote bucket to display the file tree in the dataset and capsule pages. This is only relevant when keep_on_external_storage is set to true. When keep_on_external_storage is false Code Ocean will always index the files.
custom_metadata
NA
map of key value pairs, according to custom metadata fields defined by the admin.
possible values:
+ string custom field - string
+ number custom field - number
+ date custom field - number - unix (epoch) format timestamp in seconds
{domain}*
String
Your VPC domain
{data assets ID}*
String
The dataset ID that you want to get the metadata from
Authorization*
String
Basic ${API Token from Code Ocean}
{domain}*
String
Your VPC domain
start
int
describes the search from index
limit
int
sort_field
String
option: created/type/name/size
determines the field to sort by
sort_order
String
option: asc/desc
determines the result sort order. must be provided with sort_field, otherwise ignored
query
String
determines the search query. can be a free text or in the form of “name:... tag:... run_script:... commit_id:...”
type
String
option: dataset/result
if omitted results may include both datasets and results
ownership
String
option: owner/shared
search data asset by ownership
favorite
boolean
search only favorite data assets
archived
boolean
search only archived data assets
-u*
String
\ '${API Token from Code Ocean}:\' \
{domain}*
String
Your VPC domain
{data_set_id}*
String
Data Asset's id
-u*
String
\ '${API Token from Code Ocean}:\' \
name*
String
data asset name
description*
String
data asset description
tags
array
array of string tags
mount
String
default mount folder
custom_metadata
NA
map of key value pairs, according to custom metadata fields defined by the admin.
possible values:
+ string custom field - string
+ number custom field - number
+ date custom field - number - unix (epoch) format timestamp in seconds
{domain}*
String
Your VPC domain
{data_set_id}*
String
Data Asset's id
-u*
String
\ '${API Token from Code Ocean}:\' \
users
array
array of <email, role>
groups
array
array of <group name, role>
everyone
boolean
whether to share with everyone
{domain}*
String
Your VPC domain
{data_set_id}*
String
Data Asset's id
-u*
String
\ '${API Token from Code Ocean}:\' \
{domain}*
String
Your VPC domain
{data_set_id}*
String
Data Asset's id
archive*
Boolean
If true will archive a data asset. Otherwise will unarchive it.