Dataset / finalizeNeedsReviewEntries
TypeScript
Set the data of an item within the 'needs review' folder of a dataset and move the entry into the actual dataset.
Request parameters
{
/** The dataset's id. */
datasetId: string,
/** An array containing the index to remove from 'needs review'. */
indexes: number[],
/**
* New data to add to the dataset, in place of the entries removed from 'needs review'. There should be one entry
* for each key in the dataset, and the length of the data in each key must equal the length of *indexes*.
*/
keys: {
key: string,
data: DecthingsTensor[]
}[],
/**
* If specified, the operation will only be performed if the current dataset versionId is equal to the specified
* string.
*/
datasetVersionId?: string
}
Response
{
/** If successful. One of "result" and "error" will be present. */
result?: {
/** The new dataset version identifier, which should be used as the version identifier in subsequent requests. */
newDatasetVersionId: string,
/** The number of bytes that was removed from 'needs review'. */
removedBytesFromNeedsReview: number
},
/** If failed */
error?: {
code: 'dataset_not_found' | 'index_out_of_range' | 'access_denied' | 'quota_exceeded' | 'bad_credentials' | 'too_many_requests' | 'payment_required' | 'unknown'
} | {
code: 'incorrect_version_id',
/** The correct current dataset version ID, which should be used instead. */
datasetVersionId: string
} | {
code: 'invalid_parameter',
parameterName: string,
reason: string
}
}
Example
Following the installation guide to setup the Decthings API for TypeScript. Add your parameters to the following code and run it in Node.js, or in a browser by using a bundler.
The code reads your API key from file. Create an API key and save it to the file "auth.txt". Keep your key safe!
import * as fs from 'fs'
import { DecthingsClient } from '@decthings/api-client'
let apiKey = fs.readFileSync('./auth.txt').toString().trim()
let client = new DecthingsClient({ apiKey })
async function main() {
try {
let response = await client.dataset.finalizeNeedsReviewEntries({
datasetId: /* Add datasetId here */,
indexes: /* Add indexes here */,
keys: /* Add keys here */,
keys: /* Add keys here */
})
if (result.error) {
// Decthings sent us an error
console.log(response.error)
} else {
// Success!
console.log(response.result)
}
}
catch (e) {
// Client throws an error on connection issues. The function may or may not have succeded
console.log(e)
}
}
main()