1010 SecretVersion ,
1111 SecretsList ,
1212 SecretVersionsList ,
13- YandexLockboxResponse ,
14- YandexLockboxError ,
13+ Operation ,
14+ YandexCloudError ,
1515 INewSecret ,
1616 IUpdateSecret ,
1717 INewSecretVersion ,
@@ -141,134 +141,138 @@ def _seekable_response(
141141 item .inject_client (self )
142142 yield item
143143
144- def activate_secret (
145- self , secret_id : str , raise_for_status : bool = True
146- ) -> YandexLockboxResponse | YandexLockboxError :
144+ def activate_secret (self , secret_id : str , raise_for_status : bool = True ) -> Operation | YandexCloudError :
147145 """
148146 Activates the specified secret.
149147
150148 :param secret_id: Secret indentifier.
151- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
149+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
152150 Defaults to ``True``.
153151 """
154152 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } :activate"
155- return self .adapter .request (
153+ response = self .adapter .request (
156154 "POST" ,
157155 url ,
158156 headers = self .auth_headers ,
159- response_model = YandexLockboxResponse ,
157+ response_model = Operation ,
160158 raise_for_status = raise_for_status ,
161159 )
160+ response .inject_client (self )
161+ return response
162162
163163 def add_secret_version (
164164 self , secret_id : str , version : INewSecretVersion , raise_for_status : bool = True
165- ) -> YandexLockboxResponse | YandexLockboxError :
165+ ) -> Operation | YandexCloudError :
166166 """
167167 Adds new version based on a previous one.
168168
169169 :param secret_id: Secret indentifier.
170170 :param version: A new version object.
171- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
171+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
172172 Defaults to ``True``.
173173 """
174174 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } :addVersion"
175175 payload = version .model_dump_json (by_alias = True , exclude_none = True )
176- return self .adapter .request (
176+ response = self .adapter .request (
177177 "POST" ,
178178 url ,
179179 headers = self .auth_headers ,
180180 data = payload ,
181- response_model = YandexLockboxResponse ,
181+ response_model = Operation ,
182182 raise_for_status = raise_for_status ,
183183 )
184+ response .inject_client (self )
185+ return response
184186
185- def create_secret (
186- self , secret : INewSecret , raise_for_status : bool = True
187- ) -> YandexLockboxResponse | YandexLockboxError :
187+ def create_secret (self , secret : INewSecret , raise_for_status : bool = True ) -> Operation | YandexCloudError :
188188 """
189189 Creates a secret in the specified folder.
190190
191191 :param secret: A new secret object.
192- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
192+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
193193 Defaults to ``True``.
194194 """
195195 url = f"{ self .lockbox_base_url } /secrets"
196196 payload = secret .model_dump_json (by_alias = True , exclude_none = True )
197- return self .adapter .request (
197+ response = self .adapter .request (
198198 "POST" ,
199199 url ,
200200 headers = self .auth_headers ,
201201 data = payload ,
202- response_model = YandexLockboxResponse ,
202+ response_model = Operation ,
203203 raise_for_status = raise_for_status ,
204204 )
205+ response .inject_client (self )
206+ return response
205207
206208 def cancel_secret_version_destruction (
207209 self , secret_id : str , version_id : str , raise_for_status : bool = True
208- ) -> YandexLockboxResponse | YandexLockboxError :
210+ ) -> Operation | YandexCloudError :
209211 """
210212 Cancels previously scheduled version destruction, if the version hasn't been destroyed yet.
211213
212214 :param secret_id: Secret indentifier.
213215 :param version_id: Secret version id to cancel destruction.
214- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
216+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
215217 Defaults to ``True``.
216218 """
217219 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } :cancelVersionDestruction"
218220 payload = {"versionId" : version_id }
219- return self .adapter .request (
221+ response = self .adapter .request (
220222 "POST" ,
221223 url ,
222224 headers = self .auth_headers ,
223225 json = payload ,
224- response_model = YandexLockboxResponse ,
226+ response_model = Operation ,
225227 raise_for_status = raise_for_status ,
226228 )
229+ response .inject_client (self )
230+ return response
227231
228- def deactivate_secret (
229- self , secret_id : str , raise_for_status : bool = True
230- ) -> YandexLockboxResponse | YandexLockboxError :
232+ def deactivate_secret (self , secret_id : str , raise_for_status : bool = True ) -> Operation | YandexCloudError :
231233 """
232234 Deactivate a secret.
233235
234236 :param secret_id: Secret indentifier.
235- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
237+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
236238 Defaults to ``True``.
237239 """
238240 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } :deactivate"
239- return self .adapter .request (
241+ response = self .adapter .request (
240242 "POST" ,
241243 url ,
242244 headers = self .auth_headers ,
243- response_model = YandexLockboxResponse ,
245+ response_model = Operation ,
244246 raise_for_status = raise_for_status ,
245247 )
248+ response .inject_client (self )
249+ return response
246250
247- def delete_secret (
248- self , secret_id : str , raise_for_status : bool = True
249- ) -> YandexLockboxResponse | YandexLockboxError :
251+ def delete_secret (self , secret_id : str , raise_for_status : bool = True ) -> Operation | YandexCloudError :
250252 """
251253 Deletes the specified secret.
252254
253255 :param secret_id: Secret indentifier.
254- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
256+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
255257 Defaults to ``True``.
256258 """
257259 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } "
258- return self .adapter .request (
260+ response = self .adapter .request (
259261 "DELETE" ,
260262 url ,
261263 headers = self .auth_headers ,
262- response_model = YandexLockboxResponse ,
264+ response_model = Operation ,
263265 raise_for_status = raise_for_status ,
264266 )
267+ response .inject_client (self )
268+ return response
265269
266- def get_secret (self , secret_id : str , raise_for_status : bool = True ) -> Secret | YandexLockboxError :
270+ def get_secret (self , secret_id : str , raise_for_status : bool = True ) -> Secret | YandexCloudError :
267271 """
268272 Get lockbox secret by ID.
269273
270274 :param secret_id: Secret identifier.
271- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
275+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
272276 Defaults to ``True``.
273277 """
274278 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } "
@@ -287,13 +291,13 @@ def get_secret_payload(
287291 secret_id : str ,
288292 version_id : str | None = None ,
289293 raise_for_status : bool = True ,
290- ) -> SecretPayload | YandexLockboxError :
294+ ) -> SecretPayload | YandexCloudError :
291295 """
292296 Get lockbox secret payload by ID and optional version.
293297
294298 :param secret_id: Secret identifier.
295299 :param version_id: Secret version. Optional.
296- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
300+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
297301 Defaults to ``True``.
298302 """
299303 url = f"{ self .payload_lockbox_base_url } /secrets/{ secret_id } /payload"
@@ -314,7 +318,7 @@ def list_secrets(
314318 page_token : str | None = None ,
315319 raise_for_status : bool = True ,
316320 iterator : bool = False ,
317- ) -> SecretsList | Iterator [Secret ] | YandexLockboxError :
321+ ) -> SecretsList | Iterator [Secret ] | YandexCloudError :
318322 """
319323 Retrieves the list of secrets in the specified folder.
320324
@@ -362,7 +366,7 @@ def list_secret_versions(
362366 page_token : str | None = None ,
363367 raise_for_status : bool = True ,
364368 iterator : bool = False ,
365- ) -> SecretVersionsList | Iterator [SecretVersion ] | YandexLockboxError :
369+ ) -> SecretVersionsList | Iterator [SecretVersion ] | YandexCloudError :
366370 """
367371 Retrieves the list of versions of the specified secret.
368372
@@ -397,7 +401,7 @@ def list_secret_versions(
397401
398402 def schedule_secret_version_destruction (
399403 self , secret_id : str , version_id : str , pending_period : int = 604800 , raise_for_status : bool = True
400- ) -> YandexLockboxResponse | YandexLockboxError :
404+ ) -> Operation | YandexCloudError :
401405 """
402406 Schedules the specified version for destruction.
403407 Scheduled destruction can be cancelled with the :func:`cancel_secret_version_destruction()` method.
@@ -406,7 +410,7 @@ def schedule_secret_version_destruction(
406410 :param version_id: ID of the version to be destroyed.
407411 :param pending_period: Time interval in seconds between the version destruction request and actual destruction.
408412 Default value: ``604800`` (i.e. 7 days).
409- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
413+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
410414 Defaults to ``True``.
411415 """
412416 if isinstance (pending_period , int ):
@@ -420,22 +424,24 @@ def schedule_secret_version_destruction(
420424
421425 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } :scheduleVersionDestruction"
422426 payload = {"versionId" : version_id , "pendingPeriod" : pending_period }
423- return self .adapter .request (
427+ response = self .adapter .request (
424428 "POST" ,
425429 url ,
426430 headers = self .auth_headers ,
427431 json = payload ,
428- response_model = YandexLockboxResponse ,
432+ response_model = Operation ,
429433 raise_for_status = raise_for_status ,
430434 )
435+ response .inject_client (self )
436+ return response
431437
432438 # TODO: implement
433439 def set_secret_access_bindings (self , * args , ** kwargs ):
434440 raise NotImplementedError
435441
436442 def update_secret (
437443 self , secret_id : str , data : IUpdateSecret , raise_for_status : bool = True
438- ) -> YandexLockboxResponse | YandexLockboxError :
444+ ) -> Operation | YandexCloudError :
439445 """
440446 Updates the specified secret.
441447
@@ -448,19 +454,21 @@ def update_secret(
448454 The default value for most fields is null or 0.
449455 If ``updateMask`` is not sent in the request, all fields values will be updated.
450456 Fields specified in the request will be updated to provided values. The rest of the fields will be reset to the default.
451- :param raise_for_status: If set to ``False`` returns :class:`YandexLockboxError ` instead throw exception.
457+ :param raise_for_status: If set to ``False`` returns :class:`YandexCloudError ` instead throw exception.
452458 Defaults to ``True``.
453459 """
454460 url = f"{ self .lockbox_base_url } /secrets/{ secret_id } "
455461 payload = data .model_dump_json (by_alias = True )
456- return self .adapter .request (
462+ response = self .adapter .request (
457463 "PATCH" ,
458464 url ,
459465 headers = self .auth_headers ,
460466 data = payload ,
461- response_model = YandexLockboxResponse ,
467+ response_model = Operation ,
462468 raise_for_status = raise_for_status ,
463469 )
470+ response .inject_client (self )
471+ return response
464472
465473 # TODO: implement
466474 def update_secret_access_bindings (self , * args , ** kwargs ):
0 commit comments