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-core");
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(dtdlModels: any[], options?: OperationOptions): Promise<DigitalTwinModelsAddResponse>
Parameters
- dtdlModels
-
any[]
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinModelsAddResponse>
The created application/json models and the http response.
decomissionModel(string, OperationOptions)
Decommission a model using a json patch. When a model is decommissioned, new digital twins will no longer be able to be defined by this model. However, existing digital twins may continue to use this model. Once a model is decommissioned, it may not be recommissioned.
function decomissionModel(modelId: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- modelId
-
string
The Id of the model to decommission. property can be replaced.
- options
- OperationOptions
The operation options
Returns
Promise<RestResponse>
The http response.
deleteDigitalTwin(string, DigitalTwinsDeleteOptionalParams)
Delete a digital twin
function deleteDigitalTwin(digitalTwinId: string, options?: DigitalTwinsDeleteOptionalParams): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- options
- DigitalTwinsDeleteOptionalParams
Extended operation options including ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
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 eventRoute 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, DigitalTwinsDeleteRelationshipOptionalParams)
Delete a relationship on a digital twin.
function deleteRelationship(digitalTwinId: string, relationshipId: string, options?: DigitalTwinsDeleteRelationshipOptionalParams): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the source digital twin.
- relationshipId
-
string
The Id of the relationship to delete.
The operation options ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is
Returns
Promise<RestResponse>
The http response.
getComponent(string, string, OperationOptions)
Get a component on a digital twin.
function getComponent(digitalTwinId: string, componentName: string, options?: OperationOptions): Promise<DigitalTwinsGetComponentResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- componentName
-
string
The component being retrieved.
- options
- OperationOptions
The operation options
Returns
Promise<DigitalTwinsGetComponentResponse>
Json string representation of the component corresponding to the provided componentName 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
- options
- OperationOptions
Extended operation options including includeModelDefinition: When true the model definition will be returned as part of the result. Default value: false.
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<DigitalTwinsGetRelationshipByIdResponse>
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
The pageable list of application/json relationships belonging to the specified digital twin and the http response.
listEventRoutes(number, OperationOptions & PageSettings)
List the event routes in a digital twins instance.
function listEventRoutes(resultsPerPage?: number, options?: OperationOptions & PageSettings): PagedAsyncIterableIterator<EventRoute, EventRoutesListNextResponse, PageSettings>
Parameters
- resultsPerPage
-
number
The maximum number of items to retrieve per request. The server may choose to return less than the requested max.
- options
Returns
The application/json event route and the http response.
listIncomingRelationships(string, OperationOptions & PageSettings)
Retrieve all incoming relationships for a digital twin.
function listIncomingRelationships(digitalTwinId: string, options?: OperationOptions & PageSettings): PagedAsyncIterableIterator<IncomingRelationship, DigitalTwinsListIncomingRelationshipsResponse, PageSettings>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- options
Returns
listModels(string[], boolean, number, OperationOptions & PageSettings)
Get the list of models
function listModels(dependeciesFor?: string[], includeModelDefinition?: boolean, resultsPerPage?: number, options?: OperationOptions & PageSettings): PagedAsyncIterableIterator<DigitalTwinsModelData, 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.
- resultsPerPage
-
number
The maximum number of items to retrieve per request. The server may choose to return less than the requested max.
- options
Returns
A pageable set of application/json models and the http response.
listRelationships(string, OperationOptions & PageSettings)
Retrieve relationships for a digital twin.
function listRelationships(digitalTwinId: string, options?: OperationOptions & 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, componentName: string, payload: string, messageId: string, options?: OperationOptions): Promise<RestResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- componentName
-
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, number, OperationOptions & PageSettings)
Query for digital twins.
function queryTwins(query: string, resultsPerPage?: number, options?: OperationOptions & PageSettings): PagedAsyncIterableIterator<any, QueryQueryTwinsResponse, PageSettings>
Parameters
- query
-
string
The query string, in SQL-like syntax.
- resultsPerPage
-
number
The maximum number of items to retrieve per request. The server may choose to return less than the requested max.
- options
Returns
The pageable list of query results.
updateComponent(string, string, any[], DigitalTwinsUpdateComponentOptionalParams)
Update properties of a component on a digital twin using a JSON patch.
function updateComponent(digitalTwinId: string, componentName: string, jsonPatch: any[], options?: DigitalTwinsUpdateComponentOptionalParams): Promise<DigitalTwinsUpdateComponentResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- componentName
-
string
The component being updated.
- jsonPatch
-
any[]
The application/json-patch+json operations to be performed on the specified digital twin's component.
Extended operation options including ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
Returns
Promise<DigitalTwinsUpdateComponentResponse>
The http response.
updateDigitalTwin(string, any, DigitalTwinsUpdateOptionalParams)
Update a digital twin using a json patch.
function updateDigitalTwin(digitalTwinId: string, jsonPatch: any, options?: DigitalTwinsUpdateOptionalParams): Promise<DigitalTwinsUpdateResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin.
- jsonPatch
-
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.
- options
- DigitalTwinsUpdateOptionalParams
Extended operation options including ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
Returns
Promise<DigitalTwinsUpdateResponse>
The http response.
updateRelationship(string, string, any[], DigitalTwinsUpdateRelationshipOptionalParams)
Updates the properties of a relationship on a digital twin using a JSON patch.
function updateRelationship(digitalTwinId: string, relationshipId: string, jsonPatch: any[], options?: DigitalTwinsUpdateRelationshipOptionalParams): Promise<DigitalTwinsUpdateRelationshipResponse>
Parameters
- digitalTwinId
-
string
The Id of the digital twin to delete.
- relationshipId
-
string
The Id of the relationship to be updated.
- jsonPatch
-
any[]
The application/json-patch+json operations to be performed on the specified digital twin's relationship.
Extended operation options ifMatch: Only perform the operation if the entity's etag matches one of the etags provided or * is provided.
Returns
upsertDigitalTwin(string, string, DigitalTwinsAddOptionalParams)
Create or update a digital twin
function upsertDigitalTwin(digitalTwinId: string, digitalTwinJson: string, options?: DigitalTwinsAddOptionalParams): 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
- DigitalTwinsAddOptionalParams
Extended operation options including ifNoneMatch: Only perform the operation if the entity does not already exist.
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, DigitalTwinsAddRelationshipOptionalParams)
Create or update a relationship on a digital twin.
function upsertRelationship(digitalTwinId: string, relationshipId: string, relationship: any, options?: DigitalTwinsAddRelationshipOptionalParams): Promise<DigitalTwinsAddRelationshipResponse>
Parameters
- digitalTwinId
-
string
The Id of the source digital twin.
- relationshipId
-
string
The Id of the relationship to create.
- relationship
-
any
The application/json relationship to be created.
Extended operation options including ifNoneMatch: Only perform the operation if the entity does not already exist.
Returns
Promise<DigitalTwinsAddRelationshipResponse>