Class: Annotations
repositories.Annotations
Annotations repository.
The Annotation class allows you to manage the annotations of data items.
Hierarchy
-
Repository
↳
Annotations
Implements
-
IBundle
<SDKAnnotation
>
Table of contents
Constructors
Methods
Constructors
constructor
• new Annotations(agent
)
Creates an instance of Repository.
Parameters
Name | Type |
---|---|
agent |
PeerAgent |
Inherited from
Methods
create
▸ create(payload
): Promise
<SDKAnnotation
>
Creates a new annotation.
Example
// creates a new annotation of type classification under the label "Person"
const classAnnotation = await dl.annotations.create({
type: "class",
itemId: "itemId-123",
label: "Person",
description: "This is a person classification"
})
Example
const data = {
box: [
{
x: 0,
y: 0,
z: 0,
},
{
x: 0,
y: 0,
z: 0,
},
],
note: { messages: [] },
}
// creates a new annotation of type note under the label "Notes"
const noteAnnotation = await dl.annotations.create({
type: "note",
itemId: "itemId-123",
label: "Notes",
data
})
Parameters
Name | Type | Description |
---|---|---|
payload |
Partial <SDKAnnotation > |
The payload containing the data of the new annotation. |
Returns
Promise
<SDKAnnotation
>
- A promise that resolves to the created annotation.
Implementation of
IBundle.create
delete
▸ delete(clientId
): Promise
<void
>
Deletes a specific annotation by its client id.
Example
await dl.annotations.delete('annotation-clientId-2')
Parameters
Name | Type | Description |
---|---|---|
clientId |
string |
The client id of the annotation to delete. |
Returns
Promise
<void
>
- A promise that resolves when the annotation has been deleted.
Implementation of
IBundle.delete
get
▸ get(clientId
): Promise
<SDKAnnotation
>
Retrieves a specific annotation by its client id.
Example
const annotation = await dl.annotations.get('clientId-123')
Parameters
Name | Type | Description |
---|---|---|
clientId |
string |
The client id of the annotation to retrieve. |
Returns
Promise
<SDKAnnotation
>
- A promise that resolves to the annotation with the specified client id.
Implementation of
IBundle.get
logs
▸ logs(payload?
): Promise
<SDKAnnotationLogs
>
Retrieves all annotation CRUD logs by itemId and datasetId. If not provided, the active dataset and item will be used.
Example
const logs = await dl.annotations.logs({
itemId: 'item-1',
datasetId: 'dataset-1'
})
Parameters
Name | Type | Description |
---|---|---|
payload? |
Object |
An optional payload containing the itemId and datasetId of the annotation. |
payload.datasetId |
string |
The datasetId of the annotation. |
payload.itemId |
string |
The itemId of the annotation. |
Returns
Promise
<SDKAnnotationLogs
>
- A promise that resolves to the logs of the annotations.
Implementation of
IBundle.logs
query
▸ query(payload?
): Promise
<IPagedResponse
<SDKAnnotation
>>
Lists all annotations by filter.
Example
const pagedResponse = await dl.annotations.query()
const annotations = pagedResponse.items
Parameters
Name | Type | Description |
---|---|---|
payload? |
Object |
The query containing the filter. |
payload.filter |
DQL <SDKAnnotation > |
- |
Returns
Promise
<IPagedResponse
<SDKAnnotation
>>
- A promise that resolves to a paged response with the queried annotations.
update
▸ update(payload
): Promise
<SDKAnnotation
>
Updates an existing annotation.
Example
const annotation = await dl.annotations.get('clientId-123')
if (annotation) {
annotation.description = "New description"
}
const updatedAnnotation = await dl.annotations.update(annotation)
console.log(updatedAnnotation.description) // "New description"
Parameters
Name | Type | Description |
---|---|---|
payload |
Partial <SDKAnnotation > |
The payload containing the updated data of the annotation. |
Returns
Promise
<SDKAnnotation
>
- A promise that resolves to the updated annotation.