pinexq-client 0.2.0.2024.607.8__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 (49) hide show
  1. hypermedia_client/core/__init__.py +8 -0
  2. hypermedia_client/core/base_relations.py +8 -0
  3. hypermedia_client/core/enterapi.py +17 -0
  4. hypermedia_client/core/exceptions.py +2 -0
  5. hypermedia_client/core/hco/__init__.py +0 -0
  6. hypermedia_client/core/hco/action_hco.py +70 -0
  7. hypermedia_client/core/hco/action_with_parameters_hco.py +86 -0
  8. hypermedia_client/core/hco/download_link_hco.py +37 -0
  9. hypermedia_client/core/hco/hco_base.py +91 -0
  10. hypermedia_client/core/hco/link_hco.py +57 -0
  11. hypermedia_client/core/hco/upload_action_hco.py +113 -0
  12. hypermedia_client/core/http_headers.py +9 -0
  13. hypermedia_client/core/media_types.py +24 -0
  14. hypermedia_client/core/model/__init__.py +0 -0
  15. hypermedia_client/core/model/error.py +9 -0
  16. hypermedia_client/core/model/sirenmodels.py +155 -0
  17. hypermedia_client/core/polling.py +37 -0
  18. hypermedia_client/core/sirenaccess.py +173 -0
  19. hypermedia_client/job_management/__init__.py +6 -0
  20. hypermedia_client/job_management/enterjma.py +42 -0
  21. hypermedia_client/job_management/hcos/__init__.py +12 -0
  22. hypermedia_client/job_management/hcos/entrypoint_hco.py +57 -0
  23. hypermedia_client/job_management/hcos/info_hco.py +42 -0
  24. hypermedia_client/job_management/hcos/input_dataslot_hco.py +82 -0
  25. hypermedia_client/job_management/hcos/job_hco.py +174 -0
  26. hypermedia_client/job_management/hcos/job_query_result_hco.py +63 -0
  27. hypermedia_client/job_management/hcos/job_used_tags_hco.py +30 -0
  28. hypermedia_client/job_management/hcos/jobsroot_hco.py +80 -0
  29. hypermedia_client/job_management/hcos/output_dataslot_hco.py +44 -0
  30. hypermedia_client/job_management/hcos/processing_step_hco.py +71 -0
  31. hypermedia_client/job_management/hcos/processing_step_used_tags_hco.py +30 -0
  32. hypermedia_client/job_management/hcos/processingstep_query_result_hco.py +68 -0
  33. hypermedia_client/job_management/hcos/processingsteproot_hco.py +72 -0
  34. hypermedia_client/job_management/hcos/user_hco.py +37 -0
  35. hypermedia_client/job_management/hcos/workdata_hco.py +127 -0
  36. hypermedia_client/job_management/hcos/workdata_query_result_hco.py +67 -0
  37. hypermedia_client/job_management/hcos/workdata_used_tags_query_result_hco.py +30 -0
  38. hypermedia_client/job_management/hcos/workdataroot_hco.py +84 -0
  39. hypermedia_client/job_management/ideas.md +28 -0
  40. hypermedia_client/job_management/known_relations.py +29 -0
  41. hypermedia_client/job_management/model/__init__.py +1 -0
  42. hypermedia_client/job_management/model/open_api_generated.py +890 -0
  43. hypermedia_client/job_management/model/sirenentities.py +112 -0
  44. hypermedia_client/job_management/tool/__init__.py +1 -0
  45. hypermedia_client/job_management/tool/job.py +442 -0
  46. pinexq_client-0.2.0.2024.607.8.dist-info/METADATA +105 -0
  47. pinexq_client-0.2.0.2024.607.8.dist-info/RECORD +49 -0
  48. pinexq_client-0.2.0.2024.607.8.dist-info/WHEEL +4 -0
  49. pinexq_client-0.2.0.2024.607.8.dist-info/licenses/LICENSE +19 -0
