DigitalTwinsClient class
Client for Azure IoT DigitalTwins API.
Constructors
| Digital |
Creates an instance of AzureDigitalTwinsAPI. Example usage:
|
Methods
Constructor Details
DigitalTwinsClient(string, TokenCredential, DigitalTwinsClientOptions)
Creates an instance of AzureDigitalTwinsAPI.
Example usage:
const { DigitalTwinsClient, ServiceClientCredentials } = require("@azure/digital-twins");
const client = new DigitalTwinsClient(
"<endpoint>",
new DefaultAzureCredential();
);
new DigitalTwinsClient(endpointUrl: string, credential: TokenCredential, options?: DigitalTwinsClientOptions)
Parameters
- endpointUrl
-
string
The endpoint URL of the service.
- credential
- TokenCredential
Used to authenticate requests to the service.
- options
- DigitalTwinsClientOptions
Used to configure the service client.
Method Details
createModels(any[], OperationOptions)
Create one or many
function createModels(models: any[], options?: OperationOptions): Promise<DigitalTwinModelsAddResponse>
Parameters
- models
-
any[]
The set of models to create. Each string corresponds to exactly one model.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinModelsAddResponse>
The created application/json models and the http response.
decomissionModel(string, any[], OperationOptions)
Decommission a model using a json patch.
function decomissionModel(modelId: string, updateModel: any[], options?: OperationOptions): Promise<RestResponse>
Parameters
- modelId
-
string
The Id of the model to decommission.
- updateModel
-
any[]
An update specification described by JSON Patch. Only the decommissioned property can be replaced.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
deleteDigitalTwin(string, string, OperationOptions)
Delete a digital twin
function deleteDigitalTwin(digitalTwinId: string, etag?: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- etag
-
string
Only perform the operation if the entity's etag matches one of the etags provided or * is provided
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
deleteEventRoute(string, OperationOptions)
Delete an event route.
function deleteEventRoute(eventRouteId: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- eventRouteId
-
string
The Id of the model to delete.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
deleteModel(string, OperationOptions)
Delete a model.
function deleteModel(modelId: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- modelId
-
string
The Id of the model to delete.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
deleteRelationship(string, string, string, OperationOptions)
Delete a relationship on a digital twin.
function deleteRelationship(digitalTwinId: string, relationshipId: string, etag?: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the source digital twin.
- relationshipId
-
string
The Id of the relationship to delete.
- etag
-
string
Only perform the operation if the entity's etag matches one of the etags provided or * is
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
getComponent(string, string, OperationOptions)
Get a component on a digital twin.
function getComponent(digitalTwinId: string, componentPath: string, options?: OperationOptions): Promise<DigitalTwinsGetComponentResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- componentPath
-
string
The component being retrieved.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsGetComponentResponse>
Json string representation of the component corresponding to the provided componentPath and the HTTP response.
getDigitalTwin(string, OperationOptions)
Get a digital twin
function getDigitalTwin(digitalTwinId: string, options?: OperationOptions): Promise<DigitalTwinsGetByIdResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsGetByIdResponse>
The application/json digital twin and the http response.
getEventRoute(string, OperationOptions)
Get an event route.
function getEventRoute(eventRouteId: string, options?: OperationOptions): Promise<EventRoutesGetByIdResponse>
Parameters
- eventRouteId
-
string
- options
- OperationOptions
The operation options
Returns
Promise<EventRoutesGetByIdResponse>
The application/json event route and the http response.
getModel(string, boolean, OperationOptions)
Get a model, including the model metadata and the model definition.
function getModel(modelId: string, includeModelDefinition?: boolean, options?: OperationOptions): Promise<DigitalTwinModelsGetByIdResponse>
Parameters
- modelId
-
string
The Id of the model.
- includeModelDefinition
-
boolean
When true the model definition will be returned as part of the result. Default value: false.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinModelsGetByIdResponse>
The application/json model and the http response.
getRelationship(string, string, OperationOptions)
Get a relationship on a digital twin.
function getRelationship(digitalTwinId: string, relationshipId: string, options?: OperationOptions): Promise<DigitalTwinsGetByIdResponse>
Parameters
- digitalTwinId
-
string
The Id of the source digital twin.
- relationshipId
-
string
The Id of the relationship to retrieve.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsGetByIdResponse>
The pageable list of application/json relationships belonging to the specified digital twin and the http response.
listEventRoutes(number)
List the event routes in a digital twins instance.
function listEventRoutes(maxItemCount?: number): PagedAsyncIterableIterator<EventRoute, EventRoutesListNextResponse, PageSettings>
Parameters
- maxItemCount
-
number
The maximum number of items to retrieve per request. The server may choose to return less than the requested max. Default value: -1.
Returns
The application/json event route and the http response.
listIncomingRelationships(string, RequestOptionsBase & PageSettings)
Retrieve all incoming relationships for a digital twin.
function listIncomingRelationships(digitalTwinId: string, options?: RequestOptionsBase & PageSettings): PagedAsyncIterableIterator<IncomingRelationship, DigitalTwinsListIncomingRelationshipsResponse, PageSettings>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- options
Returns
listModels(string[], boolean, number)
Get the list of models
function listModels(dependeciesFor?: string[], includeModelDefinition?: boolean, maxItemCount?: number): PagedAsyncIterableIterator<ModelData, DigitalTwinModelsListResponse, PageSettings>
Parameters
- dependeciesFor
-
string[]
The model Ids to have dependencies retrieved. If omitted, all models are retrieved.
- includeModelDefinition
-
boolean
Whether to include the model definition in the result. If false, only the model metadata will be returned.
- maxItemCount
-
number
The maximum number of items to retrieve per request. The server may choose to return less than the requested max. Default value: -1.
Returns
A pageable set of application/json models and the http response.
listRelationships(string, RequestOptionsBase & PageSettings)
Retrieve relationships for a digital twin.
function listRelationships(digitalTwinId: string, options?: RequestOptionsBase & PageSettings): PagedAsyncIterableIterator<any, DigitalTwinsListRelationshipsResponse, PageSettings>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- options
Returns
publishComponentTelemetry(string, string, string, string, OperationOptions)
Publish telemetry from a digital twin's component, which is then consumed by one or many destination endpoints (subscribers) defined under.
function publishComponentTelemetry(digitalTwinId: string, componentPath: string, payload: string, messageId?: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- componentPath
-
string
The name of the DTDL component.
- payload
-
string
The application/json telemetry payload to be sent.
- messageId
-
string
The message Id.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
publishTelemetry(string, any, string, OperationOptions)
Publish telemetry from a digital twin, which is then consumed by one or many destination endpoints (subscribers) defined under.
function publishTelemetry(digitalTwinId: string, payload: any, messageId?: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- payload
-
any
The application/json telemetry payload to be sent.
- messageId
-
string
The message Id.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
queryTwins(string)
Query for digital twins.
function queryTwins(query?: string): PagedAsyncIterableIterator<any, QueryQueryTwinsResponse, PageSettings>
Parameters
- query
-
string
The query string, in SQL-like syntax.
Returns
The pageable list of query results.
updateComponent(string, string, any[], string, OperationOptions)
Update properties of a component on a digital twin using a JSON patch.
function updateComponent(digitalTwinId: string, componentPath: string, componentPatch?: any[], etag?: string, options?: OperationOptions): Promise<DigitalTwinsUpdateComponentResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- componentPath
-
string
The component being updated.
- componentPatch
-
any[]
The application/json-patch+json operations to be performed on the specified digital twin's component.
- etag
-
string
The etag of the component to update. Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsUpdateComponentResponse>
The http response.
updateDigitalTwin(string, any, string, OperationOptions)
Update a digital twin using a json patch.
function updateDigitalTwin(digitalTwinId: string, twinPatch: any, etag?: string, options?: OperationOptions): Promise<DigitalTwinsUpdateResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- twinPatch
-
any
An update specification described by JSON Patch. Updates to property values and $model elements may happen in the same request. Operations are limited to add, replace and remove.
- etag
-
string
Only perform the operation if the entity's etag matches one of the etags provided or * is provided
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsUpdateResponse>
The http response.
updateRelationship(string, string, any[], string, OperationOptions)
Updates the properties of a relationship on a digital twin using a JSON patch.
function updateRelationship(digitalTwinId: string, relationshipId: string, relationshipPatch: any[], etag?: string, options?: OperationOptions): Promise<DigitalTwinsUpdateRelationshipResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- relationshipId
-
string
The Id of the relationship to be updated.
- relationshipPatch
-
any[]
The application/json-patch+json operations to be performed on the specified digital twin's relationship.
- etag
-
string
Only perform the operation if the entity's etag matches one of the etags provided or * is
- options
- OperationOptions
The operation options provided
Returns
upsertDigitalTwin(string, string, OperationOptions)
Create or update a digital twin
function upsertDigitalTwin(digitalTwinId: string, digitalTwinJson: string, options?: OperationOptions): Promise<DigitalTwinsAddResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to create or update.
- digitalTwinJson
-
string
The application/json digital twin to create.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsAddResponse>
The created application/json digital twin and the http response.
upsertEventRoute(string, string, string, OperationOptions)
Create or update an event route.
function upsertEventRoute(eventRouteId: string, endpointId: string, filter?: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- eventRouteId
-
string
The Id of the event route to create or update.
- endpointId
-
string
The id of the endpoint this event route is bound to.
- filter
-
string
An expression which describes the events which are routed to the endpoint.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
upsertRelationship(string, string, any, OperationOptions)
Create or update a relationship on a digital twin.
function upsertRelationship(digitalTwinId: string, relationshipId: string, relationship: any, options?: OperationOptions): Promise<DigitalTwinsAddRelationshipResponse>
Parameters
- digitalTwinId
-
string
The Id of the source digital twin.
- relationshipId
-
string
The Id of the relationship to create.
- relationship
-
any
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsAddRelationshipResponse>