cognite-toolkit 0.7.42__py3-none-any.whl → 0.7.44__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. cognite_toolkit/_cdf_tk/client/_toolkit_client.py +7 -1
  2. cognite_toolkit/_cdf_tk/client/api/events.py +20 -2
  3. cognite_toolkit/_cdf_tk/client/api/filemetadata.py +145 -0
  4. cognite_toolkit/_cdf_tk/client/api/raw.py +174 -0
  5. cognite_toolkit/_cdf_tk/client/api/simulator_models.py +118 -0
  6. cognite_toolkit/_cdf_tk/client/api/simulators.py +8 -0
  7. cognite_toolkit/_cdf_tk/client/api/timeseries.py +20 -2
  8. cognite_toolkit/_cdf_tk/client/cdf_client/__init__.py +2 -1
  9. cognite_toolkit/_cdf_tk/client/cdf_client/api.py +40 -6
  10. cognite_toolkit/_cdf_tk/client/data_classes/agent.py +6 -9
  11. cognite_toolkit/_cdf_tk/client/data_classes/annotation.py +79 -0
  12. cognite_toolkit/_cdf_tk/client/data_classes/asset.py +7 -14
  13. cognite_toolkit/_cdf_tk/client/data_classes/base.py +15 -5
  14. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/__init__.py +164 -0
  15. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_constraints.py +37 -0
  16. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_container.py +50 -0
  17. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_data_model.py +73 -0
  18. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_data_types.py +116 -0
  19. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_indexes.py +26 -0
  20. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_instance.py +143 -0
  21. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_references.py +86 -0
  22. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_space.py +26 -0
  23. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_view.py +143 -0
  24. cognite_toolkit/_cdf_tk/client/data_classes/data_modeling/_view_property.py +152 -0
  25. cognite_toolkit/_cdf_tk/client/data_classes/dataset.py +35 -0
  26. cognite_toolkit/_cdf_tk/client/data_classes/event.py +12 -15
  27. cognite_toolkit/_cdf_tk/client/data_classes/extraction_pipeline.py +59 -0
  28. cognite_toolkit/_cdf_tk/client/data_classes/filemetadata.py +15 -19
  29. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_destination.py +34 -0
  30. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_job.py +134 -0
  31. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_mapping.py +72 -0
  32. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/__init__.py +63 -0
  33. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_auth.py +63 -0
  34. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_base.py +26 -0
  35. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_certificate.py +20 -0
  36. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_eventhub.py +31 -0
  37. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_kafka.py +53 -0
  38. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_mqtt.py +36 -0
  39. cognite_toolkit/_cdf_tk/client/data_classes/hosted_extractor_source/_rest.py +49 -0
  40. cognite_toolkit/_cdf_tk/client/data_classes/identifiers.py +8 -0
  41. cognite_toolkit/_cdf_tk/client/data_classes/label.py +27 -0
  42. cognite_toolkit/_cdf_tk/client/data_classes/raw.py +3 -2
  43. cognite_toolkit/_cdf_tk/client/data_classes/securitycategory.py +24 -0
  44. cognite_toolkit/_cdf_tk/client/data_classes/sequence.py +45 -0
  45. cognite_toolkit/_cdf_tk/client/data_classes/simulator_model.py +50 -0
  46. cognite_toolkit/_cdf_tk/client/data_classes/timeseries.py +15 -18
  47. cognite_toolkit/_cdf_tk/client/data_classes/transformation.py +140 -0
  48. cognite_toolkit/_cdf_tk/client/data_classes/workflow.py +27 -0
  49. cognite_toolkit/_cdf_tk/client/data_classes/workflow_trigger.py +63 -0
  50. cognite_toolkit/_cdf_tk/client/data_classes/workflow_version.py +155 -0
  51. cognite_toolkit/_cdf_tk/client/testing.py +6 -1
  52. cognite_toolkit/_cdf_tk/commands/_migrate/conversion.py +10 -7
  53. cognite_toolkit/_cdf_tk/commands/_migrate/data_mapper.py +4 -4
  54. cognite_toolkit/_cdf_tk/cruds/_data_cruds.py +7 -3
  55. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/auth.py +5 -1
  56. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/classic.py +40 -39
  57. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/file.py +56 -59
  58. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/relationship.py +3 -3
  59. cognite_toolkit/_cdf_tk/cruds/_resource_cruds/timeseries.py +48 -47
  60. cognite_toolkit/_cdf_tk/resource_classes/__init__.py +2 -0
  61. cognite_toolkit/_cdf_tk/resource_classes/simulator_model.py +17 -0
  62. cognite_toolkit/_cdf_tk/storageio/_asset_centric.py +84 -71
  63. cognite_toolkit/_cdf_tk/storageio/_file_content.py +22 -19
  64. cognite_toolkit/_cdf_tk/utils/useful_types2.py +5 -3
  65. cognite_toolkit/_repo_files/GitHub/.github/workflows/deploy.yaml +1 -1
  66. cognite_toolkit/_repo_files/GitHub/.github/workflows/dry-run.yaml +1 -1
  67. cognite_toolkit/_resources/cdf.toml +1 -1
  68. cognite_toolkit/_version.py +1 -1
  69. {cognite_toolkit-0.7.42.dist-info → cognite_toolkit-0.7.44.dist-info}/METADATA +11 -1
  70. {cognite_toolkit-0.7.42.dist-info → cognite_toolkit-0.7.44.dist-info}/RECORD +72 -34
  71. {cognite_toolkit-0.7.42.dist-info → cognite_toolkit-0.7.44.dist-info}/WHEEL +1 -1
  72. {cognite_toolkit-0.7.42.dist-info → cognite_toolkit-0.7.44.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,53 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
6
+ BaseModelObject,
7
+ ResponseResource,
8
+ )
9
+
10
+ from ._auth import (
11
+ BasicAuthenticationRequest,
12
+ BasicAuthenticationResponse,
13
+ ClientCredentialAuthenticationRequest,
14
+ ClientCredentialAuthenticationResponse,
15
+ ScramShaAuthenticationRequest,
16
+ ScramShaAuthenticationResponse,
17
+ )
18
+ from ._base import SourceRequestDefinition, SourceResponseDefinition
19
+ from ._certificate import AuthCertificateRequest, CACertificateRequest, CertificateResponse
20
+
21
+
22
+ class KafkaBroker(BaseModelObject):
23
+ host: str
24
+ port: int
25
+
26
+
27
+ class KafkaSource(BaseModelObject):
28
+ type: Literal["kafka"] = "kafka"
29
+ bootstrap_brokers: list[KafkaBroker]
30
+ use_tls: bool | None = None
31
+
32
+
33
+ class KafkaSourceRequest(KafkaSource, SourceRequestDefinition):
34
+ authentication: (
35
+ BasicAuthenticationRequest | ClientCredentialAuthenticationRequest | ScramShaAuthenticationRequest | None
36
+ ) = Field(None, discriminator="type")
37
+ ca_certificate: CACertificateRequest | None = None
38
+ auth_certificate: AuthCertificateRequest | None = None
39
+
40
+
41
+ class KafkaSourceResponse(
42
+ SourceResponseDefinition,
43
+ KafkaSource,
44
+ ResponseResource[KafkaSourceRequest],
45
+ ):
46
+ authentication: (
47
+ BasicAuthenticationResponse | ClientCredentialAuthenticationResponse | ScramShaAuthenticationResponse | None
48
+ ) = Field(None, discriminator="type")
49
+ ca_certificate: CertificateResponse | None = None
50
+ auth_certificate: CertificateResponse | None = None
51
+
52
+ def as_request_resource(self) -> KafkaSourceRequest:
53
+ return KafkaSourceRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,36 @@
1
+ from typing import Literal
2
+
3
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
4
+ BaseModelObject,
5
+ ResponseResource,
6
+ )
7
+
8
+ from ._auth import BasicAuthenticationRequest, BasicAuthenticationResponse
9
+ from ._base import SourceRequestDefinition, SourceResponseDefinition
10
+ from ._certificate import AuthCertificateRequest, CACertificateRequest, CertificateResponse
11
+
12
+
13
+ class MQTTSource(BaseModelObject):
14
+ type: Literal["mqtt5", "mqtt3"]
15
+ host: str
16
+ port: int | None = None
17
+ use_tls: bool | None = None
18
+
19
+
20
+ class MQTTSourceRequest(MQTTSource, SourceRequestDefinition):
21
+ authentication: BasicAuthenticationRequest | None = None
22
+ ca_certificate: CACertificateRequest | None = None
23
+ auth_certificate: AuthCertificateRequest | None = None
24
+
25
+
26
+ class MQTTSourceResponse(
27
+ SourceResponseDefinition,
28
+ MQTTSource,
29
+ ResponseResource[MQTTSourceRequest],
30
+ ):
31
+ authentication: BasicAuthenticationResponse | None = None
32
+ ca_certificate: CertificateResponse | None = None
33
+ auth_certificate: CertificateResponse | None = None
34
+
35
+ def as_request_resource(self) -> MQTTSourceRequest:
36
+ return MQTTSourceRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,49 @@
1
+ from typing import Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
6
+ BaseModelObject,
7
+ ResponseResource,
8
+ )
9
+
10
+ from ._auth import (
11
+ BasicAuthenticationRequest,
12
+ BasicAuthenticationResponse,
13
+ ClientCredentialAuthenticationRequest,
14
+ ClientCredentialAuthenticationResponse,
15
+ HTTPBasicAuthenticationRequest,
16
+ HTTPBasicAuthenticationResponse,
17
+ )
18
+ from ._base import SourceRequestDefinition, SourceResponseDefinition
19
+ from ._certificate import AuthCertificateRequest, CACertificateRequest, CertificateResponse
20
+
21
+
22
+ class RESTSource(BaseModelObject):
23
+ type: Literal["rest"] = "rest"
24
+ host: str
25
+ port: int | None = None
26
+
27
+
28
+ class RESTSourceRequest(RESTSource, SourceRequestDefinition):
29
+ scheme: Literal["https", "http"] | None = None
30
+ authentication: (
31
+ BasicAuthenticationRequest | HTTPBasicAuthenticationRequest | ClientCredentialAuthenticationRequest | None
32
+ ) = Field(None, discriminator="type")
33
+ ca_certificate: CACertificateRequest | None = None
34
+ auth_certificate: AuthCertificateRequest | None = None
35
+
36
+
37
+ class RESTSourceResponse(
38
+ SourceResponseDefinition,
39
+ RESTSource,
40
+ ResponseResource[RESTSourceRequest],
41
+ ):
42
+ authentication: (
43
+ BasicAuthenticationResponse | HTTPBasicAuthenticationResponse | ClientCredentialAuthenticationResponse | None
44
+ ) = Field(None, discriminator="type")
45
+ ca_certificate: CertificateResponse | None = None
46
+ auth_certificate: CertificateResponse | None = None
47
+
48
+ def as_request_resource(self) -> RESTSourceRequest:
49
+ return RESTSourceRequest.model_validate(self.dump(), extra="ignore")
@@ -42,3 +42,11 @@ class NameId(Identifier):
42
42
 
