Class: Annotations
appLib/SDKDrivers/xFrameDriver/annotations.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
<any
>>
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 <any >> |
The payload containing the data of the new annotation. |
Returns
Promise
<SDKAnnotation
<any
>>
- A promise that resolves to the created annotation.
Implementation of
IBundle.create
createBulk
▸ createBulk(payload
, options?
): Promise
<SDKAnnotation
<any
>[]>
Creates new annotations.
Example
// creates new annotations of type classification under the labels "Person" & "Car"
const classAnnotation = await dl.annotations.createBulk([{
type: "class",
itemId: "itemId-123",
label: "Person",
description: "This is a person classification"
},
{
type: "class",
itemId: "itemId-123",
label: "Car",
description: "This is a car classification"
}
])
Parameters
Name | Type | Description |
---|---|---|
payload |
Partial <SDKAnnotation <any >>[] |
The payload containing the data of the new annotations. |
options |
Object |
|
options.timeout? |
number |
an option to set the timeout for the request. |
Returns
Promise
<SDKAnnotation
<any
>[]>
- A promise that resolves to the created annotations.
Implementation of
IBundle.createBulk
crudReq
▸ crudReq(data
): void
Sends a CRUD request to the xFrame.
Parameters
Name | Type |
---|---|
data |
any |
Returns
void
Inherited from
crudReqSync
▸ crudReqSync(data
, options?
): Promise
<any
>
Sends a CRUD request to the xFrame.
Parameters
Name | Type | Description |
---|---|---|
data |
any |
The data to send. |
options |
Object |
|
options.timeout? |
number |
an option to set the timeout for the request. |
Returns
Promise
<any
>
Inherited from
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
deleteBulk
▸ deleteBulk(clientIds
): Promise
<void
>
Deletes annotations by their client ids.
Example
await dl.annotations.deleteBulk(['annotation-clientId-1', 'annotation-clientId-2'])
Parameters
Name | Type |
---|---|
clientIds |
string [] |
Returns
Promise
<void
>
- A promise that resolves when the annotations have been deleted.
Implementation of
IBundle.deleteBulk
get
▸ get(clientId
): Promise
<SDKAnnotation
<any
>>
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
<any
>>
- 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?
, options?
): Promise
<IPagedResponse
<SDKAnnotation
<any
>>>
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 <any >> |
- |
options |
Object |
|
options.timeout? |
number |
an option to set the timeout for the request. |
Returns
Promise
<IPagedResponse
<SDKAnnotation
<any
>>>
- A promise that resolves to a paged response with the queried annotations.
Implementation of
IBundle.query
setStatus
▸ setStatus(payload
): Promise
<void
>
Sets the status of an annotation.
Example
await dl.annotations.setStatus({
annotationId: 'clientId-1',
status: 'review'
})
Parameters
Name | Type | Description |
---|---|---|
payload |
Object |
- |
payload.id |
string |
The clientId of the annotation. |
payload.status |
string |
The status of the annotation. |
Returns
Promise
<void
>
- A promise that resolves when the status is set.
Implementation of
IBundle.setStatus
update
▸ update(payload
): Promise
<SDKAnnotation
<any
>>
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 <any >> |
The payload containing the updated data of the annotation. |
Returns
Promise
<SDKAnnotation
<any
>>
- A promise that resolves to the updated annotation.
Implementation of
IBundle.update
updateBulk
▸ updateBulk(payload
, options?
): Promise
<SDKAnnotation
<any
>[]>
Updates existing annotations.
Example
const annotation1 = await dl.annotations.get('clientId-123')
if (annotation1) {
annotation1.description = "New description"
}
const annotation2 = await dl.annotations.get('clientId-456')
if (annotation2) {
annotation2.label = "New label"
}
const updatedAnnotations = await dl.annotations.updateBulk([annotation1, annotation2])
Parameters
Name | Type | Description |
---|---|---|
payload |
Partial <SDKAnnotation <any >>[] |
The payload containing the updated data of the annotations. |
options |
Object |
|
options.timeout? |
number |
an option to set the timeout for the request. |
Returns
Promise
<SDKAnnotation
<any
>[]>
- A promise that resolves to the updated annotations.
Implementation of
IBundle.updateBulk