1
+ from typing import Any , cast , Dict , List , TYPE_CHECKING , Union
2
+
1
3
from gitlab import cli
2
4
from gitlab import exceptions as exc
3
5
from gitlab .base import RequiredOptional , RESTManager , RESTObject
18
20
class GeoNode (SaveMixin , ObjectDeleteMixin , RESTObject ):
19
21
@cli .register_custom_action ("GeoNode" )
20
22
@exc .on_http_error (exc .GitlabRepairError )
21
- def repair (self , ** kwargs ) :
23
+ def repair (self , ** kwargs : Any ) -> None :
22
24
"""Repair the OAuth authentication of the geo node.
23
25
24
26
Args:
@@ -30,11 +32,13 @@ def repair(self, **kwargs):
30
32
"""
31
33
path = f"/geo_nodes/{ self .get_id ()} /repair"
32
34
server_data = self .manager .gitlab .http_post (path , ** kwargs )
35
+ if TYPE_CHECKING :
36
+ assert isinstance (server_data , dict )
33
37
self ._update_attrs (server_data )
34
38
35
39
@cli .register_custom_action ("GeoNode" )
36
40
@exc .on_http_error (exc .GitlabGetError )
37
- def status (self , ** kwargs ) :
41
+ def status (self , ** kwargs : Any ) -> Dict [ str , Any ] :
38
42
"""Get the status of the geo node.
39
43
40
44
Args:
@@ -48,7 +52,10 @@ def status(self, **kwargs):
48
52
dict: The status of the geo node
49
53
"""
50
54
path = f"/geo_nodes/{ self .get_id ()} /status"
51
- return self .manager .gitlab .http_get (path , ** kwargs )
55
+ result = self .manager .gitlab .http_get (path , ** kwargs )
56
+ if TYPE_CHECKING :
57
+ assert isinstance (result , dict )
58
+ return result
52
59
53
60
54
61
class GeoNodeManager (RetrieveMixin , UpdateMixin , DeleteMixin , RESTManager ):
@@ -58,9 +65,12 @@ class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager):
58
65
optional = ("enabled" , "url" , "files_max_capacity" , "repos_max_capacity" ),
59
66
)
60
67
68
+ def get (self , id : Union [str , int ], lazy : bool = False , ** kwargs : Any ) -> GeoNode :
69
+ return cast (GeoNode , super ().get (id = id , lazy = lazy , ** kwargs ))
70
+
61
71
@cli .register_custom_action ("GeoNodeManager" )
62
72
@exc .on_http_error (exc .GitlabGetError )
63
- def status (self , ** kwargs ) :
73
+ def status (self , ** kwargs : Any ) -> List [ Dict [ str , Any ]] :
64
74
"""Get the status of all the geo nodes.
65
75
66
76
Args:
@@ -73,11 +83,14 @@ def status(self, **kwargs):
73
83
Returns:
74
84
list: The status of all the geo nodes
75
85
"""
76
- return self .gitlab .http_list ("/geo_nodes/status" , ** kwargs )
86
+ result = self .gitlab .http_list ("/geo_nodes/status" , ** kwargs )
87
+ if TYPE_CHECKING :
88
+ assert isinstance (result , list )
89
+ return result
77
90
78
91
@cli .register_custom_action ("GeoNodeManager" )
79
92
@exc .on_http_error (exc .GitlabGetError )
80
- def current_failures (self , ** kwargs ) :
93
+ def current_failures (self , ** kwargs : Any ) -> List [ Dict [ str , Any ]] :
81
94
"""Get the list of failures on the current geo node.
82
95
83
96
Args:
@@ -90,4 +103,7 @@ def current_failures(self, **kwargs):
90
103
Returns:
91
104
list: The list of failures
92
105
"""
93
- return self .gitlab .http_list ("/geo_nodes/current/failures" , ** kwargs )
106
+ result = self .gitlab .http_list ("/geo_nodes/current/failures" , ** kwargs )
107
+ if TYPE_CHECKING :
108
+ assert isinstance (result , list )
109
+ return result
0 commit comments