10
10
DEFAULT_TIMEOUT ,
11
11
MULTI_DOCUMENT_LIMIT ,
12
12
)
13
- from .models import Detail , Document , MultiScanResult , QuotaResponse , ScanResult
13
+ from .models import (
14
+ Detail ,
15
+ Document ,
16
+ HealthCheckResponse ,
17
+ MultiScanResult ,
18
+ QuotaResponse ,
19
+ ScanResult ,
20
+ )
21
+
22
+
23
+ class Versions :
24
+ app_version : Optional [str ] = None
25
+ secrets_engine_version : Optional [str ] = None
26
+
27
+
28
+ VERSIONS = Versions ()
14
29
15
30
16
31
def load_detail (resp : Response ) -> Detail :
@@ -111,16 +126,47 @@ def request(
111
126
if extra_headers
112
127
else self .session .headers
113
128
)
114
- return self .session .request (
129
+ response : Response = self .session .request (
115
130
method = method , url = url , timeout = self .timeout , headers = headers , ** kwargs
116
131
)
117
132
133
+ self .app_version = response .headers .get ("X-App-Version" , self .app_version )
134
+ self .secrets_engine_version = response .headers .get (
135
+ "X-Secrets-Engine-Version" , self .secrets_engine_version
136
+ )
137
+
138
+ return response
139
+
118
140
def _url_from_endpoint (self , endpoint : str , version : Optional [str ]) -> str :
119
141
if version :
120
142
endpoint = urllib .parse .urljoin (version + "/" , endpoint )
121
143
122
144
return urllib .parse .urljoin (self .base_uri + "/" , endpoint )
123
145
146
+ @property
147
+ def app_version (self ) -> Optional [str ]:
148
+ global VERSIONS
149
+
150
+ return VERSIONS .app_version
151
+
152
+ @app_version .setter
153
+ def app_version (self , value : Optional [str ]):
154
+ global VERSIONS
155
+
156
+ VERSIONS .app_version = value
157
+
158
+ @property
159
+ def secrets_engine_version (self ) -> Optional [str ]:
160
+ global VERSIONS
161
+
162
+ return VERSIONS .secrets_engine_version
163
+
164
+ @secrets_engine_version .setter
165
+ def secrets_engine_version (self , value : Optional [str ]):
166
+ global VERSIONS
167
+
168
+ VERSIONS .secrets_engine_version = value
169
+
124
170
def get (
125
171
self ,
126
172
endpoint : str ,
@@ -153,7 +199,7 @@ def post(
153
199
** kwargs ,
154
200
)
155
201
156
- def health_check (self ) -> Detail :
202
+ def health_check (self ) -> HealthCheckResponse :
157
203
"""
158
204
health_check handles the /health endpoint of the API
159
205
@@ -164,10 +210,12 @@ def health_check(self) -> Detail:
164
210
"""
165
211
resp = self .get (endpoint = "health" )
166
212
167
- obj = load_detail (resp )
168
- obj .status_code = resp .status_code
169
-
170
- return obj
213
+ return HealthCheckResponse (
214
+ detail = load_detail (resp ).detail ,
215
+ status_code = resp .status_code ,
216
+ app_version = self .app_version ,
217
+ secrets_engine_version = self .secrets_engine_version ,
218
+ )
171
219
172
220
def content_scan (
173
221
self ,
0 commit comments