73
73
JobListingResponse ,
74
74
ProcessListingResponse ,
75
75
ValidationResponse ,
76
+ federation_extension ,
76
77
)
77
78
from openeo .rest .result import SaveResult
78
79
from openeo .rest .service import Service
@@ -734,7 +735,7 @@ def list_collections(self) -> CollectionListingResponse:
734
735
# TODO: add caching #383, but reset cache on auth change #254
735
736
# TODO #677 add pagination support?
736
737
data = self .get ("/collections" , expected_status = 200 ).json ()
737
- return CollectionListingResponse (response_data = data )
738
+ return CollectionListingResponse (response_data = data , connection = self )
738
739
739
740
def list_collection_ids (self ) -> List [str ]:
740
741
"""
@@ -776,7 +777,13 @@ def list_file_formats(self) -> dict:
776
777
key = "file_formats" ,
777
778
load = lambda : self .get ('/file_formats' , expected_status = 200 ).json ()
778
779
)
779
- return VisualDict ("file-formats" , data = formats )
780
+ federation_missing = federation_extension .get_federation_missing (data = formats , resource_name = "file_formats" )
781
+ federation = self .capabilities ().ext_federation_backend_details ()
782
+ return VisualDict (
783
+ "file-formats" ,
784
+ data = formats ,
785
+ parameters = {"missing" : federation_missing , "federation" : federation },
786
+ )
780
787
781
788
def list_service_types (self ) -> dict :
782
789
"""
@@ -800,17 +807,24 @@ def list_udf_runtimes(self) -> dict:
800
807
key = "udf_runtimes" ,
801
808
load = lambda : self .get ('/udf_runtimes' , expected_status = 200 ).json ()
802
809
)
803
- return VisualDict ("udf-runtimes" , data = runtimes )
810
+ federation = self .capabilities ().ext_federation_backend_details ()
811
+ return VisualDict ("udf-runtimes" , data = runtimes , parameters = {"federation" : federation })
804
812
805
- def list_services (self ) -> dict :
813
+ def list_services (self ) -> list :
806
814
"""
807
815
Loads all available services of the authenticated user.
808
816
809
817
:return: data_dict: Dict All available services
810
818
"""
811
819
# TODO return parsed service objects
812
820
services = self .get ('/services' , expected_status = 200 ).json ()["services" ]
813
- return VisualList ("data-table" , data = services , parameters = {'columns' : 'services' })
821
+ federation_missing = federation_extension .get_federation_missing (data = services , resource_name = "services" )
822
+ federation = self .capabilities ().ext_federation_backend_details ()
823
+ return VisualList (
824
+ "data-table" ,
825
+ data = services ,
826
+ parameters = {"columns" : "services" , "missing" : federation_missing , "federation" : federation },
827
+ )
814
828
815
829
def describe_collection (self , collection_id : str ) -> dict :
816
830
"""
@@ -827,7 +841,8 @@ def describe_collection(self, collection_id: str) -> dict:
827
841
# TODO: duplication with `Connection.collection_metadata`: deprecate one or the other?
828
842
# TODO: add caching #383
829
843
data = self .get (f"/collections/{ collection_id } " , expected_status = 200 ).json ()
830
- return VisualDict ("collection" , data = data )
844
+ federation = self .capabilities ().ext_federation_backend_details ()
845
+ return VisualDict ("collection" , data = data , parameters = {"federation" : federation })
831
846
832
847
def collection_items (
833
848
self ,
@@ -865,11 +880,22 @@ def collection_items(
865
880
if limit is not None and limit > 0 :
866
881
params ['limit' ] = limit
867
882
868
- return paginate (self , url , params , lambda response , page : VisualDict ("items" , data = response , parameters = {'show-map' : True , 'heading' : 'Page {} - Items' .format (page )}))
883
+ federation = self .capabilities ().ext_federation_backend_details ()
884
+ return paginate (
885
+ self ,
886
+ url ,
887
+ params ,
888
+ lambda response , page : VisualDict (
889
+ "items" ,
890
+ data = response ,
891
+ parameters = {"show-map" : True , "heading" : "Page {} - Items" .format (page ), "federation" : federation },
892
+ ),
893
+ )
869
894
870
895
def collection_metadata (self , name ) -> CollectionMetadata :
871
896
# TODO: duplication with `Connection.describe_collection`: deprecate one or the other?
872
- return CollectionMetadata (metadata = self .describe_collection (name ))
897
+ federation = self .capabilities ().ext_federation_backend_details ()
898
+ return CollectionMetadata (metadata = self .describe_collection (name ), _federation = federation )
873
899
874
900
def list_processes (self , namespace : Optional [str ] = None ) -> ProcessListingResponse :
875
901
"""
@@ -891,7 +917,7 @@ def list_processes(self, namespace: Optional[str] = None) -> ProcessListingRespo
891
917
)
892
918
else :
893
919
response = self .get ("/processes/" + namespace , expected_status = 200 ).json ()
894
- return ProcessListingResponse (response_data = response )
920
+ return ProcessListingResponse (response_data = response , connection = self )
895
921
896
922
def describe_process (self , id : str , namespace : Optional [str ] = None ) -> dict :
897
923
"""
@@ -904,9 +930,14 @@ def describe_process(self, id: str, namespace: Optional[str] = None) -> dict:
904
930
"""
905
931
906
932
processes = self .list_processes (namespace )
933
+ federation = self .capabilities ().ext_federation_backend_details ()
907
934
for process in processes :
908
935
if process ["id" ] == id :
909
- return VisualDict ("process" , data = process , parameters = {'show-graph' : True , 'provide-download' : False })
936
+ return VisualDict (
937
+ "process" ,
938
+ data = process ,
939
+ parameters = {"show-graph" : True , "provide-download" : False , "federation" : federation },
940
+ )
910
941
911
942
raise OpenEoClientException ("Process does not exist." )
912
943
@@ -933,7 +964,7 @@ def list_jobs(self, limit: Union[int, None] = 100) -> JobListingResponse:
933
964
# TODO: Parse the result so that Job classes returned?
934
965
# TODO: when pagination is enabled: how to expose link to next page?
935
966
resp = self .get ("/jobs" , params = {"limit" : limit }, expected_status = 200 ).json ()
936
- return JobListingResponse (response_data = resp )
967
+ return JobListingResponse (response_data = resp , connection = self )
937
968
938
969
def assert_user_defined_process_support (self ):
939
970
"""
@@ -996,7 +1027,7 @@ def list_user_defined_processes(self) -> ProcessListingResponse:
996
1027
# TODO #677 add pagination support?
997
1028
self .assert_user_defined_process_support ()
998
1029
data = self .get ("/process_graphs" , expected_status = 200 ).json ()
999
- return ProcessListingResponse (response_data = data )
1030
+ return ProcessListingResponse (response_data = data , connection = self )
1000
1031
1001
1032
def user_defined_process (self , user_defined_process_id : str ) -> RESTUserDefinedProcess :
1002
1033
"""
@@ -1496,9 +1527,15 @@ def list_files(self) -> List[UserFile]:
1496
1527
1497
1528
:return: List of the user-uploaded files.
1498
1529
"""
1499
- files = self .get ('/files' , expected_status = 200 ).json ()['files' ]
1500
- files = [UserFile .from_metadata (metadata = f , connection = self ) for f in files ]
1501
- return VisualList ("data-table" , data = files , parameters = {'columns' : 'files' })
1530
+ data = self .get ("/files" , expected_status = 200 ).json ()
1531
+ files = [UserFile .from_metadata (metadata = f , connection = self ) for f in data .get ("files" , [])]
1532
+ federation_missing = federation_extension .get_federation_missing (data = data , resource_name = "files" )
1533
+ federation = self .capabilities ().ext_federation_backend_details ()
1534
+ return VisualList (
1535
+ "data-table" ,
1536
+ data = files ,
1537
+ parameters = {"columns" : "files" , "missing" : federation_missing , "federation" : federation },
1538
+ )
1502
1539
1503
1540
def get_file (
1504
1541
self , path : Union [str , PurePosixPath ], metadata : Optional [dict ] = None
0 commit comments