pinexq-client 0.5.0.20241030.1__py3-none-any.whl → 0.9.0.20241203.1__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.
@@ -2,10 +2,13 @@ from typing import Self, Type
2
2
 
3
3
  import httpx
4
4
  from httpx import URL
5
+ from httpx import Response
5
6
 
6
- from pinexq_client.core import Link, Entity, navigate, ensure_siren_response, ClientException
7
+ from pinexq_client.core import Link, Entity, navigate, ensure_siren_response, ClientException, raise_exception_on_error, \
8
+ ApiException
7
9
  from pinexq_client.core.hco.hco_base import ClientContainer, TEntity
8
10
  from pinexq_client.core.hco.unavailable import UnavailableLink, HypermediaAvailability
11
+ from pinexq_client.core.model.error import ProblemDetails
9
12
 
10
13
 
11
14
  class LinkHco(ClientContainer, HypermediaAvailability):
@@ -51,6 +54,37 @@ class LinkHco(ClientContainer, HypermediaAvailability):
51
54
  def is_available() -> bool:
52
55
  return True
53
56
 
57
+ """Checks if the resource can be retrieved (no 404) """
58
+ def exists(self) -> bool:
59
+ response = navigate(self._client, self._link)
60
+ match response:
61
+ case Response() as r:
62
+ if r.status_code == 404:
63
+ # resource is not found
64
+ return False
65
+ elif r.status_code == 200:
66
+ # resource found
67
+ return True
68
+ elif r.status_code >= 400:
69
+ raise_exception_on_error("Expected a resource or none, got error", r)
70
+ else:
71
+ raise ApiException(f"Unexpected status code in response: {r.status_code}")
72
+
73
+ case ProblemDetails() as p:
74
+ if p.status == 404:
75
+ # resource is not found
76
+ return False
77
+ elif p.status == 200:
78
+ # resource found
79
+ return True
80
+ elif p.status >= 400:
81
+ raise_exception_on_error("Expected a resource or none, got error", p)
82
+ else:
83
+ raise ApiException(f"Unexpected status code in response: {p.status_code}")
84
+ case _:
85
+ # got entity
86
+ return True
87
+
54
88
  def _navigate_internal(self, parse_type: Type[TEntity] = Entity) -> TEntity:
55
89
  response = navigate(self._client, self._link, parse_type)
56
90
  return ensure_siren_response(response)
@@ -58,6 +92,13 @@ class LinkHco(ClientContainer, HypermediaAvailability):
58
92
  def get_url(self) -> URL:
59
93
  return URL(self._link.href)
60
94
 
95
+ def __eq__(self, other):
96
+ """Compares the link url to determine if the link is pointing to the same resource."""
97
+ if isinstance(other, LinkHco):
98
+ return self.get_url() == other.get_url()
99
+ else:
100
+ return NotImplemented
101
+
61
102
  def __repr__(self):
62
103
  rel_names = ', '.join((f"'{r}'" for r in self._link.rel))
63
104
  return f"<{self.__class__.__name__}: {rel_names}>"
@@ -19,6 +19,9 @@ class MediaTypes(StrEnum):
19
19
  JPEG = "image/jpeg"
20
20
  BMP = "image/bmp"
21
21
 
22
+ WORKFLOW_DEFINITION = "application/vnd.pinexq.workflow.definition+json"
23
+ WORKFLOW_REPORT = "application/vnd.pinexq.workflow.report+json"
24
+
22
25
 
23
26
  class SirenClasses(StrEnum):
24
27
  FileUploadAction = "FileUploadAction"
@@ -1,6 +1,6 @@
1
1
  from typing import Any
2
2
 
3
- from pydantic import BaseModel, Field, ConfigDict
3
+ from pydantic import BaseModel
4
4
 
5
5
 
6
6
  class ProblemDetails(BaseModel):