43
43
  def __str__(self) -> str:
44
44
  return f"name='{self.name}'"
45
+
46
+
47
+ class WorkflowVersionId(Identifier):
48
+ workflow_external_id: str
49
+ version: str
50
+
51
+ def __str__(self) -> str:
52
+ return f"workflowExternalId='{self.workflow_external_id}', version='{self.version}'"
@@ -0,0 +1,27 @@
1
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
2
+ BaseModelObject,
3
+ RequestResource,
4
+ ResponseResource,
5
+ )
6
+
7
+ from .identifiers import ExternalId
8
+
9
+
10
+ class Label(BaseModelObject):
11
+ external_id: str
12
+ name: str
13
+ description: str | None = None
14
+ data_set_id: int | None = None
15
+
16
+ def as_id(self) -> ExternalId:
17
+ return ExternalId(external_id=self.external_id)
18
+
19
+
20
+ class LabelRequest(Label, RequestResource): ...
21
+
22
+
23
+ class LabelResponse(Label, ResponseResource[LabelRequest]):
24
+ created_time: int
25
+
26
+ def as_request_resource(self) -> LabelRequest:
27
+ return LabelRequest.model_validate(self.dump(), extra="ignore")
@@ -28,8 +28,9 @@ class RAWDatabase(RequestResource, Identifier, ResponseResource["RAWDatabase"]):
28
28
 
