Update 3D revisions
Required capabilities:
threedAcl:UPDATE
POST
/
3d
/
models
/
{modelId}
/
revisions
/
update
JavaScript SDK
const revisionsToUpdate = [{
id: 6305529564379596,
update: {
rotation: {
set: [1, 2, 3]
},
translation: {
set: [4, 5, 6]
},
scale: {
set: [0.5, 0.3, 0.2]
}
}
}];
const updated = await client.revisions3D.update(8252999965991682, revisionsToUpdate);revision = client.three_d.revisions.retrieve(model_id=1, id=1)
revision.status = "New Status"
res = client.three_d.revisions.update(model_id=1, item=revision)
from cognite.client.data_classes import ThreeDModelRevisionUpdate
my_update = ThreeDModelRevisionUpdate(id=1).published.set(False).metadata.add({"key": "value"})
res = client.three_d.revisions.update(model_id=1, item=my_update)
ThreeDModelRevision th = ThreeDModelRevision.newBuilder().setId(10).setRotation(1,10).build();
List<ThreeDModelRevision> tdUpdateResults =
client.threeD()
.models()
.revisions()
.upsert(10L, List.of(th));
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496,
"update": {
"published": {
"set": true
},
"rotation": {
"set": [
123
]
},
"scale": {
"set": [
123
]
},
"translation": {
"set": [
123
]
},
"camera": {},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
}
}
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 4503599627370496,
'update' => [
'published' => [
'set' => true
],
'rotation' => [
'set' => [
123
]
],
'scale' => [
'set' => [
123
]
],
'translation' => [
'set' => [
123
]
],
'camera' => [
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"published\": {\n \"set\": true\n },\n \"rotation\": {\n \"set\": [\n 123\n ]\n },\n \"scale\": {\n \"set\": [\n 123\n ]\n },\n \"translation\": {\n \"set\": [\n 123\n ]\n },\n \"camera\": {},\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n }\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"published\": {\n \"set\": true\n },\n \"rotation\": {\n \"set\": [\n 123\n ]\n },\n \"scale\": {\n \"set\": [\n 123\n ]\n },\n \"translation\": {\n \"set\": [\n 123\n ]\n },\n \"camera\": {},\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 1000,
"fileId": 1000,
"published": false,
"status": "Done",
"assetMappingCount": 0,
"createdTime": 0,
"rotation": [
0,
0,
0
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
],
"camera": {
"target": [
123
],
"position": [
123
]
},
"metadata": {},
"thumbnailThreedFileId": 1000,
"thumbnailURL": "https://api.cognitedata.com/api/v1/project/myproject/3d/files/1000"
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
]
}
}Authorizations
oidc-tokenoauth2-client-credentialsoauth2-open-industrial-dataoauth2-auth-code
Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
Scopes
Body
application/json
List of changes.
⌘I
JavaScript SDK
const revisionsToUpdate = [{
id: 6305529564379596,
update: {
rotation: {
set: [1, 2, 3]
},
translation: {
set: [4, 5, 6]
},
scale: {
set: [0.5, 0.3, 0.2]
}
}
}];
const updated = await client.revisions3D.update(8252999965991682, revisionsToUpdate);revision = client.three_d.revisions.retrieve(model_id=1, id=1)
revision.status = "New Status"
res = client.three_d.revisions.update(model_id=1, item=revision)
from cognite.client.data_classes import ThreeDModelRevisionUpdate
my_update = ThreeDModelRevisionUpdate(id=1).published.set(False).metadata.add({"key": "value"})
res = client.three_d.revisions.update(model_id=1, item=my_update)
ThreeDModelRevision th = ThreeDModelRevision.newBuilder().setId(10).setRotation(1,10).build();
List<ThreeDModelRevision> tdUpdateResults =
client.threeD()
.models()
.revisions()
.upsert(10L, List.of(th));
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"items": [
{
"id": 4503599627370496,
"update": {
"published": {
"set": true
},
"rotation": {
"set": [
123
]
},
"scale": {
"set": [
123
]
},
"translation": {
"set": [
123
]
},
"camera": {},
"metadata": {
"set": {
"key1": "value1",
"key2": "value2"
}
}
}
}
]
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'items' => [
[
'id' => 4503599627370496,
'update' => [
'published' => [
'set' => true
],
'rotation' => [
'set' => [
123
]
],
'scale' => [
'set' => [
123
]
],
'translation' => [
'set' => [
123
]
],
'camera' => [
],
'metadata' => [
'set' => [
'key1' => 'value1',
'key2' => 'value2'
]
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update"
payload := strings.NewReader("{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"published\": {\n \"set\": true\n },\n \"rotation\": {\n \"set\": [\n 123\n ]\n },\n \"scale\": {\n \"set\": [\n 123\n ]\n },\n \"translation\": {\n \"set\": [\n 123\n ]\n },\n \"camera\": {},\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n }\n }\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://{cluster}.cognitedata.com/api/v1/projects/{project}/3d/models/{modelId}/revisions/update")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"items\": [\n {\n \"id\": 4503599627370496,\n \"update\": {\n \"published\": {\n \"set\": true\n },\n \"rotation\": {\n \"set\": [\n 123\n ]\n },\n \"scale\": {\n \"set\": [\n 123\n ]\n },\n \"translation\": {\n \"set\": [\n 123\n ]\n },\n \"camera\": {},\n \"metadata\": {\n \"set\": {\n \"key1\": \"value1\",\n \"key2\": \"value2\"\n }\n }\n }\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"items": [
{
"id": 1000,
"fileId": 1000,
"published": false,
"status": "Done",
"assetMappingCount": 0,
"createdTime": 0,
"rotation": [
0,
0,
0
],
"scale": [
1,
1,
1
],
"translation": [
0,
0,
0
],
"camera": {
"target": [
123
],
"position": [
123
]
},
"metadata": {},
"thumbnailThreedFileId": 1000,
"thumbnailURL": "https://api.cognitedata.com/api/v1/project/myproject/3d/files/1000"
}
]
}{
"error": {
"code": 401,
"message": "Could not authenticate.",
"missing": [
{}
],
"duplicated": [
{}
]
}
}