@@ -0,0 +1,174 @@
1
+ from datetime import datetime
2
+ from typing import Self, List
3
+
4
+ import httpx
5
+ from pydantic import BaseModel, ConfigDict
6
+
7
+ from hypermedia_client.core.hco.action_hco import ActionHco
8
+ from hypermedia_client.core.hco.action_with_parameters_hco import ActionWithParametersHco
9
+ from hypermedia_client.core.hco.hco_base import Hco, Property
10
+ from hypermedia_client.core.hco.link_hco import LinkHco
11
+ from hypermedia_client.job_management.hcos import InputDataSlotHco
12
+ from hypermedia_client.job_management.hcos.output_dataslot_hco import OutputDataSlotHco
13
+ from hypermedia_client.job_management.hcos.processing_step_hco import ProcessingStepLink
14
+ from hypermedia_client.job_management.known_relations import Relations
15
+ from hypermedia_client.job_management.model.open_api_generated import JobStates, ProcessingView, RenameJobParameters, \
16
+ SelectProcessingParameters, SetJobTagsParameters
17
+ from hypermedia_client.job_management.model.sirenentities import JobEntity, InputDataSlotEntity, OutputDataSlotEntity
18
+
19
+
20
+ class JobRenameAction(ActionWithParametersHco[RenameJobParameters]):
21
+ def execute(self, parameters: RenameJobParameters):
22
+ self._execute(parameters)
23
+
24
+ def default_parameters(self) -> RenameJobParameters:
25
+ return self._get_default_parameters(RenameJobParameters, RenameJobParameters())
26
+
27
+
28
+ class JobSelectProcessingAction(ActionWithParametersHco[SelectProcessingParameters]):
29
+ def execute(self, parameters: SelectProcessingParameters):
30
+ self._execute(parameters)
31
+
32
+ def default_parameters(self) -> SelectProcessingParameters:
33
+ return self._get_default_parameters(SelectProcessingParameters, SelectProcessingParameters())
34
+
35
+
36
+ class JobHideAction(ActionHco):
37
+ def execute(self):
38
+ self._execute_internal()
39
+
40
+
41
+ class JobUnHideAction(ActionHco):
42
+ def execute(self):
43
+ self._execute_internal()
44
+
45
+
46
+ class JobAllowOutputDataDeletionAction(ActionHco):
47
+ def execute(self):
48
+ self._execute_internal()
49
+
50
+
51
+ class JobDisAllowOutputDataDeletionAction(ActionHco):
52
+ def execute(self):
53
+ self._execute_internal()
54
+
55
+
56
+ class GenericProcessingConfigureParameters(BaseModel):
57
+ """Generic parameter model, that can be set with any dictionary"""
58
+ model_config = ConfigDict(extra='allow')
59
+
60
+
61
+ class JobConfigureProcessingAction(ActionWithParametersHco[GenericProcessingConfigureParameters]):
62
+ def execute(self, parameters: GenericProcessingConfigureParameters):
63
+ self._execute(parameters)
64
+
65
+ def default_parameters(self) -> GenericProcessingConfigureParameters:
66
+ return self._get_default_parameters(GenericProcessingConfigureParameters,
67
+ GenericProcessingConfigureParameters())
68
+
69
+
70
+ class JobStartProcessingAction(ActionHco):
71
+ def execute(self):
72
+ self._execute_internal()
73
+
74
+
75
+ class JobLink(LinkHco):
76
+ def navigate(self) -> 'JobHco':
77
+ return JobHco.from_entity(self._navigate_internal(JobEntity), self._client)
78
+
79
+
80
+ class ParentJobLink(LinkHco):
81
+ def navigate(self) -> 'JobHco':
82
+ return JobHco.from_entity(self._navigate_internal(JobEntity), self._client)
83
+
84
+
85
+ class JobEditTagsAction(ActionWithParametersHco[SetJobTagsParameters]):
86
+ def execute(self, parameters: SetJobTagsParameters):
87
+ self._execute(parameters)
88
+
89
+ def default_parameters(self) -> SetJobTagsParameters:
90
+ # todo check why we have to manually set tags
91
+ return self._get_default_parameters(SetJobTagsParameters, SetJobTagsParameters(tags=[]))
92
+
93
+
94
+ class JobHco(Hco[JobEntity]):
95
+ name: str = Property()
96
+ state: JobStates = Property()
97
+ hidden: bool = Property()
98
+ tags: list[str] | None = Property()
99
+ output_is_deletable: bool = Property()
100
+ created_at: datetime = Property()
101
+ completed_at: datetime = Property()
102
+ error_description: str = Property()
103
+ processing: ProcessingView = Property()
104
+ result: str = Property()
105
+
106
+ self_link: JobLink
107
+ parent_link: ParentJobLink | None
108
+ selected_processing_step_link: ProcessingStepLink | None
109
+
110
+ rename_action: JobRenameAction
111
+ select_processing_action: JobSelectProcessingAction
112
+ configure_processing_action: JobConfigureProcessingAction
113
+ start_processing_action: JobStartProcessingAction
114
+ hide_action: JobHideAction
115
+ unhide_action: JobUnHideAction
116
+ allow_output_data_deletion_action: JobAllowOutputDataDeletionAction
117
+ disallow_output_data_deletion_action: JobDisAllowOutputDataDeletionAction
118
+ edit_tags_action: JobEditTagsAction | None
119
+
120
+ input_dataslots: List[InputDataSlotHco]
121
+ output_dataslots: List[OutputDataSlotHco]
122
+
123
+ @classmethod
124
+ def from_entity(cls, entity: JobEntity, client: httpx.Client) -> Self:
125
+ instance = cls(client, entity)
126
+
127
+ Hco.check_classes(instance._entity.class_, ["Job"])
128
+
129
+ instance.self_link = JobLink.from_entity(
130
+ instance._client, instance._entity, Relations.SELF)
131
+ instance.parent_link = ParentJobLink.from_entity_optional(
132
+ instance._client, instance._entity, Relations.PARENT_JOB)
133
+ instance.selected_processing_step_link = ProcessingStepLink.from_entity_optional(
134
+ instance._client, instance._entity, Relations.SELECTED_PROCESSING_STEP)
135
+
136
+ # actions
137
+ instance.hide_action = JobHideAction.from_entity_optional(
138
+ client, instance._entity, "Hide")
139
+ instance.unhide_action = JobUnHideAction.from_entity_optional(
140
+ client, instance._entity, "UnHide")
141
+ instance.rename_action = JobRenameAction.from_entity_optional(
142
+ client, instance._entity, "Rename")
143
+ instance.select_processing_action = JobSelectProcessingAction.from_entity_optional(
144
+ client, instance._entity, "SelectProcessing")
145
+ instance.configure_processing_action = JobConfigureProcessingAction.from_entity_optional(
146
+ client, instance._entity, "ConfigureProcessing")
147
+ instance.start_processing_action = JobStartProcessingAction.from_entity_optional(
148
+ client, instance._entity, "StartProcessing")
149
+ instance.allow_output_data_deletion_action = JobAllowOutputDataDeletionAction.from_entity_optional(
150
+ client, instance._entity, "AllowOutputDataDeletion")
151
+ instance.disallow_output_data_deletion_action = JobDisAllowOutputDataDeletionAction.from_entity_optional(
152
+ client, instance._entity, "DisallowOutputDataDeletion")
153
+ instance.edit_tags_action = JobEditTagsAction.from_entity_optional(
154
+ client, instance._entity, "EditTags")
155
+
156
+ # entities
157
+ instance._extract_input_dataslots()
158
+ instance._extract_output_dataslots()
159
+
160
+ return instance
161
+
162
+ def _extract_input_dataslots(self):
163
+ self.input_dataslots = []
164
+ input_dataslots = self._entity.find_all_entities_with_relation(Relations.INPUT_DATASLOT, InputDataSlotEntity)
165
+ for input_dataslot in input_dataslots:
166
+ input_dataslot_hco: InputDataSlotHco = InputDataSlotHco.from_entity(input_dataslot, self._client)
167
+ self.input_dataslots.append(input_dataslot_hco)
168
+
169
+ def _extract_output_dataslots(self):
170
+ self.output_dataslots = []
171
+ output_dataslots = self._entity.find_all_entities_with_relation(Relations.OUTPUT_DATASLOT, OutputDataSlotEntity)
172
+ for output_dataslot in output_dataslots:
173
+ output_dataslot_hco: OutputDataSlotHco = OutputDataSlotHco.from_entity(output_dataslot, self._client)
174
+ self.output_dataslots.append(output_dataslot_hco)
@@ -0,0 +1,63 @@
1
+ from typing import List
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core.hco.hco_base import Hco, Property
6
+ from hypermedia_client.core.hco.link_hco import LinkHco
7
+ from hypermedia_client.job_management.hcos.job_hco import JobHco
8
+ from hypermedia_client.job_management.known_relations import Relations
9
+ from hypermedia_client.job_management.model.sirenentities import JobQueryResultEntity, JobEntity
10
+
11
+
12
+ class JobQueryResultPaginationLink(LinkHco):
13
+ def navigate(self) -> 'JobQueryResultHco':
14
+ return JobQueryResultHco.from_entity(self._client, self._navigate_internal(JobQueryResultEntity))
15
+
16
+
17
+ class JobQueryResultLink(LinkHco):
18
+ def navigate(self) -> 'JobQueryResultHco':
19
+ return JobQueryResultHco.from_entity(self._client, self._navigate_internal(JobQueryResultEntity))
20
+
21
+
22
+ class JobQueryResultHco(Hco[JobQueryResultEntity]):
23
+ self_link: JobQueryResultLink
24
+ all_link: JobQueryResultPaginationLink | None
25
+ first_link: JobQueryResultPaginationLink | None
26
+ last_link: JobQueryResultPaginationLink | None
27
+ next_link: JobQueryResultPaginationLink | None
28
+ previous_link: JobQueryResultPaginationLink | None
29
+
30
+ total_entities: int = Property()
31
+ current_entities_count: int = Property()
32
+ jobs: List[JobHco]
33
+
34
+ @classmethod
35
+ def from_entity(cls, client: httpx.Client, entity: JobQueryResultEntity) -> 'JobQueryResultHco':
36
+ instance = cls(client, entity)
37
+
38
+ Hco.check_classes(instance._entity.class_, ["JobQueryResult"])
39
+
40
+ # pagination links
41
+ instance.self_link = JobQueryResultLink.from_entity(instance._client, instance._entity, Relations.SELF)
42
+ instance.all_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
43
+ Relations.ALL)
44
+ instance.first_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
45
+ Relations.FIRST)
46
+ instance.last_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
47
+ Relations.LAST)
48
+ instance.next_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
49
+ Relations.NEXT)
50
+ instance.previous_link = JobQueryResultPaginationLink.from_entity_optional(instance._client, instance._entity,
51
+ Relations.PREVIOUS)
52
+
53
+ # entities
54
+ instance._extract_jobs()
55
+
56
+ return instance
57
+
58
+ def _extract_jobs(self):
59
+ self.jobs = []
60
+ jobs = self._entity.find_all_entities_with_relation(Relations.ITEM, JobEntity)
61
+ for job in jobs:
62
+ job_hco: JobHco = JobHco.from_entity(job, self._client)
63
+ self.jobs.append(job_hco)
@@ -0,0 +1,30 @@
1
+ from typing import List, Self
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core.hco.hco_base import Hco, Property
6
+ from hypermedia_client.core.hco.link_hco import LinkHco
7
+ from hypermedia_client.job_management.known_relations import Relations
8
+ from hypermedia_client.job_management.model.sirenentities import JobUsedTagsEntity
9
+
10
+
11
+ class JobUsedTagsHco(Hco[JobUsedTagsEntity]):
12
+ tags: List[str] | None = Property()
13
+
14
+ self_link: 'JobUsedTagsLink'
15
+
16
+ @classmethod
17
+ def from_entity(cls, entity: JobUsedTagsEntity, client: httpx.Client) -> Self:
18
+ instance = cls(client, entity)
19
+
20
+ Hco.check_classes(instance._entity.class_, ["JobUsedTags"])
21
+
22
+ instance.self_link = JobUsedTagsLink.from_entity(instance._client, instance._entity, Relations.SELF)
23
+
24
+ return instance
25
+
26
+
27
+ class JobUsedTagsLink(LinkHco):
28
+ def navigate(self) -> JobUsedTagsHco:
29
+ return JobUsedTagsHco.from_entity(self._navigate_internal(JobUsedTagsEntity), self._client)
30
+
@@ -0,0 +1,80 @@
1
+ from typing import Self
2
+
3
+ import httpx
4
+ from httpx import URL
5
+
6
+ from hypermedia_client.core import MediaTypes, Link
7
+ from hypermedia_client.core.hco.action_with_parameters_hco import ActionWithParametersHco
8
+ from hypermedia_client.core.hco.hco_base import Hco
9
+ from hypermedia_client.core.hco.link_hco import LinkHco
10
+ from hypermedia_client.job_management.hcos.job_hco import JobLink
11
+ from hypermedia_client.job_management.hcos.job_query_result_hco import (
12
+ JobQueryResultHco,
13
+ JobQueryResultLink
14
+ )
15
+ from hypermedia_client.job_management.hcos.job_used_tags_hco import JobUsedTagsLink
16
+ from hypermedia_client.job_management.known_relations import Relations
17
+ from hypermedia_client.job_management.model.open_api_generated import (
18
+ CreateJobParameters,
19
+ JobQueryParameters,
20
+ CreateSubJobParameters
21
+ )
22
+ from hypermedia_client.job_management.model.sirenentities import JobsRootEntity
23
+
24
+
25
+ class CreateJobAction(ActionWithParametersHco[CreateJobParameters]):
26
+ def execute(self, parameters: CreateJobParameters) -> JobLink:
27
+ url: URL = self._execute_returns_url(parameters)
28
+ link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created job", MediaTypes.SIREN)
29
+ return JobLink.from_link(self._client, link)
30
+
31
+ def default_parameters(self) -> CreateJobParameters:
32
+ return self._get_default_parameters(CreateJobParameters, CreateJobParameters())
33
+
34
+
35
+ class CreateSubJobAction(ActionWithParametersHco[CreateSubJobParameters]):
36
+ def execute(self, parameters: CreateSubJobParameters) -> JobLink:
37
+ url = self._execute_returns_url(parameters)
38
+ link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created sub-job", MediaTypes.SIREN)
39
+ return JobLink.from_link(self._client, link)
40
+
41
+ def default_parameters(self) -> CreateSubJobParameters:
42
+ return self._get_default_parameters(CreateSubJobParameters, CreateSubJobParameters())
43
+
44
+
45
+ class JobQueryAction(ActionWithParametersHco):
46
+ def execute(self, parameters: JobQueryParameters) -> JobQueryResultHco:
47
+ url = self._execute_returns_url(parameters)
48
+ link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created job query", MediaTypes.SIREN)
49
+ # resolve link immediately
50
+ return JobQueryResultLink.from_link(self._client, link).navigate()
51
+
52
+ def default_parameters(self) -> JobQueryParameters:
53
+ return self._get_default_parameters(JobQueryParameters, JobQueryParameters())
54
+
55
+
56
+ class JobsRootHco(Hco[JobsRootEntity]):
57
+ create_job_action: CreateJobAction | None
58
+ job_query_action: JobQueryAction | None
59
+ create_subjob_action: CreateSubJobAction | None
60
+ used_tags_link: JobUsedTagsLink | None
61
+
62
+ self_link: 'JobsRootLink'
63
+
64
+ @classmethod
65
+ def from_entity(cls, entity: JobsRootEntity, client: httpx.Client) -> Self:
66
+ instance = cls(client, entity)
67
+
68
+ Hco.check_classes(instance._entity.class_, ["JobsRoot"])
69
+ instance.create_job_action = CreateJobAction.from_entity_optional(client, instance._entity, "CreateJob")
70
+ instance.create_subjob_action = CreateSubJobAction.from_entity_optional(client, instance._entity, "CreateSubJob")
71
+ instance.job_query_action = JobQueryAction.from_entity_optional(client, instance._entity, "CreateJobQuery")
72
+ instance.used_tags_link = JobUsedTagsLink.from_entity_optional(
73
+ instance._client, instance._entity, Relations.USED_TAGS)
74
+ instance.self_link = JobsRootLink.from_entity(instance._client, instance._entity, Relations.SELF)
75
+ return instance
76
+
77
+
78
+ class JobsRootLink(LinkHco):
79
+ def navigate(self) -> JobsRootHco:
80
+ return JobsRootHco.from_entity(self._navigate_internal(JobsRootEntity), self._client)
@@ -0,0 +1,44 @@
1
+ from typing import Self
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core.hco.hco_base import Hco, Property
6
+ from hypermedia_client.core.hco.link_hco import LinkHco
7
+ from hypermedia_client.job_management.hcos.workdata_hco import WorkDataHco
8
+ from hypermedia_client.job_management.known_relations import Relations
9
+ from hypermedia_client.job_management.model.sirenentities import (
10
+ OutputDataSlotEntity,
11
+ WorkDataEntity
12
+ )
13
+
14
+
15
+ class OutputDataSlotLink(LinkHco):
16
+ def navigate(self) -> 'OutputDataSlotHco':
17
+ return OutputDataSlotHco.from_entity(self._navigate_internal(OutputDataSlotEntity), self._client)
18
+
19
+
20
+ class OutputDataSlotHco(Hco[OutputDataSlotEntity]):
21
+ title: str | None = Property()
22
+ description: str | None = Property()
23
+ media_type: str | None = Property()
24
+ assigned_workdata: WorkDataHco | None
25
+
26
+ @classmethod
27
+ def from_entity(cls, entity: OutputDataSlotEntity, client: httpx.Client) -> Self:
28
+ instance = cls(client, entity)
29
+ Hco.check_classes(instance._entity.class_, ["OutputDataSlot"])
30
+
31
+ instance._extract_workdata()
32
+
33
+ return instance
34
+
35
+ def _extract_workdata(self):
36
+ self.assigned_workdatas = []
37
+
38
+ workdatas: list[WorkDataEntity] = self._entity.find_all_entities_with_relation(Relations.ASSIGNED,
39
+ WorkDataEntity)
40
+ if not workdatas:
41
+ return
42
+
43
+ self.assigned_workdatas = list[WorkDataHco](
44
+ WorkDataHco.from_entity(workdata, self._client) for workdata in workdatas)
@@ -0,0 +1,71 @@
1
+ from datetime import datetime
2
+ from typing import List, Self
3
+
4
+ import httpx
5
+
6
+ from hypermedia_client.core.hco.action_with_parameters_hco import ActionWithParametersHco
7
+ from hypermedia_client.core.hco.download_link_hco import DownloadLinkHco
8
+ from hypermedia_client.core.hco.hco_base import Hco, Property
9
+ from hypermedia_client.core.hco.link_hco import LinkHco
10
+ from hypermedia_client.job_management.known_relations import Relations
11
+ from hypermedia_client.job_management.model.open_api_generated import DataSpecificationHto, \
12
+ SetProcessingStepTagsParameters
13
+ from hypermedia_client.job_management.model.sirenentities import ProcessingStepEntity
14
+
15
+
16
+ class ProcessingStepLink(LinkHco):
17
+ def navigate(self) -> 'ProcessingStepHco':
18
+ return ProcessingStepHco.from_entity(self._navigate_internal(ProcessingStepEntity), self._client)
19
+
20
+
21
+ class ProcessingStepEditTagsAction(ActionWithParametersHco[SetProcessingStepTagsParameters]):
22
+ def execute(self, parameters: SetProcessingStepTagsParameters):
23
+ self._execute(parameters)
24
+
25
+ def default_parameters(self) -> SetProcessingStepTagsParameters:
26
+ # todo check why we have to manually set tags
27
+ return self._get_default_parameters(SetProcessingStepTagsParameters, SetProcessingStepTagsParameters(tags=[]))
28
+
29
+
30
+ class ProcessingStepHco(Hco[ProcessingStepEntity]):
31
+ title: str = Property()
32
+ version: str | None = Property()
33
+ function_name: str | None = Property()
34
+ short_description: str | None = Property()
35
+ long_description: str | None = Property()
36
+ tags: list[str] | None = Property()
37
+ has_parameters: bool | None = Property()
38
+ is_public: bool | None = Property()
39
+ is_configured: bool | None = Property()
40
+ created_at: datetime | None = Property()
41
+ last_modified_at: datetime | None = Property()
42
+ parameter_schema: str | None = Property()
43
+ default_parameters: str | None = Property()
44
+ return_schema: str | None = Property()
45
+ error_schema: str | None = Property()
46
+ input_data_slot_specification: List[DataSpecificationHto] | None = Property()
47
+ output_data_slot_specification: List[DataSpecificationHto] | None = Property()
48
+ edit_tags_action: ProcessingStepEditTagsAction | None
49
+
50
+ self_link: ProcessingStepLink
51
+ download_link: DownloadLinkHco
52
+
53
+ @classmethod
54
+ def from_entity(cls, entity: ProcessingStepEntity, client: httpx.Client) -> Self:
55
+ instance = cls(client, entity)
56
+ Hco.check_classes(instance._entity.class_, ["ProcessingStep"])
57
+
58
+ instance.self_link = ProcessingStepLink.from_entity(instance._client, instance._entity, Relations.SELF)
59
+ instance.download_link = DownloadLinkHco.from_entity(instance._client, instance._entity, Relations.DOWNLOAD)
60
+
61
+ # todo tests
62
+
63
+ # actions
64
+ # todo
65
+ # "EditProperties"
66
+ # "Upload"
67
+ # "ConfigureDefaultParameters"
68
+ # "ClearDefaultParameters"
69
+ instance.edit_tags_action = ProcessingStepEditTagsAction.from_entity_optional(
70
+ client, instance._entity, "EditTags")
71
+ return instance
@@ -0,0 +1,30 @@
1
+ from typing import List, Self
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core.hco.hco_base import Hco, Property
6
+ from hypermedia_client.core.hco.link_hco import LinkHco
7
+ from hypermedia_client.job_management.known_relations import Relations
8
+ from hypermedia_client.job_management.model.sirenentities import ProcessingStepUsedTagsEntity
9
+
10
+
11
+ class ProcessingStepUsedTagsHco(Hco[{ProcessingStepUsedTagsEntity}]):
12
+ tags: List[str] | None = Property()
13
+
14
+ self_link: 'ProcessingStepUsedTagsLink'
15
+
16
+ @classmethod
17
+ def from_entity(cls, entity: ProcessingStepUsedTagsEntity, client: httpx.Client) -> Self:
18
+ instance = cls(client, entity)
19
+
20
+ Hco.check_classes(instance._entity.class_, ["ProcessingStepUsedTags"])
21
+
22
+ instance.self_link = ProcessingStepUsedTagsLink.from_entity(instance._client, instance._entity, Relations.SELF)
23
+
24
+ return instance
25
+
26
+
27
+ class ProcessingStepUsedTagsLink(LinkHco):
28
+ def navigate(self) -> ProcessingStepUsedTagsHco:
29
+ return ProcessingStepUsedTagsHco.from_entity(self._navigate_internal(ProcessingStepUsedTagsEntity), self._client)
30
+
@@ -0,0 +1,68 @@
1
+ from typing import Self
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core.hco.hco_base import Hco, Property
6
+ from hypermedia_client.core.hco.link_hco import LinkHco
7
+ from hypermedia_client.job_management.hcos.processing_step_hco import ProcessingStepHco
8
+ from hypermedia_client.job_management.known_relations import Relations
9
+ from hypermedia_client.job_management.model.sirenentities import (
10
+ ProcessingStepQueryResultEntity,
11
+ ProcessingStepEntity
12
+ )
13
+
14
+
15
+ class ProcessingStepQueryResultPaginationLink(LinkHco):
16
+ def navigate(self) -> 'ProcessingStepQueryResultHco':
17
+ return ProcessingStepQueryResultHco.from_entity(self._navigate_internal(ProcessingStepQueryResultEntity),
18
+ self._client)
19
+
20
+
21
+ class ProcessingStepQueryResultLink(LinkHco):
22
+ def navigate(self) -> 'ProcessingStepQueryResultHco':
23
+ return ProcessingStepQueryResultHco.from_entity(self._navigate_internal(ProcessingStepQueryResultEntity),
24
+ self._client)
25
+
26
+
27
+ class ProcessingStepQueryResultHco(Hco[ProcessingStepQueryResultEntity]):
28
+ total_entities: int = Property()
29
+ current_entities_count: int = Property()
30
+ processing_steps: list[ProcessingStepHco]
31
+
32
+ self_link: ProcessingStepQueryResultLink
33
+ all_link: ProcessingStepQueryResultPaginationLink | None
34
+ first_link: ProcessingStepQueryResultPaginationLink | None
35
+ last_link: ProcessingStepQueryResultPaginationLink | None
36
+ next_link: ProcessingStepQueryResultPaginationLink | None
37
+ previous_link: ProcessingStepQueryResultPaginationLink | None
38
+
39
+ @classmethod
40
+ def from_entity(cls, entity: ProcessingStepQueryResultEntity, client: httpx.Client) -> Self:
41
+ instance = cls(client, entity)
42
+
43
+ Hco.check_classes(instance._entity.class_, ["ProcessingStepQueryResult"])
44
+
45
+ # pagination links
46
+ instance.self_link = ProcessingStepQueryResultLink.from_entity(
47
+ instance._client, instance._entity, Relations.SELF)
48
+ instance.all_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
49
+ instance._client, instance._entity, Relations.ALL)
50
+ instance.first_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
51
+ instance._client, instance._entity, Relations.FIRST)
52
+ instance.last_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
53
+ instance._client, instance._entity, Relations.LAST)
54
+ instance.next_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
55
+ instance._client, instance._entity, Relations.NEXT)
56
+ instance.previous_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
57
+ instance._client, instance._entity, Relations.PREVIOUS)
58
+
59
+ instance._extract_processing_steps()
60
+
61
+ return instance
62
+
63
+ def _extract_processing_steps(self):
64
+ self.processing_steps = []
65
+ processing_steps = self._entity.find_all_entities_with_relation(Relations.ITEM, ProcessingStepEntity)
66
+ for processing_step in processing_steps:
67
+ processing_step_hco: ProcessingStepHco = ProcessingStepHco.from_entity(processing_step, self._client)
68
+ self.processing_steps.append(processing_step_hco)
@@ -0,0 +1,72 @@
1
+ from typing import Self
2
+
3
+ import httpx
4
+
5
+ from hypermedia_client.core import MediaTypes, Link
6
+ from hypermedia_client.core.hco.action_with_parameters_hco import ActionWithParametersHco
7
+ from hypermedia_client.core.hco.hco_base import Hco
8
+ from hypermedia_client.core.hco.link_hco import LinkHco
9
+ from hypermedia_client.job_management.hcos.processing_step_hco import ProcessingStepLink, ProcessingStepHco
10
+ from hypermedia_client.job_management.hcos.processing_step_used_tags_hco import ProcessingStepUsedTagsLink
11
+ from hypermedia_client.job_management.hcos.processingstep_query_result_hco import (
12
+ ProcessingStepQueryResultHco,
13
+ ProcessingStepQueryResultLink,
14
+ ProcessingStepQueryResultPaginationLink
15
+ )
16
+ from hypermedia_client.job_management.known_relations import Relations
17
+ from hypermedia_client.job_management.model import ProcessingStepQueryParameters, CreateProcessingStepParameters
18
+ from hypermedia_client.job_management.model.sirenentities import ProcessingStepsRootEntity
19
+
20
+
21
+ class ProcessingStepQueryAction(ActionWithParametersHco[ProcessingStepQueryParameters]):
22
+ def execute(self, parameters: ProcessingStepQueryParameters) -> ProcessingStepQueryResultHco:
23
+ url = self._execute_returns_url(parameters)
24
+ link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created query", MediaTypes.SIREN)
25
+ # resolve link immediately
26
+ return ProcessingStepQueryResultLink.from_link(self._client, link).navigate()
27
+
28
+ def default_parameters(self) -> ProcessingStepQueryParameters:
29
+ return self._get_default_parameters(ProcessingStepQueryParameters, ProcessingStepQueryParameters())
30
+
31
+
32
+ class ProcessingStepRegisterNewAction(ActionWithParametersHco[CreateProcessingStepParameters]):
33
+ def execute(self, parameters: CreateProcessingStepParameters) -> ProcessingStepHco:
34
+ url = self._execute_returns_url(parameters)
35
+ link = Link.from_url(url, [str(Relations.CREATED_RESSOURCE)], "Created processing-step", MediaTypes.SIREN)
36
+ # resolve link immediately
37
+ return ProcessingStepLink.from_link(self._client, link).navigate()
38
+
39
+ def default_parameters(self) -> CreateProcessingStepParameters:
40
+ return self._get_default_parameters(CreateProcessingStepParameters, CreateProcessingStepParameters())
41
+
42
+
43
+ class ProcessingStepsRootLink(LinkHco):
44
+ def navigate(self) -> 'ProcessingStepsRootHco':
45
+ return ProcessingStepsRootHco.from_entity(self._navigate_internal(ProcessingStepsRootEntity), self._client)
46
+
47
+
48
+ class ProcessingStepsRootHco(Hco[ProcessingStepsRootEntity]):
49
+ query_action: ProcessingStepQueryAction | None
50
+ register_new_action: ProcessingStepRegisterNewAction | None
51
+
52
+ self_link: ProcessingStepsRootLink
53
+ all_link: ProcessingStepQueryResultPaginationLink | None
54
+ used_tags_link: ProcessingStepUsedTagsLink | None
55
+
56
+ @classmethod
57
+ def from_entity(cls, entity: ProcessingStepsRootEntity, client: httpx.Client) -> Self:
58
+ instance = cls(client, entity)
59
+ Hco.check_classes(instance._entity.class_, ["ProcessingStepRoot"])
60
+
61
+ instance.register_new_action = ProcessingStepRegisterNewAction.from_entity_optional(
62
+ client, instance._entity, "RegisterNewProcessingStep")
63
+ instance.query_action = ProcessingStepQueryAction.from_entity_optional(
64
+ client, instance._entity, "CreateProcessingStepQuery")
65
+ instance.used_tags_link = ProcessingStepUsedTagsLink.from_entity_optional(
66
+ instance._client, instance._entity, Relations.USED_TAGS)
67
+ instance.self_link = ProcessingStepsRootLink.from_entity(
68
+ instance._client, instance._entity, Relations.SELF)
69
+ instance.all_link = ProcessingStepQueryResultPaginationLink.from_entity_optional(
70
+ instance._client, instance._entity, Relations.ALL)
71
+
72
+ return instance
@@ -0,0 +1,37 @@
1
+ from typing import Self
2
+ from uuid import UUID
3
+
4
+ import httpx
5
+
6
+ from hypermedia_client.core.hco.hco_base import Hco, Property
7
+ from hypermedia_client.core.hco.link_hco import LinkHco
8
+ from hypermedia_client.job_management.known_relations import Relations
9
+ from hypermedia_client.job_management.model.sirenentities import UserEntity
10
+
11
+
12
+ class UserLink(LinkHco):
13
+ def navigate(self) -> "UserHco":
14
+ return UserHco.from_entity(self._navigate_internal(UserEntity), self._client)
15
+
16
+
17
+ class UserHco(Hco[UserEntity]):
18
+ user_id: UUID = Property()
19
+ user_groups: list[str] = Property()
20
+
21
+ self_link: UserLink
22
+
23
+ @classmethod
24
+ def from_entity(cls, entity: UserEntity, client: httpx.Client) -> Self:
25
+ instance = cls(client, entity)
26
+
27
+ Hco.check_classes(instance._entity.class_, ["User"])
28
+
29
+ instance.self_link = UserLink.from_entity(
30
+ instance._client, instance._entity, Relations.SELF
31
+ )
32
+
33
+ return instance
34
+
35
+ def _extract_current_user(self):
36
+ self.current_user = self._entity.find_all_entities_with_relation(
37
+ Relations.CURRENT_USER, UserEntity)