デジタル・ツイン・モデルの作成
Internet of Things用のデジタル・ツイン・モデルを作成します(IoT)。
デジタル・ツイン・モデルは、デジタル・ツインのセマンティクスを定義し、DTDL v3仕様に基づいています。デジタル・ツイン・モデルは、デジタル・ツイン・モデル識別子(DTMI)を一意の識別子として使用します。
たとえば: dtmi:com:oracle:iot:connectable;1
デジタル・ツイン・インスタンスでは、構造化されたデバイス・データを受信するために、デジタル・ツイン・モデルとデジタル・ツイン・アダプタが必要です。具体的な例は、シナリオを参照してください。
デジタル・ツイン定義言語(DTDL) v3は、デジタル・ツイン・コンソーシアムによってGitHubでサポートされています。MQTT拡張および書込み可能プロパティはサポートされていないことに注意してください。
writableプロパティが含まれている場合は、falseに設定する必要があります。
oci iot digital-twin-model createコマンドおよび必須パラメータを使用して、特定のIoTドメインにデジタル・ツイン・モデルを作成します。指定は、コマンドラインで直接JSONコンテンツとして、またはコマンドラインで参照されるファイルとして指定します。
次の例は、コマンドラインでJSON仕様を直接指定する方法を示しています。
oci iot digital-twin-model create --iot-domain-id <iot-domain-OCID> --spec '{"@context": ["dtmi:dtdl:context;3", "dtmi:dtdl:extension:historization;1", "dtmi:dtdl:extension:quantitativeTypes;1", "dtmi:com:oracle:dtdl:extension:validation;1"], "@id": "dtmi:com:oracle:iot:sample:hvac:UgNaNWHbzK;1", "@type": "Interface", "contents": [{"@type": ["Telemetry", "Temperature"], "name": "temperature", "schema": "integer", "unit": "degreeFahrenheit"}, {"@type": ["Telemetry", "Historized", "Validated"], "name": "humidity", "schema": "integer", "minimum": 0, "maximum": 100}, {"@type": ["Property", "Historized"], "name": "location", "schema": "point", "writable": true}, {"@type": ["Property", "Validated"], "name": "serialNumber", "schema": "string", "pattern": "^([0-9]){2}([0-9]){5}([0-9]){6}$"}]}'この例では、指定を含む
dtdl-specifications.jsonファイルを作成し、コマンドでファイルを参照する方法を示します。ファイルの参照の詳細は、複合入力へのJSONファイルの使用を参照してください。
デジタル・ツイン・モデル識別子(DTMI)を一意識別子として含むDTDL v3指定に基づくoci iot digital-twin-model create --iot-domain-id <iot-domain-OCID> --spec file://dtdl-specifications.jsondtdl-specifications.jsonファイルの例。{ "@context": [ "dtmi:dtdl:context;3", "dtmi:dtdl:extension:historization;1", "dtmi:dtdl:extension:quantitativeTypes;1", "dtmi:com:oracle:dtdl:extension:validation;1" ], "@id": "dtmi:com:oracle:iot:sample:hvac:UgNaNWHbzK;1", "@type": "Interface", "contents": [ { "@type": [ "Telemetry", "Temperature" ], "name": "temperature", "schema": "integer", "unit": "degreeFahrenheit" }, { "@type": [ "Telemetry", "Historized", "Validated" ], "name": "humidity", "schema": "integer", "minimum": 0, "maximum": 100 }, { "@type": [ "Property", "Historized" ], "name": "location", "schema": "point", "writable": false }, { "@type": [ "Property", "Validated" ], "name": "serialNumber", "schema": "string", "pattern": "^([0-9]){2}([0-9]){5}([0-9]){6}$" } ] }このレスポンス例は、DTMI URI:
dtmi:com:oracle:iot:sample:hvac:unique-id;1を使用して、IoTドメインにデジタル・ツイン・モデルが作成されたことを示しています。{ "data": { "defined-tags": { "Oracle-Tags": { "CreatedBy": "default/user", "CreatedOn": "2025-08-05T17:43:00.438Z" } }, "description": null, "display-name": "HVAC", "freeform-tags": {}, "id": "<iot-digital-twin-model-OCID>", "iot-domain-id": "<iot-domain-OCID>", "lifecycle-state": "ACTIVE", "spec-uri": "dtmi:com:oracle:iot:sample:hvac:unique-id;1", "system-tags": {}, "time-created": "2025-08-05T17:43:00.508000+00:00", "time-updated": "2025-08-05T17:43:00.508000+00:00" }, "etag": "<unique-id>" }CLIコマンドのパラメータおよび値の完全なリストは、CLIコマンド・リファレンスを参照してください。
CreateDigitalTwinModel操作を実行して、特定のIoTドメインにデジタル・ツイン・モデルを作成します。
リクエストの例:
POST /20250531/digitalTwinModels content-type: application/json+ld { "@context": ["dtmi:dtdl:context;3"], "@id": "dtmi:com:oracle:labauto:SmartSpecimenVault;1", "@type": "Interface", "extends": "dtmi:com:oracle:iot:connectable;1", "displayName": "HVAC", "contents": [ {"@type": "Telemetry", "name": "temperature", "schema": "integer"}, {"@type": "Telemetry", "name": "humidity", "schema": "integer", "minimum":0, "maximum": 100}, {"@type": "Property", "name": "desiredTemperature", "schema": "integer", "writable": true}, {"@type": "Property", "name": "serialNumber", "schema": "string"} ] }レスポンスの例:
header: content-type: application/json Body: { "id": "<digital-twin-model-OCID>" "displayName": "<your-HVAC-display-name>", "description": "<digital-twin-model-for-HVAC>" "lifecycleState": "ACTIVE", "freeformTags": {}, "definedTags": { "Oracle-Tags": { "CreatedBy": "default/user@oracle.com", "CreatedOn": "2024-07-22T10:24:53.446Z" } }, "specUri": "dtmi:com:oracle:labauto:SmartSpecimenVault;1" "timeCreated": "2025-01-13T10:24:53Z", "timeUpdated": "2025-01-14T17:15:21Z" }