5
5
from typing import List , Optional , Union
6
6
7
7
from openeo .internal .jupyter import render_component
8
- from openeo .rest .models . federation_extension import FederationExtension
8
+ from openeo .rest .models import federation_extension
9
9
from openeo .rest .models .logs import LogEntry , normalize_log_level
10
10
11
11
@@ -43,8 +43,6 @@ class CollectionListingResponse(list):
43
43
but now also provides methods/properties to access additional response data.
44
44
45
45
:param response_data: response data from a ``GET /collections`` request
46
- :param warn_on_federation_missing: whether to automatically warn
47
- about missing federation components.
48
46
49
47
.. seealso:: :py:meth:`openeo.rest.connection.Connection.list_collections()`
50
48
@@ -53,12 +51,12 @@ class CollectionListingResponse(list):
53
51
54
52
__slots__ = ["_data" ]
55
53
56
- def __init__ (self , response_data : dict , * , warn_on_federation_missing : bool = True ):
54
+ def __init__ (self , response_data : dict ):
57
55
self ._data = response_data
58
56
# Mimic original list of collection metadata dictionaries
59
57
super ().__init__ (response_data ["collections" ])
60
- if warn_on_federation_missing :
61
- self .ext_federation . warn_on_missing ( resource_name = "collection listing" )
58
+
59
+ self .ext_federation_missing ( auto_warn = True )
62
60
63
61
def _repr_html_ (self ):
64
62
return render_component (component = "collections" , data = self )
@@ -68,11 +66,20 @@ def links(self) -> List[Link]:
68
66
"""Get links related to this resource."""
69
67
return [Link .from_dict (d ) for d in self ._data .get ("links" , [])]
70
68
71
- @property
72
- def ext_federation (self ) -> FederationExtension :
73
- """Accessor for federation extension data related to this resource."""
74
- return FederationExtension (self ._data )
69
+ def ext_federation_missing (self , * , auto_warn : bool = False ) -> Union [None , List [str ]]:
70
+ """
71
+ List of backends IDs (from the federation)
72
+ that were not available during the resource listing request.
73
+
74
+ :param auto_warn: whether to automatically log a warning if missing federation components are detected.
75
75
76
+ .. seealso:: :ref:`federation-extension`
77
+
78
+ .. warning:: this API is experimental and subject to change.
79
+ """
80
+ return federation_extension .get_federation_missing (
81
+ data = self ._data , resource_name = "collection listing" , auto_warn = auto_warn
82
+ )
76
83
77
84
class ProcessListingResponse (list ):
78
85
"""
@@ -86,22 +93,21 @@ class ProcessListingResponse(list):
86
93
but now also provides methods/properties to access additional response data.
87
94
88
95
:param response_data: response data from a ``GET /processes`` request
89
- :param warn_on_federation_missing: whether to automatically warn
90
- about missing federation components.
91
96
92
97
.. seealso:: :py:meth:`openeo.rest.connection.Connection.list_processes()`
93
98
94
99
.. versionadded:: 0.38.0
95
100
"""
96
101
102
+
97
103
__slots__ = ["_data" ]
98
104
99
- def __init__ (self , response_data : dict , * , warn_on_federation_missing : bool = True ):
105
+ def __init__ (self , response_data : dict ):
100
106
self ._data = response_data
101
107
# Mimic original list of process metadata dictionaries
102
108
super ().__init__ (response_data ["processes" ])
103
- if warn_on_federation_missing :
104
- self .ext_federation . warn_on_missing ( resource_name = "process listing" )
109
+
110
+ self .ext_federation_missing ( auto_warn = True )
105
111
106
112
def _repr_html_ (self ):
107
113
return render_component (
@@ -113,11 +119,20 @@ def links(self) -> List[Link]:
113
119
"""Get links related to this resource."""
114
120
return [Link .from_dict (d ) for d in self ._data .get ("links" , [])]
115
121
116
- @property
117
- def ext_federation (self ) -> FederationExtension :
118
- """Accessor for federation extension data related to this resource."""
119
- return FederationExtension (self ._data )
122
+ def ext_federation_missing (self , * , auto_warn : bool = False ) -> Union [None , List [str ]]:
123
+ """
124
+ List of backends IDs (from the federation)
125
+ that were not available during the resource listing request.
126
+
127
+ :param auto_warn: whether to automatically log a warning if missing federation components are detected.
120
128
129
+ .. seealso:: :ref:`federation-extension`
130
+
131
+ .. warning:: this API is experimental and subject to change.
132
+ """
133
+ return federation_extension .get_federation_missing (
134
+ data = self ._data , resource_name = "process listing" , auto_warn = auto_warn
135
+ )
121
136
122
137
class JobListingResponse (list ):
123
138
"""
@@ -132,22 +147,21 @@ class JobListingResponse(list):
132
147
but now also provides methods/properties to access additional response data.
133
148
134
149
:param response_data: response data from a ``GET /jobs`` request
135
- :param warn_on_federation_missing: whether to automatically warn
136
- about missing federation components.
137
150
138
151
.. seealso:: :py:meth:`openeo.rest.connection.Connection.list_jobs()`
139
152
140
153
.. versionadded:: 0.38.0
141
154
"""
142
155
156
+
143
157
__slots__ = ["_data" ]
144
158
145
- def __init__ (self , response_data : dict , * , warn_on_federation_missing : bool = True ):
159
+ def __init__ (self , response_data : dict ):
146
160
self ._data = response_data
147
161
# Mimic original list of process metadata dictionaries
148
162
super ().__init__ (response_data ["jobs" ])
149
- if warn_on_federation_missing :
150
- self .ext_federation . warn_on_missing ( resource_name = "job listing" )
163
+
164
+ self .ext_federation_missing ( auto_warn = True )
151
165
152
166
def _repr_html_ (self ):
153
167
return render_component (component = "data-table" , data = self , parameters = {"columns" : "jobs" })
@@ -157,11 +171,20 @@ def links(self) -> List[Link]:
157
171
"""Get links related to this resource."""
158
172
return [Link .from_dict (d ) for d in self ._data .get ("links" , [])]
159
173
160
- @property
161
- def ext_federation (self ) -> FederationExtension :
162
- """Accessor for federation extension data related to this resource."""
163
- return FederationExtension (self ._data )
174
+ def ext_federation_missing (self , * , auto_warn : bool = False ) -> Union [None , List [str ]]:
175
+ """
176
+ List of backends IDs (from the federation)
177
+ that were not available during the resource listing request.
178
+
179
+ :param auto_warn: whether to automatically log a warning if missing federation components are detected.
164
180
181
+ .. seealso:: :ref:`federation-extension`
182
+
183
+ .. warning:: this API is experimental and subject to change.
184
+ """
185
+ return federation_extension .get_federation_missing (
186
+ data = self ._data , resource_name = "job listing" , auto_warn = auto_warn
187
+ )
165
188
166
189
class LogsResponse (list ):
167
190
"""
@@ -178,20 +201,17 @@ class LogsResponse(list):
178
201
179
202
:param response_data: response data from a ``GET /jobs/{job_id}/logs``
180
203
or ``GET /services/{service_id}/logs`` request.
181
- :param warn_on_federation_missing: whether to automatically warn
182
- about missing federation components.
183
204
184
205
.. seealso:: :py:meth:`~openeo.rest.job.BatchJob.logs()`
185
206
and :py:meth:`~openeo.rest.service.Service.logs()`
186
207
187
208
.. versionadded:: 0.38.0
188
209
"""
189
210
211
+
190
212
__slots__ = ["_data" ]
191
213
192
- def __init__ (
193
- self , response_data : dict , * , log_level : Optional [str ] = None , warn_on_federation_missing : bool = True
194
- ):
214
+ def __init__ (self , response_data : dict , * , log_level : Optional [str ] = None ):
195
215
self ._data = response_data
196
216
197
217
logs = response_data .get ("logs" , [])
@@ -214,8 +234,8 @@ def accept_level(level: str) -> bool:
214
234
# Mimic original list of process metadata dictionaries
215
235
super ().__init__ (logs )
216
236
217
- if warn_on_federation_missing :
218
- self . ext_federation . warn_on_missing ( resource_name = "log listing" )
237
+ self . ext_federation_missing ( auto_warn = True )
238
+
219
239
220
240
def _repr_html_ (self ):
221
241
return render_component (component = "logs" , data = self )
@@ -230,7 +250,17 @@ def links(self) -> List[Link]:
230
250
"""Get links related to this resource."""
231
251
return [Link .from_dict (d ) for d in self ._data .get ("links" , [])]
232
252
233
- @property
234
- def ext_federation (self ) -> FederationExtension :
235
- """Accessor for federation extension data related to this resource."""
236
- return FederationExtension (self ._data )
253
+ def ext_federation_missing (self , * , auto_warn : bool = False ) -> Union [None , List [str ]]:
254
+ """
255
+ List of backends IDs (from the federation)
256
+ that were not available during the resource listing request.
257
+
258
+ :param auto_warn: whether to automatically log a warning if missing federation components are detected.
259
+
260
+ .. seealso:: :ref:`federation-extension`
261
+
262
+ .. warning:: this API is experimental and subject to change.
263
+ """
264
+ return federation_extension .get_federation_missing (
265
+ data = self ._data , resource_name = "log listing" , auto_warn = auto_warn
266
+ )
0 commit comments