Skip to main content

digital_twin_models

Creates, updates, deletes, gets or lists a digital_twin_models resource.

Overview

Namedigital_twin_models
TypeResource
Idazure.digital_twins_core.digital_twin_models

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringThe id of the model as specified in the model definition. Required.
decommissionedbooleanIndicates if the model is decommissioned. Decommissioned models cannot be referenced by newly created digital twins.
descriptionobjectA language map that contains the localized descriptions as specified in the model definition.
displayNameobjectA language map that contains the localized display names as specified in the model definition.
modelobjectThe model definition.
uploadTimestring (date-time)The time the model was uploaded to the service.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_by_idselectid, endpointtraceparent, tracestate, includeModelDefinitionRetrieves model metadata and optionally the model definition. Status codes: * 200 OK * 400 Bad Request * InvalidArgument - The model id is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found.
listselectendpointtraceparent, tracestate, includeModelDefinition, max-items-per-pageRetrieves model metadata and, optionally, model definitions. Status codes: * 200 OK * 400 Bad Request * InvalidArgument - The model id is invalid. * LimitExceeded - The maximum number of model ids allowed in 'dependenciesFor' has been reached. * 404 Not Found * ModelNotFound - The model was not found.
updateupdateid, endpointtraceparent, tracestateUpdates the metadata for a model. Status codes: * 204 No Content * 400 Bad Request * InvalidArgument - The model id is invalid. * JsonPatchInvalid - The JSON Patch provided is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found. * 409 Conflict * ModelReferencesNotDecommissioned - The model refers to models that are not decommissioned.
deletedeleteid, endpointtraceparent, tracestateDeletes a model. A model can only be deleted if no other models reference it. Status codes: * 204 No Content * 400 Bad Request * InvalidArgument - The model id is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found. * 409 Conflict * ModelReferencesNotDeleted - The model refers to models that are not deleted.
addexecendpointtraceparent, tracestateUploads one or more models. When any error occurs, no models are uploaded. Status codes: * 201 Created * 400 Bad Request * DTDLParserError - The models provided are not valid DTDL. * InvalidArgument - The model id is invalid. * LimitExceeded - The maximum number of model ids allowed in 'dependenciesFor' has been reached. * ModelVersionNotSupported - The version of DTDL used is not supported. * 409 Conflict * ModelAlreadyExists - The model provided already exists.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
endpointstringThe service endpoint host (no scheme). (default: )
idstringThe id for the model. The id is globally unique and case sensitive. Required.
includeModelDefinitionbooleanWhen true the model definition will be returned as part of the result. Default value is False.
max-items-per-pageinteger
traceparentstring
tracestatestring

SELECT examples

Retrieves model metadata and optionally the model definition. Status codes: * 200 OK * 400 Bad Request * InvalidArgument - The model id is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found.

SELECT
id,
decommissioned,
description,
displayName,
model,
uploadTime
FROM azure.digital_twins_core.digital_twin_models
WHERE id = '{{ id }}' -- required
AND endpoint = '{{ endpoint }}' -- required
AND traceparent = '{{ traceparent }}'
AND tracestate = '{{ tracestate }}'
AND includeModelDefinition = '{{ includeModelDefinition }}'
;

UPDATE examples

Updates the metadata for a model. Status codes: * 204 No Content * 400 Bad Request * InvalidArgument - The model id is invalid. * JsonPatchInvalid - The JSON Patch provided is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found. * 409 Conflict * ModelReferencesNotDecommissioned - The model refers to models that are not decommissioned.

UPDATE azure.digital_twins_core.digital_twin_models
SET
traceparent = '{{ traceparent }}',
tracestate = '{{ tracestate }}'
WHERE
id = '{{ id }}' --required
AND endpoint = '{{ endpoint }}' --required
AND traceparent = '{{ traceparent}}'
AND tracestate = '{{ tracestate}}';

DELETE examples

Deletes a model. A model can only be deleted if no other models reference it. Status codes: * 204 No Content * 400 Bad Request * InvalidArgument - The model id is invalid. * MissingArgument - The model id was not provided. * 404 Not Found * ModelNotFound - The model was not found. * 409 Conflict * ModelReferencesNotDeleted - The model refers to models that are not deleted.

DELETE FROM azure.digital_twins_core.digital_twin_models
WHERE id = '{{ id }}' --required
AND endpoint = '{{ endpoint }}' --required
AND traceparent = '{{ traceparent }}'
AND tracestate = '{{ tracestate }}'
;

Lifecycle Methods

Uploads one or more models. When any error occurs, no models are uploaded. Status codes: * 201 Created * 400 Bad Request * DTDLParserError - The models provided are not valid DTDL. * InvalidArgument - The model id is invalid. * LimitExceeded - The maximum number of model ids allowed in 'dependenciesFor' has been reached. * ModelVersionNotSupported - The version of DTDL used is not supported. * 409 Conflict * ModelAlreadyExists - The model provided already exists.

EXEC azure.digital_twins_core.digital_twin_models.add 
@endpoint='{{ endpoint }}' --required,
@traceparent='{{ traceparent }}',
@tracestate='{{ tracestate }}'
@@json=
'{
"traceparent": "{{ traceparent }}",
"tracestate": "{{ tracestate }}"
}'
;