29
29
 
30
30
  class RAWTable(RequestResource, Identifier, ResponseResource["RAWTable"]):
31
- # This is a query parameter, so we exclude it from serialization
32
- db_name: str = Field(exclude=True)
31
+ # This is a query parameter, so we exclude it from serialization.
32
+ # Default to empty string to allow parsing from API responses (which don't include db_name).
33
+ db_name: str = Field(default="", exclude=True)
33
34
  name: str
34
35
 
35
36
  def as_id(self) -> Self:
@@ -0,0 +1,24 @@
1
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
2
+ BaseModelObject,
3
+ RequestResource,
4
+ ResponseResource,
5
+ )
6
+
7
+ from .identifiers import NameId
8
+
9
+
10
+ class SecurityCategory(BaseModelObject):
11
+ name: str
12
+
13
+ def as_id(self) -> NameId:
14
+ return NameId(name=self.name)
15
+
16
+
17
+ class SecurityCategoryRequest(SecurityCategory, RequestResource): ...
18
+
19
+
20
+ class SecurityCategoryResponse(SecurityCategory, ResponseResource[SecurityCategoryRequest]):
21
+ id: int
22
+
23
+ def as_request_resource(self) -> SecurityCategoryRequest:
24
+ return SecurityCategoryRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,45 @@
1
+ from typing import ClassVar, Literal
2
+
3
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
4
+ BaseModelObject,
5
+ RequestUpdateable,
6
+ ResponseResource,
7
+ )
8
+
9
+ from .identifiers import ExternalId
10
+
11
+
12
+ class SequenceColumn(BaseModelObject):
13
+ external_id: str
14
+ name: str | None = None
15
+ description: str | None = None
16
+ metadata: dict[str, str] | None = None
17
+ value_type: Literal["STRING", "DOUBLE", "LONG"] | None = None
18
+
19
+
20
+ class Sequence(BaseModelObject):
21
+ external_id: str | None = None
22
+ name: str | None = None
23
+ description: str | None = None
24
+ asset_id: int | None = None
25
+ data_set_id: int | None = None
26
+ metadata: dict[str, str] | None = None
27
+ columns: list[SequenceColumn]
28
+
29
+ def as_id(self) -> ExternalId:
30
+ if self.external_id is None:
31
+ raise ValueError("Cannot convert Sequence to ExternalId when external_id is None")
32
+ return ExternalId(external_id=self.external_id)
33
+
34
+
35
+ class SequenceRequest(Sequence, RequestUpdateable):
36
+ container_fields: ClassVar[frozenset[str]] = frozenset({"metadata", "columns"})
37
+
38
+
39
+ class SequenceResponse(Sequence, ResponseResource[SequenceRequest]):
40
+ id: int
41
+ created_time: int
42
+ last_updated_time: int
43
+
44
+ def as_request_resource(self) -> SequenceRequest:
45
+ return SequenceRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,50 @@
1
+ from typing import Any, Literal
2
+
3
+ from pydantic import Field
4
+
5
+ from cognite_toolkit._cdf_tk.client.data_classes.base import RequestUpdateable, ResponseResource
6
+
7
+ from .identifiers import ExternalId
8
+
9
+
10
+ class SimulatorModelRequest(RequestUpdateable):
11
+ # The 'id' field is not part of the request when creating a new resource,
12
+ # but is needed when updating an existing resource.
13
+ id: int | None = Field(default=None, exclude=True)
14
+ external_id: str
15
+ simulator_external_id: str
16
+ name: str
17
+ description: str | None = None
18
+ data_set_id: int
19
+ type: str
20
+
21
+ def as_id(self) -> ExternalId:
22
+ return ExternalId(external_id=self.external_id)
23
+
24
+ def as_update(self, mode: Literal["patch", "replace"]) -> dict[str, Any]:
25
+ if self.id is None:
26
+ raise ValueError("id must be provided to create an update dictionary")
27
+ return {
28
+ "id": self.id,
29
+ "update": {
30
+ "name": {"set": self.name},
31
+ **{"description": {"set": self.description} if self.description is not None else {}},
32
+ },
33
+ }
34
+
35
+
36
+ class SimulatorModelResponse(ResponseResource[SimulatorModelRequest]):
37
+ id: int
38
+ external_id: str
39
+ simulator_external_id: str
40
+ name: str
41
+ description: str | None = None
42
+ data_set_id: int
43
+ type: str | None = None
44
+ created_time: int
45
+ last_updated_time: int
46
+
47
+ def as_request_resource(self) -> SimulatorModelRequest:
48
+ if self.type is None:
49
+ raise ValueError("Cannot convert SimulatorModelResponse to SimulatorModelRequest when type is None")
50
+ return SimulatorModelRequest.model_validate(self.dump(), extra="ignore")
@@ -1,14 +1,16 @@
1
1
  from typing import Any, ClassVar, Literal
