77 DEFAULT_NUMBER_OF_PATHS_PER_PAGE ,
88 MAX_NUMBER_OF_PATHS_PER_PAGE ,
99)
10- from pydantic import BaseModel , Field , HttpUrl
10+ from pydantic import BaseModel , Field
1111
1212from ..api_schemas_rpc_async_jobs .async_jobs import (
1313 AsyncJobGet ,
@@ -52,9 +52,17 @@ def to_rpc_schema(self, location_id: LocationID) -> DataExportTaskStartInput:
5252
5353
5454class AsyncJobLinks (OutputSchema ):
55- status_href : HttpUrl
56- abort_href : HttpUrl
57- result_href : HttpUrl
55+ status_href : str
56+ abort_href : str
57+ result_href : str
58+
59+ @classmethod
60+ def from_job_id (cls , app : web .Application , job_id : str ) -> "AsyncJobLinks" :
61+ return AsyncJobLinks (
62+ status_href = f"{ app .router ['get_async_job_status' ].url_for (job_id = job_id )} " ,
63+ abort_href = f"{ app .router ['abort_async_job' ].url_for (job_id = job_id )} " ,
64+ result_href = f"{ app .router ['get_async_job_result' ].url_for (job_id = job_id )} " ,
65+ )
5866
5967
6068class StorageAsyncJobGet (OutputSchema ):
@@ -63,21 +71,13 @@ class StorageAsyncJobGet(OutputSchema):
6371
6472 @classmethod
6573 def from_rpc_schema (
66- cls , app : web .Application , async_job_rpc_get : AsyncJobGet
74+ cls , * , app : web .Application , async_job_rpc_get : AsyncJobGet
6775 ) -> "StorageAsyncJobGet" :
6876 job_id = f"{ async_job_rpc_get .job_id } "
69- links = AsyncJobLinks (
70- status_href = HttpUrl (
71- f"{ app .router ['get_async_job_status' ].url_for (job_id = job_id )} "
72- ),
73- abort_href = HttpUrl (
74- f"{ app .router ['abort_async_job' ].url_for (job_id = job_id )} "
75- ),
76- result_href = HttpUrl (
77- f"{ app .router ['get_async_job_result' ].url_for (job_id = job_id )} "
78- ),
77+ return StorageAsyncJobGet (
78+ job_id = async_job_rpc_get .job_id ,
79+ links = AsyncJobLinks .from_job_id (app = app , job_id = job_id ),
7980 )
80- return StorageAsyncJobGet (job_id = async_job_rpc_get .job_id , links = links )
8181
8282
8383class StorageAsyncJobStatus (OutputSchema ):
@@ -86,17 +86,21 @@ class StorageAsyncJobStatus(OutputSchema):
8686 done : bool
8787 started : datetime
8888 stopped : datetime | None
89+ links : AsyncJobLinks
8990
9091 @classmethod
9192 def from_rpc_schema (
92- cls , async_job_rpc_status : AsyncJobStatus
93+ cls , * , app : web . Application , async_job_rpc_status : AsyncJobStatus
9394 ) -> "StorageAsyncJobStatus" :
9495 return StorageAsyncJobStatus (
9596 job_id = async_job_rpc_status .job_id ,
9697 progress = async_job_rpc_status .progress ,
9798 done = async_job_rpc_status .done ,
9899 started = async_job_rpc_status .started ,
99100 stopped = async_job_rpc_status .stopped ,
101+ links = AsyncJobLinks .from_job_id (
102+ app = app , job_id = f"{ async_job_rpc_status .job_id } "
103+ ),
100104 )
101105
102106
0 commit comments