@@ -43,12 +43,11 @@ def get_resource(client: httpx.Client, href: str, media_type: str = MediaTypes.S
43
43
  warnings.warn(f"Unexpected return code: {response.status_code}")
44
44
  return response
45
45
 
46
-
47
- def navigate(client: httpx.Client, link: Link,
46
+ def navigate(client: httpx.Client,
47
+ link: Link,
48
48
  parse_type: type[TEntity] = Entity) -> TEntity | ProblemDetails | Response:
49
49
  return get_resource(client, link.href, link.type, parse_type)
50
50
 
51
-
52
51
  def ensure_siren_response(response: TEntity | ProblemDetails | Response) -> TEntity:
53
52
  raise_exception_on_error(f"Error while navigating, unexpected response", response)
54
53
  return response
@@ -3,4 +3,4 @@ from .enterjma import enter_jma
3
3
  from .tool import Job, ProcessingStep, WorkData
4
4
 
5
5
  # Protocol version the JMA is using
6
- __jma_version__ = [7, 0, 0]
6
+ __jma_version__ = [7, 3, 0]
@@ -1,4 +1,5 @@
1
1
  from .input_dataslot_hco import *
2
+ from .output_dataslot_hco import *
2
3
  from .entrypoint_hco import *
3
4
  from .info_hco import *
4
5
  from .job_hco import *
@@ -1,5 +1,5 @@
1
1
  from datetime import datetime
2
- from typing import Self, List
2
+ from typing import Self, List, TYPE_CHECKING
3
3
 
4
4
  import httpx
5
5
  from pydantic import BaseModel, ConfigDict
@@ -9,8 +9,6 @@ from pinexq_client.core.hco.action_with_parameters_hco import ActionWithParamete
9
9
  from pinexq_client.core.hco.hco_base import Hco, Property
10
10
  from pinexq_client.core.hco.link_hco import LinkHco
11
11
  from pinexq_client.core.hco.unavailable import UnavailableAction, UnavailableLink
12
- from pinexq_client.job_management.hcos import InputDataSlotHco
13
- from pinexq_client.job_management.hcos.output_dataslot_hco import OutputDataSlotHco
14
12
  from pinexq_client.job_management.hcos.processing_step_hco import ProcessingStepLink
15
13
  from pinexq_client.job_management.known_relations import Relations
16
14
  from pinexq_client.job_management.model import SetJobErrorStateParameters
@@ -18,6 +16,10 @@ from pinexq_client.job_management.model.open_api_generated import JobStates, Pro
18
16
  SelectProcessingParameters, SetJobTagsParameters
19
17
  from pinexq_client.job_management.model.sirenentities import JobEntity, InputDataSlotEntity, OutputDataSlotEntity
20
18
 
19
+ if TYPE_CHECKING:
20
+ from pinexq_client.job_management.hcos.input_dataslot_hco import InputDataSlotHco
21
+ from pinexq_client.job_management.hcos.output_dataslot_hco import OutputDataSlotHco
22
+
21
23
 
22
24
  class JobRenameAction(ActionWithParametersHco[RenameJobParameters]):
23
25
  def execute(self, parameters: RenameJobParameters):
@@ -136,8 +138,8 @@ class JobHco(Hco[JobEntity]):
136
138
  edit_tags_action: JobEditTagsAction | UnavailableAction
137
139
  set_to_error_state_action: JobSetToErrorStateAction | UnavailableAction
138
140
 
139
- input_dataslots: List[InputDataSlotHco]
140
- output_dataslots: List[OutputDataSlotHco]
141
+ input_dataslots: List["InputDataSlotHco"]
142
+ output_dataslots: List["OutputDataSlotHco"]
141
143
 
142
144
  @classmethod
143
145
  def from_entity(cls, entity: JobEntity, client: httpx.Client) -> Self:
@@ -183,6 +185,7 @@ class JobHco(Hco[JobEntity]):
183
185
  return instance
184
186
 
185
187
  def _extract_input_dataslots(self):
188
+ from pinexq_client.job_management.hcos.input_dataslot_hco import InputDataSlotHco
186
189
  self.input_dataslots = []
187
190
  input_dataslots = self._entity.find_all_entities_with_relation(Relations.INPUT_DATASLOT, InputDataSlotEntity)
188
191
  for input_dataslot in input_dataslots:
@@ -190,6 +193,7 @@ class JobHco(Hco[JobEntity]):
190
193
  self.input_dataslots.append(input_dataslot_hco)
191
194
 
192
195
  def _extract_output_dataslots(self):
196
+ from pinexq_client.job_management.hcos.output_dataslot_hco import OutputDataSlotHco
193
197
  self.output_dataslots = []
194
198
  output_dataslots = self._entity.find_all_entities_with_relation(Relations.OUTPUT_DATASLOT, OutputDataSlotEntity)
195
199
  for output_dataslot in output_dataslots:
@@ -13,103 +13,103 @@ from pinexq_client.core.hco.link_hco import LinkHco
13
13
  from pinexq_client.core.hco.unavailable import UnavailableAction
14
14
  from pinexq_client.core.hco.upload_action_hco import UploadAction, UploadParameters
15
15
  from pinexq_client.job_management.known_relations import Relations
16
- from pinexq_client.job_management.model import EditProcessingStepParameters
17
16
  from pinexq_client.job_management.model.open_api_generated import DataSpecificationHto, \
18
- SetProcessingStepTagsParameters
17
+ SetProcessingStepTagsParameters, EditProcessingStepParameters
19
18
  from pinexq_client.job_management.model.sirenentities import ProcessingStepEntity
20
19
 
21
20
 
22
21
  class ProcessingStepLink(LinkHco):
23
- def navigate(self) -> 'ProcessingStepHco':
24
- return ProcessingStepHco.from_entity(self._navigate_internal(ProcessingStepEntity), self._client)
22
+ def navigate(self) -> 'ProcessingStepHco':
23
+ return ProcessingStepHco.from_entity(self._navigate_internal(ProcessingStepEntity), self._client)
25
24
 
26
25
 
27
26
  class ProcessingStepEditTagsAction(ActionWithParametersHco[SetProcessingStepTagsParameters]):
28
- def execute(self, parameters: SetProcessingStepTagsParameters):
29
- self._execute(parameters)
27
+ def execute(self, parameters: SetProcessingStepTagsParameters):
28
+ self._execute(parameters)
30
29
 
31
- def default_parameters(self) -> SetProcessingStepTagsParameters:
32
- # todo check why we have to manually set tags
33
- return self._get_default_parameters(SetProcessingStepTagsParameters, SetProcessingStepTagsParameters(tags=[]))
30
+ def default_parameters(self) -> SetProcessingStepTagsParameters:
31
+ # todo check why we have to manually set tags
32
+ return self._get_default_parameters(SetProcessingStepTagsParameters, SetProcessingStepTagsParameters(tags=[]))
34
33
 
35
34
 
36
35
  class ProcessingStepEditPropertiesAction(ActionWithParametersHco[EditProcessingStepParameters]):
37
- def execute(self, parameters: EditProcessingStepParameters):
38
- self._execute(parameters)
36
+ def execute(self, parameters: EditProcessingStepParameters):
37
+ self._execute(parameters)
39
38
 
40
- def default_parameters(self) -> EditProcessingStepParameters:
41
- return self._get_default_parameters(EditProcessingStepParameters, EditProcessingStepParameters())
39
+ def default_parameters(self) -> EditProcessingStepParameters:
40
+ return self._get_default_parameters(EditProcessingStepParameters,
41
+ EditProcessingStepParameters())
42
42
 
43
43
 
44
44
  class GenericProcessingConfigureParameters(BaseModel):
45
- """Generic parameter model, that can be set with any dictionary"""
46
- model_config = ConfigDict(extra='allow')
45
+ """Generic parameter model, that can be set with any dictionary"""
46
+ model_config = ConfigDict(extra='allow')
47
47
 
48
48
 
49
49
  class ConfigureDefaultParametersAction(ActionWithParametersHco[GenericProcessingConfigureParameters]):
50
- def execute(self, parameters: GenericProcessingConfigureParameters):
51
- self._execute(parameters)
50
+ def execute(self, parameters: GenericProcessingConfigureParameters):
51
+ self._execute(parameters)
52
52
 
53
- def default_parameters(self) -> GenericProcessingConfigureParameters:
54
- return self._get_default_parameters(GenericProcessingConfigureParameters,
55
- GenericProcessingConfigureParameters())
53
+ def default_parameters(self) -> GenericProcessingConfigureParameters:
54
+ return self._get_default_parameters(GenericProcessingConfigureParameters,
55
+ GenericProcessingConfigureParameters())
56
56
 
57
57
 
58
58
  class ClearDefaultParametersAction(ActionHco):
59
- def execute(self):
60
- self._execute_internal()
59
+ def execute(self):
60
+ self._execute_internal()
61
61
 
62
62
 
63
63
  class UploadConfigurationAction(UploadAction):
64
- def execute(self, parameters: UploadParameters):
65
- upload_json(self._client, self._action, parameters.json_, parameters.filename)
64
+ def execute(self, parameters: UploadParameters):
65
+ upload_json(self._client, self._action, parameters.json_, parameters.filename)
66
66
 
67
67
 
68
68
  class ProcessingStepHco(Hco[ProcessingStepEntity]):
69
- title: str = Property()
70
- version: str | None = Property()
71
- function_name: str | None = Property()
72
- short_description: str | None = Property()
73
- long_description: str | None = Property()
74
- tags: list[str] | None = Property()
75
- has_parameters: bool | None = Property()
76
- is_public: bool | None = Property()
77
- is_configured: bool | None = Property()
78
- created_at: datetime | None = Property()
79
- last_modified_at: datetime | None = Property()
80
- parameter_schema: str | None = Property()
81
- default_parameters: str | None = Property()
82
- return_schema: str | None = Property()
83
- error_schema: str | None = Property()
84
- input_data_slot_specification: List[DataSpecificationHto] | None = Property()
85
- output_data_slot_specification: List[DataSpecificationHto] | None = Property()
86
- edit_tags_action: ProcessingStepEditTagsAction | UnavailableAction
87
- edit_properties_action: ProcessingStepEditPropertiesAction | UnavailableAction
88
- configure_default_parameters_action: ConfigureDefaultParametersAction | UnavailableAction
89
- clear_default_parameters_action: ClearDefaultParametersAction | UnavailableAction
90
- upload_configuration_action: UploadConfigurationAction | None
91
-
92
- self_link: ProcessingStepLink
93
- download_link: DownloadLinkHco
94
-
95
- @classmethod
96
- def from_entity(cls, entity: ProcessingStepEntity, client: httpx.Client) -> Self:
97
- instance = cls(client, entity)
98
- Hco.check_classes(instance._entity.class_, ["ProcessingStep"])
99
-
100
- instance.self_link = ProcessingStepLink.from_entity(instance._client, instance._entity, Relations.SELF)
101
- instance.download_link = DownloadLinkHco.from_entity(instance._client, instance._entity, Relations.DOWNLOAD)
102
-
103
- # todo tests
104
-
105
- instance.edit_tags_action = ProcessingStepEditTagsAction.from_entity_optional(
106
- client, instance._entity, "EditTags")
107
- instance.edit_properties_action = ProcessingStepEditPropertiesAction.from_entity_optional(
108
- client, instance._entity, "EditProperties")
109
- instance.configure_default_parameters_action = ConfigureDefaultParametersAction.from_entity_optional(
110
- client, instance._entity, "ConfigureDefaultParameters")
111
- instance.clear_default_parameters_action = ClearDefaultParametersAction.from_entity_optional(
112
- client, instance._entity, "ClearDefaultParameters")
113
- instance.upload_configuration_action = UploadConfigurationAction.from_entity_optional(
114
- client, instance._entity, "Upload")
115
- return instance
69
+ title: str = Property()
70
+ version: str | None = Property()
71
+ function_name: str | None = Property()
72
+ short_description: str | None = Property()
73
+ long_description: str | None = Property()
74
+ tags: list[str] | None = Property()
75
+ has_parameters: bool | None = Property()
76
+ is_public: bool | None = Property()
77
+ is_configured: bool | None = Property()
78
+ created_at: datetime | None = Property()
79
+ last_modified_at: datetime | None = Property()
80
+ parameter_schema: str | None = Property()
81
+ default_parameters: str | None = Property()
82
+ return_schema: str | None = Property()
83
+ error_schema: str | None = Property()
84
+ input_data_slot_specification: List[DataSpecificationHto] | None = Property()
85
+ output_data_slot_specification: List[DataSpecificationHto] | None = Property()
86
+ edit_tags_action: ProcessingStepEditTagsAction | UnavailableAction
87
+ edit_properties_action: ProcessingStepEditPropertiesAction | UnavailableAction
88
+ configure_default_parameters_action: ConfigureDefaultParametersAction | UnavailableAction
89
+ clear_default_parameters_action: ClearDefaultParametersAction | UnavailableAction
90
+ upload_configuration_action: UploadConfigurationAction | None
91
+
92
+ self_link: ProcessingStepLink
93
+ download_link: DownloadLinkHco
94
+
95
+ @classmethod
96
+ def from_entity(cls, entity: ProcessingStepEntity, client: httpx.Client) -> Self:
97
+ instance = cls(client, entity)
98
+ Hco.check_classes(instance._entity.class_, ["ProcessingStep"])
99
+
100
+ instance.self_link = ProcessingStepLink.from_entity(instance._client, instance._entity, Relations.SELF)
101
+ instance.download_link = DownloadLinkHco.from_entity(instance._client, instance._entity, Relations.DOWNLOAD)
102
+
103
+ # todo tests
104
+
105
+ instance.edit_tags_action = ProcessingStepEditTagsAction.from_entity_optional(
106
+ client, instance._entity, "EditTags")
107
+ instance.edit_properties_action = ProcessingStepEditPropertiesAction.from_entity_optional(
108
+ client, instance._entity, "EditProperties")
109
+ instance.configure_default_parameters_action = ConfigureDefaultParametersAction.from_entity_optional(
110
+ client, instance._entity, "ConfigureDefaultParameters")
111
+ instance.clear_default_parameters_action = ClearDefaultParametersAction.from_entity_optional(
112
+ client, instance._entity, "ClearDefaultParameters")
113
+ instance.upload_configuration_action = UploadConfigurationAction.from_entity_optional(
114
+ client, instance._entity, "Upload")
115
+ return instance
@@ -8,121 +8,129 @@ from pinexq_client.core.hco.action_with_parameters_hco import ActionWithParamete
8
8
  from pinexq_client.core.hco.download_link_hco import DownloadLinkHco
9
9
  from pinexq_client.core.hco.hco_base import Hco, Property
10
10
  from pinexq_client.core.hco.link_hco import LinkHco
11
- from pinexq_client.core.hco.unavailable import UnavailableAction
11
+ from pinexq_client.core.hco.unavailable import UnavailableAction, UnavailableLink
12
+ from pinexq_client.job_management.hcos.processing_step_hco import ProcessingStepLink
13
+ from pinexq_client.job_management.hcos.job_hco import JobLink
12
14
  from pinexq_client.job_management.known_relations import Relations
13
15
  from pinexq_client.job_management.model.open_api_generated import (
14
- SetNameWorkDataParameters,
15
- SetCommentWorkDataParameters,
16
- SetTagsWorkDataParameters,
17
- WorkDataKind
16
+ SetNameWorkDataParameters,
17
+ SetCommentWorkDataParameters,
18
+ SetTagsWorkDataParameters,
19
+ WorkDataKind
18
20
  )
19
21
  from pinexq_client.job_management.model.sirenentities import WorkDataEntity
20
22
 
21
23
 
22
24
  class WorkDataLink(LinkHco):
23
- def navigate(self) -> 'WorkDataHco':
24
- return WorkDataHco.from_entity(self._navigate_internal(WorkDataEntity), self._client)
25
+ def navigate(self) -> 'WorkDataHco':
26
+ return WorkDataHco.from_entity(self._navigate_internal(WorkDataEntity), self._client)
25
27
 
26
28
 
27
29
  class WorkDataDeleteAction(ActionHco):
28
- def execute(self):
29
- self._execute_internal()
30
+ def execute(self):
31
+ self._execute_internal()
30
32
 
31
33
 
32
34
  class WorkDataRenameAction(ActionWithParametersHco[SetNameWorkDataParameters]):
33
- def execute(self, parameters: SetNameWorkDataParameters):
34
- self._execute(parameters)
35
+ def execute(self, parameters: SetNameWorkDataParameters):
36
+ self._execute(parameters)
35
37
 
36
- def default_parameters(self) -> SetNameWorkDataParameters:
37
- return self._get_default_parameters(SetNameWorkDataParameters, SetNameWorkDataParameters())
38
+ def default_parameters(self) -> SetNameWorkDataParameters:
39
+ return self._get_default_parameters(SetNameWorkDataParameters, SetNameWorkDataParameters())
38
40
 
39
41
 
40
42
  class WorkDataEditCommentAction(ActionWithParametersHco[SetCommentWorkDataParameters]):
41
- def execute(self, parameters: SetCommentWorkDataParameters):
42
- self._execute(parameters)
43
+ def execute(self, parameters: SetCommentWorkDataParameters):
44
+ self._execute(parameters)
43
45
 
44
- def default_parameters(self) -> SetCommentWorkDataParameters:
45
- return self._get_default_parameters(SetCommentWorkDataParameters, SetCommentWorkDataParameters())
46
+ def default_parameters(self) -> SetCommentWorkDataParameters:
47
+ return self._get_default_parameters(SetCommentWorkDataParameters, SetCommentWorkDataParameters())
46
48
 
47
49
 
48
50
  class WorkDataEditTagsAction(ActionWithParametersHco[SetTagsWorkDataParameters]):
49
- def execute(self, parameters: SetTagsWorkDataParameters):
50
- self._execute(parameters)
51
+ def execute(self, parameters: SetTagsWorkDataParameters):
52
+ self._execute(parameters)
51
53
 
52
- def default_parameters(self) -> SetTagsWorkDataParameters:
53
- # todo check why we have to manually set tags
54
- return self._get_default_parameters(SetTagsWorkDataParameters, SetTagsWorkDataParameters(tags=[]))
54
+ def default_parameters(self) -> SetTagsWorkDataParameters:
55
+ # todo check why we have to manually set tags
56
+ return self._get_default_parameters(SetTagsWorkDataParameters, SetTagsWorkDataParameters(tags=[]))
55
57
 
56
58
 
57
59
  class WorkDataAllowDeletionAction(ActionHco):
58
- def execute(self):
59
- self._execute_internal()
60
+ def execute(self):
61
+ self._execute_internal()
60
62
 
61
63
 
62
64
  class WorkDataDisallowAction(ActionHco):
63
- def execute(self):
64
- self._execute_internal()
65
+ def execute(self):
66
+ self._execute_internal()
65
67
 
66
68
 
67
69
  class WorkDataHideAction(ActionHco):
68
- def execute(self):
69
- self._execute_internal()
70
+ def execute(self):
71
+ self._execute_internal()
70
72
 
71
73
 
72
74
  class WorkDataUnHideAction(ActionHco):
73
- def execute(self):
74
- self._execute_internal()
75
+ def execute(self):
76
+ self._execute_internal()
75
77
 
76
78
 
77
79
  class WorkDataHco(Hco[WorkDataEntity]):
78
- name: str | None = Property()
79
- created_at: datetime | None = Property()
80
- size_in_bytes: int | None = Property()
81
- tags: list[str] | None = Property()
82
- media_type: str | None = Property()
83
- kind: WorkDataKind | None = Property()
84
- comments: str | None = Property()
85
- is_deletable: bool | None = Property()
86
- hidden: bool | None = Property()
87
-
88
- delete_action: WorkDataDeleteAction | UnavailableAction
89
- hide_action: WorkDataHideAction | UnavailableAction
90
- unhide_action: WorkDataUnHideAction | UnavailableAction
91
- allow_deletion_action: WorkDataAllowDeletionAction | UnavailableAction
92
- disallow_deletion_action: WorkDataDisallowAction | UnavailableAction
93
- rename_action: WorkDataRenameAction | UnavailableAction
94
- edit_comment_action: WorkDataEditCommentAction | UnavailableAction
95
- edit_tags_action: WorkDataEditTagsAction | UnavailableAction
96
-
97
- self_link: WorkDataLink
98
- download_link: DownloadLinkHco
99
-
100
- @classmethod
101
- def from_entity(cls, entity: WorkDataEntity, client: httpx.Client) -> Self:
102
- instance = cls(client, entity)
103
- Hco.check_classes(instance._entity.class_, ["WorkData"])
104
-
105
- # actions
106
- instance.hide_action = WorkDataHideAction.from_entity_optional(
107
- client, instance._entity, "Hide")
108
- instance.unhide_action = WorkDataUnHideAction.from_entity_optional(
109
- client, instance._entity, "UnHide")
110
- instance.delete_action = WorkDataDeleteAction.from_entity_optional(
111
- client, instance._entity, "Delete")
112
- instance.rename_action = WorkDataRenameAction.from_entity_optional(
113
- client, instance._entity, "Rename")
114
- instance.edit_comment_action = WorkDataEditCommentAction.from_entity_optional(
115
- client, instance._entity, "EditComment")
116
- instance.edit_tags_action = WorkDataEditTagsAction.from_entity_optional(
117
- client, instance._entity, "EditTags")
118
- instance.allow_deletion_action = WorkDataAllowDeletionAction.from_entity_optional(
119
- client, instance._entity, "AllowDeletion")
120
- instance.disallow_deletion_action = WorkDataDisallowAction.from_entity_optional(
121
- client, instance._entity, "DisallowDeletion")
122
-
123
- # links
124
- instance.self_link = WorkDataLink.from_entity(
125
- instance._client, instance._entity, Relations.SELF)
126
- instance.download_link = DownloadLinkHco.from_entity(
127
- instance._client, instance._entity, Relations.DOWNLOAD)
128
- return instance
80
+ name: str | None = Property()
81
+ created_at: datetime | None = Property()
82
+ size_in_bytes: int | None = Property()
83
+ tags: list[str] | None = Property()
84
+ media_type: str | None = Property()
85
+ kind: WorkDataKind | None = Property()
86
+ comments: str | None = Property()
87
+ is_deletable: bool | None = Property()
88
+ hidden: bool | None = Property()
89
+
90
+ delete_action: WorkDataDeleteAction | UnavailableAction
91
+ hide_action: WorkDataHideAction | UnavailableAction
92
+ unhide_action: WorkDataUnHideAction | UnavailableAction
93
+ allow_deletion_action: WorkDataAllowDeletionAction | UnavailableAction
94
+ disallow_deletion_action: WorkDataDisallowAction | UnavailableAction
95
+ rename_action: WorkDataRenameAction | UnavailableAction
96
+ edit_comment_action: WorkDataEditCommentAction | UnavailableAction
97
+ edit_tags_action: WorkDataEditTagsAction | UnavailableAction
98
+
99
+ self_link: WorkDataLink
100
+ download_link: DownloadLinkHco
101
+ producer_job_link: JobLink | UnavailableLink
102
+ producer_processing_step_link: ProcessingStepLink | UnavailableLink
103
+
104
+ @classmethod
105
+ def from_entity(cls, entity: WorkDataEntity, client: httpx.Client) -> Self:
106
+ instance = cls(client, entity)
107
+ Hco.check_classes(instance._entity.class_, ["WorkData"])
108
+
109
+ # actions
110
+ instance.hide_action = WorkDataHideAction.from_entity_optional(
111
+ client, instance._entity, "Hide")
112
+ instance.unhide_action = WorkDataUnHideAction.from_entity_optional(
113
+ client, instance._entity, "UnHide")
114
+ instance.delete_action = WorkDataDeleteAction.from_entity_optional(
115
+ client, instance._entity, "Delete")
116
+ instance.rename_action = WorkDataRenameAction.from_entity_optional(
117
+ client, instance._entity, "Rename")
118
+ instance.edit_comment_action = WorkDataEditCommentAction.from_entity_optional(
119
+ client, instance._entity, "EditComment")
120
+ instance.edit_tags_action = WorkDataEditTagsAction.from_entity_optional(
121
+ client, instance._entity, "EditTags")
122
+ instance.allow_deletion_action = WorkDataAllowDeletionAction.from_entity_optional(
123
+ client, instance._entity, "AllowDeletion")
124
+ instance.disallow_deletion_action = WorkDataDisallowAction.from_entity_optional(
125
+ client, instance._entity, "DisallowDeletion")
126
+
127
+ # links
128
+ instance.self_link = WorkDataLink.from_entity(
129
+ instance._client, instance._entity, Relations.SELF)
130
+ instance.download_link = DownloadLinkHco.from_entity(
131
+ instance._client, instance._entity, Relations.DOWNLOAD)
132
+ instance.producer_job_link = JobLink.from_entity_optional(
133
+ instance._client, instance._entity, Relations.PRODUCED_BY_JOB)
134
+ instance.producer_processing_step_link = ProcessingStepLink.from_entity_optional(
135
+ instance._client, instance._entity, Relations.PRODUCED_BY_PROCESSING_STEP)
136
+ return instance
@@ -21,6 +21,10 @@ class Relations(StrEnum):
21
21
  INPUT_DATASLOT = "InputDataSlot"
22
22
  OUTPUT_DATASLOT = "OutputDataSlot"
23
23
 
24
+ # workdata
25
+ PRODUCED_BY_JOB = "ProducedByJob"
26
+ PRODUCED_BY_PROCESSING_STEP = "ProducedByProcessingStep"
27
+
24
28
  # dataslots
25
29
  SELECTED = "Selected"
26
30
  ASSIGNED = "Assigned"