2
2
 
3
- from cognite_toolkit._cdf_tk.client.data_classes.base import RequestUpdateable, ResponseResource
3
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
4
+ BaseModelObject,
5
+ RequestUpdateable,
6
+ ResponseResource,
7
+ )
4
8
 
5
9
  from .identifiers import ExternalId, InternalOrExternalId
6
10
  from .instance_api import NodeReference
7
11
 
8
12
 
9
- class TimeSeriesRequest(RequestUpdateable):
10
- container_fields: ClassVar[frozenset[str]] = frozenset({"metadata", "security_categories"})
11
- non_nullable_fields: ClassVar[frozenset[str]] = frozenset({"is_step"})
13
+ class TimeSeries(BaseModelObject):
12
14
  external_id: str | None = None
13
15
  name: str | None = None
14
16
  is_string: bool = False
@@ -26,30 +28,25 @@ class TimeSeriesRequest(RequestUpdateable):
26
28
  raise ValueError("Cannot convert TimeSeriesRequest to ExternalId when external_id is None")
27
29
  return ExternalId(external_id=self.external_id)
28
30
 
31
+
32
+ class TimeSeriesRequest(TimeSeries, RequestUpdateable):
33
+ container_fields: ClassVar[frozenset[str]] = frozenset({"metadata", "security_categories"})
34
+ non_nullable_fields: ClassVar[frozenset[str]] = frozenset({"is_step"})
35
+
29
36
  def as_update(self, mode: Literal["patch", "replace"]) -> dict[str, Any]:
