from cognite.client.data_classes.data_modeling import ViewApply, MappedPropertyApply, ContainerId
views = [
ViewApply(
space="mySpace",
external_id="myView",
version="v1",
properties={
"someAlias": MappedPropertyApply(
container=ContainerId("mySpace", "myContainer"),
container_property_identifier="someProperty",
),
}
)
]
res = client.data_modeling.views.apply(views)
from cognite.client.data_classes.data_modeling import (
ContainerId,
DirectRelationReference,
MappedPropertyApply,
MultiEdgeConnectionApply,
ViewApply,
ViewId
)
acts_in_edge_type = DirectRelationReference(space="imdb", external_id="acts-in")
movie_view = ViewApply(
space="imdb",
external_id="Movie",
version="1",
name="Movie",
properties={
"title": MappedPropertyApply(
container=ContainerId(space="imdb", external_id="Movie"),
container_property_identifier="title",
),
"actors": MultiEdgeConnectionApply(
type=acts_in_edge_type,
direction="inwards",
source=ViewId("imdb", "Actor", "1"),
name="actors",
),
}
)
actor_view = ViewApply(
space="imdb",
external_id="Actor",
version="1",
name="Actor",
properties={
"name": MappedPropertyApply(
container=ContainerId("imdb", "Actor"),
name="name",
container_property_identifier="name",
),
"movies": MultiEdgeConnectionApply(
type=acts_in_edge_type,
direction="outwards",
source=ViewId("imdb", "Movie", "1"),
name="movies",
),
}
)
res = client.data_modeling.views.apply([movie_view, actor_view]){
"items": [
{
"externalId": "<string>",
"space": "<string>",
"version": "<string>",
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"writable": true,
"queryable": true,
"usedFor": "node",
"isGlobal": true,
"properties": {},
"mappedContainers": [
{
"type": "container",
"space": "<string>",
"externalId": "<string>"
}
],
"name": "<string>",
"description": "<string>",
"filter": {
"and": [
{
"in": {
"property": [
"tag"
],
"values": [
10011,
10011
]
}
},
{
"range": {
"property": [
"weight"
],
"gte": 0
}
}
]
},
"implements": [
{
"type": "view",
"space": "<string>",
"externalId": "<string>",
"version": "<string>"
}
]
}
]
}Required capabilities:
DataModelsAcl:WRITE
Add or update (upsert) views. For unchanged view specifications, the operation completes without making any changes. We will not update the lastUpdatedTime value for views that remain unchanged.
from cognite.client.data_classes.data_modeling import ViewApply, MappedPropertyApply, ContainerId
views = [
ViewApply(
space="mySpace",
external_id="myView",
version="v1",
properties={
"someAlias": MappedPropertyApply(
container=ContainerId("mySpace", "myContainer"),
container_property_identifier="someProperty",
),
}
)
]
res = client.data_modeling.views.apply(views)
from cognite.client.data_classes.data_modeling import (
ContainerId,
DirectRelationReference,
MappedPropertyApply,
MultiEdgeConnectionApply,
ViewApply,
ViewId
)
acts_in_edge_type = DirectRelationReference(space="imdb", external_id="acts-in")
movie_view = ViewApply(
space="imdb",
external_id="Movie",
version="1",
name="Movie",
properties={
"title": MappedPropertyApply(
container=ContainerId(space="imdb", external_id="Movie"),
container_property_identifier="title",
),
"actors": MultiEdgeConnectionApply(
type=acts_in_edge_type,
direction="inwards",
source=ViewId("imdb", "Actor", "1"),
name="actors",
),
}
)
actor_view = ViewApply(
space="imdb",
external_id="Actor",
version="1",
name="Actor",
properties={
"name": MappedPropertyApply(
container=ContainerId("imdb", "Actor"),
name="name",
container_property_identifier="name",
),
"movies": MultiEdgeConnectionApply(
type=acts_in_edge_type,
direction="outwards",
source=ViewId("imdb", "Movie", "1"),
name="movies",
),
}
)
res = client.data_modeling.views.apply([movie_view, actor_view]){
"items": [
{
"externalId": "<string>",
"space": "<string>",
"version": "<string>",
"createdTime": 1730204346000,
"lastUpdatedTime": 1730204346000,
"writable": true,
"queryable": true,
"usedFor": "node",
"isGlobal": true,
"properties": {},
"mappedContainers": [
{
"type": "container",
"space": "<string>",
"externalId": "<string>"
}
],
"name": "<string>",
"description": "<string>",
"filter": {
"and": [
{
"in": {
"property": [
"tag"
],
"values": [
10011,
10011
]
}
},
{
"range": {
"property": [
"weight"
],
"gte": 0
}
}
]
},
"implements": [
{
"type": "view",
"space": "<string>",
"externalId": "<string>",
"version": "<string>"
}
]
}
]
}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.
Views to add or update.
List of views to create/update
1 - 100 elementsShow child attributes
List of views
List of views
Show child attributes
Was this page helpful?