the time this Data Asset was last used in seconds from unix epoch.
name -
string
name of the Data Asset
size
string
the size in bytes of the Data Asset.
state
boolean
the Data Asset creation state
DATA_ASSET_STATE_DRAFT
the Data Asset is still being created.
DATA_ASSET_STATE_READY
the Data Asset is ready to use.
DATA_ASSET_STATE_FAILED
the Data Asset creation failed
source_bucket
information on bucket from which Data Asset was created.
bucket
the original buckets name
origin
aws/local/gcp
prefix
the folder in the s3 bucket from which the Data Asset would be created.
tags
keywords for searching the Data Asset by.
type
the type of the Data Asset.
DATA_ASSET_TYPE_DATASET
DATA_ASSET_TYPE_RESULT
custom_metadata
map of key value pairs, according to custom metadata fields defined by the admin and values that were set by the user.
provenance
shows the Data Asset provenance, only relevant for kind = result.
commit
the commit the Data Asset was created from with.
runScript
the script the Data Asset was created by.
DataAssets
datasets that was used to create the Data Asset.
DockerImage
the docker image used to create the Data Asset.
Capsule
the Capsule used to create the Data Asset.
app_parameters
the list of command-line arguments and their names provided to the Capsule run script in the related computation.
items
name
parameter name
value
parameter value
Create Data Asset
POSThttps://{domain}/api/v1/data_assets
This API allows for the creation of data assets from either an S3 bucket or the results of a computation.
Prerequisite
Before using this API call, you may require AWS Cloud Credentials configured as Secrets or an Assumable Role.
Path Parameters
Name
Type
Description
POST*
/datasets
Headers
Name
Type
Description
-u:*
Authorize with Code Ocean API Secret: -u $API_SECRET :
This is setting the "Authorization Basic" base64string header
-H*
Set this to: Content - Type: application/json
--data-raw *
JSON data with new or updated permission
Request Body
Name
Type
Description
name*
string
data asset name
description*
string
data asset description
mount*
string
data asset default mount folder
tags*
list/string
keywords for searching the data asset by
Custom Metadata
map of key value pairs, according to custom metadata fields defined by the admin, possible values:
- custom field: string
- custom field: number
- custom field: date
source*
aws*
Bucket*
the S3 bucket from which the data asset would be created
- bucket name
Prefix*
the folder in the S3 bucket from which the data asset would be created
- directory path
Keep_on_external_storage*
boolean
when this property is set to true an External Data Asset will be created. When this property is set to false or excluded, the data asset files are copied into Code Ocean and an Internal Data Asset is created.
Public*
boolean
when this property is set to true, CO will try to access the source bucket without credentials
computation
id
string
computation ID
path
string
path to a folder in Results, leave empty to capture all files
Target
aws
Bucket
Prefix
The folder in the S3 bucket in which the data asset will be created
Create a Data Asset from a Public S3 Bucket
Request Example Bash
curl --location --request POST 'https://codeocean.com/api/v1/data_assets' \--header 'Content-Type: application/json' \-u \'${API_SECRET}:\' \--data-raw '{"name":"import public AWS bucket with dataset api","description":"meaningful-c","mount":"citations","tags":["Genomics"],"source": { "aws": { "public":true, "bucket":"codeocean-public-data", "prefix":"example_datasets/ATAC/hg38_2bit/" } }}'
API only returns a confirmation of the validity of the creation request, not the success of the creation, since the creation takes time. Poll on the dataset details and monitor its state until it’s ready.
Authorize with Code Ocean API Secret: -u $API_SECRET :
This is setting the "Authorization Basic" base64string header
-H*
String
Set this to: Content - Type: application/json
{ "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, "type": string - dataset / result }
Request Example Bash
curl --location --request GET 'https://codeocean.com/api/v1/data_assets/4bc97533-6eb4-48ac-966f-648548a756d2' \--header 'Content-Type: application/json' \-u \'${API_SECRET}:\'
This API allows for the updating of the metadata for your data asset.
Path Parameters
Name
Type
Description
PUT*
/data_assets/:data_asset_id
Your VPC domain
Headers
Name
Type
Description
-u*
Authorize with Code Ocean API Secret: -u $API_SECRET :
This is setting the "Authorization Basic" base64string header
-H*
Set this to: Content - Type: application/json
--data-raw*
JSON with parameters
Request Body
Name
Type
Description
name*
string
The name of the data asset
description*
string
A description for the data asset
tags*
string
Keywords to search the data asset by
mount*
string
Data asset default mount folder
custom_metadata
Map of key value pairs, should match custom metadata fields defined by the admin's possible values:
string custom field - string
number custom field - number
date custom field - number
- unix (epoch) format timestamp in secs
Request Example Bash
curl -X PUT 'https://codeocean.com/api/v1/data_assets/d36665a7-ef59-4b8e-a799-bee7f83ee317' \-u \'${API_SECRET}:\' \-H 'Content-Type: application/json' \--data-raw '{ "name": "Modified The Name", "description": "a new description from the API!", "tags": ["I","Am","New"], "mount": "NewMount"}'
Request Example Python
import os, requests headers = { "Content-Type": "application/json"}json_data = { "name": "Modified The Name", "description": "a new description from the API!", "tags": [ "I", "Am", "New" ], "mount": "NewMount"}response = requests.put('https://codeocean.com/api/v1/data_assets/d36665a7-ef59-4b8e-a799-bee7f83ee317', headers=headers, json=json_data, auth=("'" + os.getenv('API_SECRET', ''), "'"), )