30
37
  dumped = super().as_update(mode)
38
+ update = dumped["update"] if "update" in dumped else dumped
31
39
  # isString is immutable in CDF, so we remove it from update payloads
32
- dumped.pop("isString", None)
40
+ update.pop("isString", None)
33
41
  return dumped
34
42
 
35
43
 
36
- class TimeSeriesResponse(ResponseResource[TimeSeriesRequest]):
44
+ class TimeSeriesResponse(TimeSeries, ResponseResource[TimeSeriesRequest]):
37
45
  id: int
38
46
  instance_id: NodeReference | None = None
39
- external_id: str | None = None
40
- name: str | None = None
41
- is_string: bool
42
- metadata: dict[str, str] | None = None
43
- unit: str | None = None
44
47
  type: str
45
- unit_external_id: str | None = None
46
- asset_id: int | None = None
47
- is_step: bool
48
- description: str | None = None
49
- security_categories: list[int] | None = None
50
- data_set_id: int | None = None
51
48
  created_time: int
52
49
  last_updated_time: int
53
50
 
54
51
  def as_request_resource(self) -> TimeSeriesRequest:
55
- return TimeSeriesRequest.model_validate(self.dump())
52
+ return TimeSeriesRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,140 @@
1
+ from typing import Annotated, ClassVar, Literal
2
+
3
+ from pydantic import Field, JsonValue
4
+
5
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
6
+ BaseModelObject,
7
+ RequestUpdateable,
8
+ ResponseResource,
9
+ )
10
+
11
+ from .identifiers import ExternalId
12
+
13
+
14
+ class NonceCredentials(BaseModelObject):
15
+ nonce: str
16
+
17
+
18
+ class DestinationDefinition(BaseModelObject):
19
+ type: str
20
+
21
+
22
+ class DataModelInfo(BaseModelObject):
23
+ space: str
24
+ external_id: str
25
+ version: str
26
+ destination_type: str
27
+ destination_relationship_from_type: str | None = None
28
+
29
+
30
+ class ViewInfo(BaseModelObject):
31
+ space: str
32
+ external_id: str
33
+ version: str
34
+
35
+
36
+ class EdgeType(BaseModelObject):
37
+ space: str
38
+ external_id: str
39
+
40
+
41
+ class AssetCentricDataSource(DestinationDefinition):
42
+ type: Literal[
43
+ "assets",
44
+ "events",
45
+ "asset_hierarchy",
46
+ "datapoints",
47
+ "string_datapoints",
48
+ "timeseries",
49
+ "sequences",
50
+ "files",
51
+ "labels",
52
+ "relationships",
53
+ "data_sets",
54
+ ]
55
+
56
+
57
+ class DataModelSource(DestinationDefinition):
58
+ type: Literal["instances"] = "instances"
59
+ data_model: DataModelInfo
60
+ instance_space: str | None = None
61
+
62
+
63
+ class ViewDataSource(DestinationDefinition):
64
+ type: Literal["nodes", "edges"]
65
+ view: ViewInfo
66
+ edge_type: EdgeType | None = None
67
+ instance_space: str | None = None
68
+
69
+
70
+ class RawDataSource(DestinationDefinition):
71
+ type: Literal["raw_tables"] = "raw_tables"
72
+ database: str
73
+ table: str
74
+
75
+
76
+ class SequenceRowDataSource(DestinationDefinition):
77
+ type: Literal["sequence_rows"] = "sequence_rows"
78
+ external_id: str
79
+
80
+
81
+ Destination = Annotated[
82
+ AssetCentricDataSource | DataModelSource | ViewDataSource | RawDataSource | SequenceRowDataSource,
83
+ Field(discriminator="type"),
84
+ ]
85
+
86
+
87
+ class BlockedInfo(BaseModelObject):
88
+ reason: str
89
+ created_time: int
90
+
91
+
92
+ class SessionInfo(BaseModelObject):
93
+ client_id: str
94
+ session_id: str
95
+ project_name: str
96
+
97
+
98
+ class Transformation(BaseModelObject):
99
+ external_id: str
100
+ name: str
101
+ ignore_null_fields: bool
102
+ data_set_id: int | None = None
103
+ tags: list[str] | None = None
104
+
105
+ def as_id(self) -> ExternalId:
106
+ return ExternalId(external_id=self.external_id)
107
+
108
+
109
+ class TransformationRequest(Transformation, RequestUpdateable):
110
+ container_fields: ClassVar[frozenset[str]] = frozenset({"tags"})
111
+ non_nullable_fields: ClassVar[frozenset[str]] = frozenset({"is_public", "query", "destination"})
112
+ query: str | None = None
113
+ conflict_mode: str | None = None
114
+ destination: Destination | None = None
115
+ source_nonce: NonceCredentials | None = None
116
+ destination_nonce: NonceCredentials | None = None
117
+ is_public: bool | None = None
118
+
119
+
120
+ class TransformationResponse(Transformation, ResponseResource[TransformationRequest]):
121
+ id: int
122
+ created_time: int
123
+ last_updated_time: int
124
+ query: str
125
+ is_public: bool
126
+ conflict_mode: str
127
+ destination: Destination
128
+ blocked: BlockedInfo | None = None
129
+ owner: str
130
+ owner_is_current_user: bool
131
+ has_source_oidc_credentials: bool
132
+ has_destination_oidc_credentials: bool
133
+ source_session: SessionInfo | None = None
134
+ destination_session: SessionInfo | None = None
135
+ last_finished_job: dict[str, JsonValue] | None = None
136
+ running_job: dict[str, JsonValue] | None = None
137
+ schedule: dict[str, JsonValue] | None = None
138
+
139
+ def as_request_resource(self) -> TransformationRequest:
140
+ return TransformationRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,27 @@
1
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
2
+ BaseModelObject,
3
+ RequestResource,
4
+ ResponseResource,
5
+ )
6
+
7
+ from .identifiers import ExternalId
8
+
9
+
10
+ class Workflow(BaseModelObject):
11
+ external_id: str
12
+ description: str | None = None
13
+ data_set_id: int | None = None
14
+
15
+ def as_id(self) -> ExternalId:
16
+ return ExternalId(external_id=self.external_id)
17
+
18
+
19
+ class WorkflowRequest(Workflow, RequestResource): ...
20
+
21
+
22
+ class WorkflowResponse(Workflow, ResponseResource[WorkflowRequest]):
23
+ created_time: int
24
+ last_updated_time: int
25
+
26
+ def as_request_resource(self) -> WorkflowRequest:
27
+ return WorkflowRequest.model_validate(self.dump(), extra="ignore")
@@ -0,0 +1,63 @@
1
+ from typing import Annotated, Literal
2
+
3
+ from pydantic import Field, JsonValue
4
+
5
+ from cognite_toolkit._cdf_tk.client.data_classes.base import (
6
+ BaseModelObject,
7
+ RequestResource,
8
+ ResponseResource,
9
+ )
10
+
11
+ from .identifiers import ExternalId
12
+
13
+
14
+ class TriggerRuleDefinition(BaseModelObject):
15
+ trigger_type: str
16
+
17
+
18
+ class ScheduleTriggerRule(BaseModelObject):
19
+ trigger_type: Literal["schedule"] = "schedule"
20
+ cron_expression: str
21
+ timezone: str | None = None
22
+
23
+
24
+ class DataModelingTriggerRule(BaseModelObject):
25
+ trigger_type: Literal["dataModeling"] = "dataModeling"
26
+ data_modeling_query: JsonValue
27
+ batch_size: int
28
+ batch_timeout: int
29
+
30
+
31
+ TriggerRule = Annotated[
32
+ ScheduleTriggerRule | DataModelingTriggerRule,
33
+ Field(discriminator="trigger_type"),
34
+ ]
35
+
36
+
37
+ class NonceCredentials(BaseModelObject):
38
+ nonce: str
39
+
40
+
41
+ class WorkflowTrigger(BaseModelObject):
42
+ external_id: str
43
+ trigger_rule: TriggerRule
44
+ workflow_external_id: str
45
+ workflow_version: str
46
+ input: JsonValue | None = None
47
+ metadata: dict[str, str] | None = None
48
+
49
+ def as_id(self) -> ExternalId:
50
+ return ExternalId(external_id=self.external_id)
51
+
52
+
53
+ class WorkflowTriggerRequest(WorkflowTrigger, RequestResource):
54
+ authentication: NonceCredentials
55
+
56
+
57
+ class WorkflowTriggerResponse(WorkflowTrigger, ResponseResource[WorkflowTriggerRequest]):
58
+ created_time: int
59
+ last_updated_time: int
60
+ is_paused: bool
61
+
62
+ def as_request_resource(self) -> WorkflowTriggerRequest:
63
+ return WorkflowTriggerRequest.model_validate(self.dump(), extra="ignore")