Debian Codegraph @

src/anthropic/resources/beta/vaults/vaults.py

raw
1 from __future__ import annotations
2
3 from typing import Dict, List, Optional
4 from itertools import chain
5
6 import httpx2
7
8 from ...._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
9 from ...._utils import is_given, path_template, strip_not_given
10 from ...._compat import cached_property
11 from .credentials import (
12 Credentials,
13 AsyncCredentials,
14 CredentialsWithRawResponse,
15 AsyncCredentialsWithRawResponse,
16 CredentialsWithStreamingResponse,
17 AsyncCredentialsWithStreamingResponse,
18 )
19 from ...._resource import SyncAPIResource, AsyncAPIResource
20 from ...._response import (
21 to_raw_response_wrapper,
22 to_streamed_response_wrapper,
23 async_to_raw_response_wrapper,
24 async_to_streamed_response_wrapper,
25 )
26 from ....pagination import SyncPageCursor, AsyncPageCursor
27 from ...._base_client import AsyncPaginator, make_request_options
28 from ....types.anthropic_beta_param import AnthropicBetaParam
29 from ....types.beta.beta_managed_agents_vault import BetaManagedAgentsVault
30 from ....types.beta.beta_managed_agents_deleted_vault import BetaManagedAgentsDeletedVault
31
32 __all__ = ["Vaults", "AsyncVaults"]
33
34
35 class Vaults(SyncAPIResource):
36 @cached_property
37 def credentials(self) -> Credentials:
38 return Credentials(self._client)
39
40 @cached_property
41 def with_raw_response(self) -> VaultsWithRawResponse:
42 """
43 This property can be used as a prefix for any HTTP method call to return
44 the raw response object instead of the parsed content.
45
46 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
47 """
48 return VaultsWithRawResponse(self)
49
50 @cached_property
51 def with_streaming_response(self) -> VaultsWithStreamingResponse:
52 """
53 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
54
55 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
56 """
57 return VaultsWithStreamingResponse(self)
58
59 def create(
60 self,
61 *,
62 display_name: str,
63 metadata: Dict[str, str] | Omit = omit,
64 betas: List[AnthropicBetaParam] | Omit = omit,
65 workspace_id: str | Omit = omit,
66 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
67 # The extra values given here take precedence over values defined on the client or passed to this method.
68 extra_headers: Headers | None = None,
69 extra_query: Query | None = None,
70 extra_body: Body | None = None,
71 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
72 ) -> BetaManagedAgentsVault:
73 """Create Vault
74
75 Args:
76 display_name: Human-readable name for the vault.
77
78 1-255 characters.
79
80 metadata: Arbitrary key-value metadata to attach to the vault. Maximum 16 pairs, keys up
81 to 64 chars, values up to 512 chars.
82
83 betas: Optional header to specify the beta version(s) you want to use.
84
85 workspace_id: Optional header to select the Workspace for this request. The value is a
86 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
87
88 Only needed for credentials that can act on more than one Workspace. A
89 credential that belongs to a specific Workspace may omit it; if sent, it must
90 match that Workspace.
91
92 extra_headers: Send extra headers
93
94 extra_query: Add additional query parameters to the request
95
96 extra_body: Add additional JSON properties to the request
97
98 timeout: Override the client-level default timeout for this request, in seconds
99 """
100 extra_headers = {
101 **strip_not_given(
102 {
103 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
104 if is_given(betas)
105 else not_given,
106 "anthropic-workspace-id": workspace_id,
107 }
108 ),
109 **(extra_headers or {}),
110 }
111 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
112 return self._post(
113 "/v1/vaults?beta=true",
114 body={
115 "display_name": display_name,
116 "metadata": metadata,
117 },
118 options=make_request_options(
119 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
120 ),
121 cast_to=BetaManagedAgentsVault,
122 )
123
124 def retrieve(
125 self,
126 vault_id: str,
127 *,
128 betas: List[AnthropicBetaParam] | Omit = omit,
129 workspace_id: str | Omit = omit,
130 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
131 # The extra values given here take precedence over values defined on the client or passed to this method.
132 extra_headers: Headers | None = None,
133 extra_query: Query | None = None,
134 extra_body: Body | None = None,
135 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
136 ) -> BetaManagedAgentsVault:
137 """
138 Get Vault
139
140 Args:
141 vault_id: Unique identifier of the vault to retrieve.
142
143 betas: Optional header to specify the beta version(s) you want to use.
144
145 workspace_id: Optional header to select the Workspace for this request. The value is a
146 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
147
148 Only needed for credentials that can act on more than one Workspace. A
149 credential that belongs to a specific Workspace may omit it; if sent, it must
150 match that Workspace.
151
152 extra_headers: Send extra headers
153
154 extra_query: Add additional query parameters to the request
155
156 extra_body: Add additional JSON properties to the request
157
158 timeout: Override the client-level default timeout for this request, in seconds
159 """
160 if not vault_id:
161 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
162 extra_headers = {
163 **strip_not_given(
164 {
165 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
166 if is_given(betas)
167 else not_given,
168 "anthropic-workspace-id": workspace_id,
169 }
170 ),
171 **(extra_headers or {}),
172 }
173 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
174 return self._get(
175 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
176 options=make_request_options(
177 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
178 ),
179 cast_to=BetaManagedAgentsVault,
180 )
181
182 def update(
183 self,
184 vault_id: str,
185 *,
186 display_name: Optional[str] | Omit = omit,
187 metadata: Optional[Dict[str, Optional[str]]] | Omit = omit,
188 betas: List[AnthropicBetaParam] | Omit = omit,
189 workspace_id: str | Omit = omit,
190 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
191 # The extra values given here take precedence over values defined on the client or passed to this method.
192 extra_headers: Headers | None = None,
193 extra_query: Query | None = None,
194 extra_body: Body | None = None,
195 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
196 ) -> BetaManagedAgentsVault:
197 """
198 Update Vault
199
200 Args:
201 vault_id: Unique identifier of the vault to update.
202
203 display_name: Updated human-readable name for the vault. 1-255 characters.
204
205 metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it.
206 Omitted keys are preserved.
207
208 betas: Optional header to specify the beta version(s) you want to use.
209
210 workspace_id: Optional header to select the Workspace for this request. The value is a
211 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
212
213 Only needed for credentials that can act on more than one Workspace. A
214 credential that belongs to a specific Workspace may omit it; if sent, it must
215 match that Workspace.
216
217 extra_headers: Send extra headers
218
219 extra_query: Add additional query parameters to the request
220
221 extra_body: Add additional JSON properties to the request
222
223 timeout: Override the client-level default timeout for this request, in seconds
224 """
225 if not vault_id:
226 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
227 extra_headers = {
228 **strip_not_given(
229 {
230 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
231 if is_given(betas)
232 else not_given,
233 "anthropic-workspace-id": workspace_id,
234 }
235 ),
236 **(extra_headers or {}),
237 }
238 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
239 return self._post(
240 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
241 body={
242 "display_name": display_name,
243 "metadata": metadata,
244 },
245 options=make_request_options(
246 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
247 ),
248 cast_to=BetaManagedAgentsVault,
249 )
250
251 def list(
252 self,
253 *,
254 include_archived: bool | Omit = omit,
255 limit: int | Omit = omit,
256 page: str | Omit = omit,
257 betas: List[AnthropicBetaParam] | Omit = omit,
258 workspace_id: str | Omit = omit,
259 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
260 # The extra values given here take precedence over values defined on the client or passed to this method.
261 extra_headers: Headers | None = None,
262 extra_query: Query | None = None,
263 extra_body: Body | None = None,
264 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
265 ) -> SyncPageCursor[BetaManagedAgentsVault]:
266 """
267 List Vaults
268
269 Args:
270 include_archived: Whether to include archived vaults in the results.
271
272 limit: Maximum number of vaults to return per page. Defaults to 20, maximum 100.
273
274 page: Opaque pagination token from a previous `list_vaults` response.
275
276 betas: Optional header to specify the beta version(s) you want to use.
277
278 workspace_id: Optional header to select the Workspace for this request. The value is a
279 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
280
281 Only needed for credentials that can act on more than one Workspace. A
282 credential that belongs to a specific Workspace may omit it; if sent, it must
283 match that Workspace.
284
285 extra_headers: Send extra headers
286
287 extra_query: Add additional query parameters to the request
288
289 extra_body: Add additional JSON properties to the request
290
291 timeout: Override the client-level default timeout for this request, in seconds
292 """
293 extra_headers = {
294 **strip_not_given(
295 {
296 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
297 if is_given(betas)
298 else not_given,
299 "anthropic-workspace-id": workspace_id,
300 }
301 ),
302 **(extra_headers or {}),
303 }
304 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
305 return self._get_api_list(
306 "/v1/vaults?beta=true",
307 page=SyncPageCursor[BetaManagedAgentsVault],
308 options=make_request_options(
309 extra_headers=extra_headers,
310 extra_query=extra_query,
311 extra_body=extra_body,
312 timeout=timeout,
313 query={
314 "include_archived": include_archived,
315 "limit": limit,
316 "page": page,
317 },
318 ),
319 model=BetaManagedAgentsVault,
320 )
321
322 def delete(
323 self,
324 vault_id: str,
325 *,
326 betas: List[AnthropicBetaParam] | Omit = omit,
327 workspace_id: str | Omit = omit,
328 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
329 # The extra values given here take precedence over values defined on the client or passed to this method.
330 extra_headers: Headers | None = None,
331 extra_query: Query | None = None,
332 extra_body: Body | None = None,
333 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
334 ) -> BetaManagedAgentsDeletedVault:
335 """
336 Delete Vault
337
338 Args:
339 vault_id: Unique identifier of the vault to delete.
340
341 betas: Optional header to specify the beta version(s) you want to use.
342
343 workspace_id: Optional header to select the Workspace for this request. The value is a
344 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
345
346 Only needed for credentials that can act on more than one Workspace. A
347 credential that belongs to a specific Workspace may omit it; if sent, it must
348 match that Workspace.
349
350 extra_headers: Send extra headers
351
352 extra_query: Add additional query parameters to the request
353
354 extra_body: Add additional JSON properties to the request
355
356 timeout: Override the client-level default timeout for this request, in seconds
357 """
358 if not vault_id:
359 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
360 extra_headers = {
361 **strip_not_given(
362 {
363 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
364 if is_given(betas)
365 else not_given,
366 "anthropic-workspace-id": workspace_id,
367 }
368 ),
369 **(extra_headers or {}),
370 }
371 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
372 return self._delete(
373 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
374 options=make_request_options(
375 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
376 ),
377 cast_to=BetaManagedAgentsDeletedVault,
378 )
379
380 def archive(
381 self,
382 vault_id: str,
383 *,
384 betas: List[AnthropicBetaParam] | Omit = omit,
385 workspace_id: str | Omit = omit,
386 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
387 # The extra values given here take precedence over values defined on the client or passed to this method.
388 extra_headers: Headers | None = None,
389 extra_query: Query | None = None,
390 extra_body: Body | None = None,
391 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
392 ) -> BetaManagedAgentsVault:
393 """
394 Archive Vault
395
396 Args:
397 vault_id: Unique identifier of the vault to archive.
398
399 betas: Optional header to specify the beta version(s) you want to use.
400
401 workspace_id: Optional header to select the Workspace for this request. The value is a
402 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
403
404 Only needed for credentials that can act on more than one Workspace. A
405 credential that belongs to a specific Workspace may omit it; if sent, it must
406 match that Workspace.
407
408 extra_headers: Send extra headers
409
410 extra_query: Add additional query parameters to the request
411
412 extra_body: Add additional JSON properties to the request
413
414 timeout: Override the client-level default timeout for this request, in seconds
415 """
416 if not vault_id:
417 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
418 extra_headers = {
419 **strip_not_given(
420 {
421 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
422 if is_given(betas)
423 else not_given,
424 "anthropic-workspace-id": workspace_id,
425 }
426 ),
427 **(extra_headers or {}),
428 }
429 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
430 return self._post(
431 path_template("/v1/vaults/{vault_id}/archive?beta=true", vault_id=vault_id),
432 options=make_request_options(
433 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
434 ),
435 cast_to=BetaManagedAgentsVault,
436 )
437
438
439 class AsyncVaults(AsyncAPIResource):
440 @cached_property
441 def credentials(self) -> AsyncCredentials:
442 return AsyncCredentials(self._client)
443
444 @cached_property
445 def with_raw_response(self) -> AsyncVaultsWithRawResponse:
446 """
447 This property can be used as a prefix for any HTTP method call to return
448 the raw response object instead of the parsed content.
449
450 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
451 """
452 return AsyncVaultsWithRawResponse(self)
453
454 @cached_property
455 def with_streaming_response(self) -> AsyncVaultsWithStreamingResponse:
456 """
457 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
458
459 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
460 """
461 return AsyncVaultsWithStreamingResponse(self)
462
463 async def create(
464 self,
465 *,
466 display_name: str,
467 metadata: Dict[str, str] | Omit = omit,
468 betas: List[AnthropicBetaParam] | Omit = omit,
469 workspace_id: str | Omit = omit,
470 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
471 # The extra values given here take precedence over values defined on the client or passed to this method.
472 extra_headers: Headers | None = None,
473 extra_query: Query | None = None,
474 extra_body: Body | None = None,
475 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
476 ) -> BetaManagedAgentsVault:
477 """Create Vault
478
479 Args:
480 display_name: Human-readable name for the vault.
481
482 1-255 characters.
483
484 metadata: Arbitrary key-value metadata to attach to the vault. Maximum 16 pairs, keys up
485 to 64 chars, values up to 512 chars.
486
487 betas: Optional header to specify the beta version(s) you want to use.
488
489 workspace_id: Optional header to select the Workspace for this request. The value is a
490 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
491
492 Only needed for credentials that can act on more than one Workspace. A
493 credential that belongs to a specific Workspace may omit it; if sent, it must
494 match that Workspace.
495
496 extra_headers: Send extra headers
497
498 extra_query: Add additional query parameters to the request
499
500 extra_body: Add additional JSON properties to the request
501
502 timeout: Override the client-level default timeout for this request, in seconds
503 """
504 extra_headers = {
505 **strip_not_given(
506 {
507 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
508 if is_given(betas)
509 else not_given,
510 "anthropic-workspace-id": workspace_id,
511 }
512 ),
513 **(extra_headers or {}),
514 }
515 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
516 return await self._post(
517 "/v1/vaults?beta=true",
518 body={
519 "display_name": display_name,
520 "metadata": metadata,
521 },
522 options=make_request_options(
523 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
524 ),
525 cast_to=BetaManagedAgentsVault,
526 )
527
528 async def retrieve(
529 self,
530 vault_id: str,
531 *,
532 betas: List[AnthropicBetaParam] | Omit = omit,
533 workspace_id: str | Omit = omit,
534 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
535 # The extra values given here take precedence over values defined on the client or passed to this method.
536 extra_headers: Headers | None = None,
537 extra_query: Query | None = None,
538 extra_body: Body | None = None,
539 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
540 ) -> BetaManagedAgentsVault:
541 """
542 Get Vault
543
544 Args:
545 vault_id: Unique identifier of the vault to retrieve.
546
547 betas: Optional header to specify the beta version(s) you want to use.
548
549 workspace_id: Optional header to select the Workspace for this request. The value is a
550 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
551
552 Only needed for credentials that can act on more than one Workspace. A
553 credential that belongs to a specific Workspace may omit it; if sent, it must
554 match that Workspace.
555
556 extra_headers: Send extra headers
557
558 extra_query: Add additional query parameters to the request
559
560 extra_body: Add additional JSON properties to the request
561
562 timeout: Override the client-level default timeout for this request, in seconds
563 """
564 if not vault_id:
565 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
566 extra_headers = {
567 **strip_not_given(
568 {
569 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
570 if is_given(betas)
571 else not_given,
572 "anthropic-workspace-id": workspace_id,
573 }
574 ),
575 **(extra_headers or {}),
576 }
577 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
578 return await self._get(
579 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
580 options=make_request_options(
581 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
582 ),
583 cast_to=BetaManagedAgentsVault,
584 )
585
586 async def update(
587 self,
588 vault_id: str,
589 *,
590 display_name: Optional[str] | Omit = omit,
591 metadata: Optional[Dict[str, Optional[str]]] | Omit = omit,
592 betas: List[AnthropicBetaParam] | Omit = omit,
593 workspace_id: str | Omit = omit,
594 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
595 # The extra values given here take precedence over values defined on the client or passed to this method.
596 extra_headers: Headers | None = None,
597 extra_query: Query | None = None,
598 extra_body: Body | None = None,
599 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
600 ) -> BetaManagedAgentsVault:
601 """
602 Update Vault
603
604 Args:
605 vault_id: Unique identifier of the vault to update.
606
607 display_name: Updated human-readable name for the vault. 1-255 characters.
608
609 metadata: Metadata patch. Set a key to a string to upsert it, or to null to delete it.
610 Omitted keys are preserved.
611
612 betas: Optional header to specify the beta version(s) you want to use.
613
614 workspace_id: Optional header to select the Workspace for this request. The value is a
615 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
616
617 Only needed for credentials that can act on more than one Workspace. A
618 credential that belongs to a specific Workspace may omit it; if sent, it must
619 match that Workspace.
620
621 extra_headers: Send extra headers
622
623 extra_query: Add additional query parameters to the request
624
625 extra_body: Add additional JSON properties to the request
626
627 timeout: Override the client-level default timeout for this request, in seconds
628 """
629 if not vault_id:
630 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
631 extra_headers = {
632 **strip_not_given(
633 {
634 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
635 if is_given(betas)
636 else not_given,
637 "anthropic-workspace-id": workspace_id,
638 }
639 ),
640 **(extra_headers or {}),
641 }
642 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
643 return await self._post(
644 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
645 body={
646 "display_name": display_name,
647 "metadata": metadata,
648 },
649 options=make_request_options(
650 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
651 ),
652 cast_to=BetaManagedAgentsVault,
653 )
654
655 def list(
656 self,
657 *,
658 include_archived: bool | Omit = omit,
659 limit: int | Omit = omit,
660 page: str | Omit = omit,
661 betas: List[AnthropicBetaParam] | Omit = omit,
662 workspace_id: str | Omit = omit,
663 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
664 # The extra values given here take precedence over values defined on the client or passed to this method.
665 extra_headers: Headers | None = None,
666 extra_query: Query | None = None,
667 extra_body: Body | None = None,
668 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
669 ) -> AsyncPaginator[BetaManagedAgentsVault, AsyncPageCursor[BetaManagedAgentsVault]]:
670 """
671 List Vaults
672
673 Args:
674 include_archived: Whether to include archived vaults in the results.
675
676 limit: Maximum number of vaults to return per page. Defaults to 20, maximum 100.
677
678 page: Opaque pagination token from a previous `list_vaults` response.
679
680 betas: Optional header to specify the beta version(s) you want to use.
681
682 workspace_id: Optional header to select the Workspace for this request. The value is a
683 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
684
685 Only needed for credentials that can act on more than one Workspace. A
686 credential that belongs to a specific Workspace may omit it; if sent, it must
687 match that Workspace.
688
689 extra_headers: Send extra headers
690
691 extra_query: Add additional query parameters to the request
692
693 extra_body: Add additional JSON properties to the request
694
695 timeout: Override the client-level default timeout for this request, in seconds
696 """
697 extra_headers = {
698 **strip_not_given(
699 {
700 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
701 if is_given(betas)
702 else not_given,
703 "anthropic-workspace-id": workspace_id,
704 }
705 ),
706 **(extra_headers or {}),
707 }
708 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
709 return self._get_api_list(
710 "/v1/vaults?beta=true",
711 page=AsyncPageCursor[BetaManagedAgentsVault],
712 options=make_request_options(
713 extra_headers=extra_headers,
714 extra_query=extra_query,
715 extra_body=extra_body,
716 timeout=timeout,
717 query={
718 "include_archived": include_archived,
719 "limit": limit,
720 "page": page,
721 },
722 ),
723 model=BetaManagedAgentsVault,
724 )
725
726 async def delete(
727 self,
728 vault_id: str,
729 *,
730 betas: List[AnthropicBetaParam] | Omit = omit,
731 workspace_id: str | Omit = omit,
732 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
733 # The extra values given here take precedence over values defined on the client or passed to this method.
734 extra_headers: Headers | None = None,
735 extra_query: Query | None = None,
736 extra_body: Body | None = None,
737 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
738 ) -> BetaManagedAgentsDeletedVault:
739 """
740 Delete Vault
741
742 Args:
743 vault_id: Unique identifier of the vault to delete.
744
745 betas: Optional header to specify the beta version(s) you want to use.
746
747 workspace_id: Optional header to select the Workspace for this request. The value is a
748 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
749
750 Only needed for credentials that can act on more than one Workspace. A
751 credential that belongs to a specific Workspace may omit it; if sent, it must
752 match that Workspace.
753
754 extra_headers: Send extra headers
755
756 extra_query: Add additional query parameters to the request
757
758 extra_body: Add additional JSON properties to the request
759
760 timeout: Override the client-level default timeout for this request, in seconds
761 """
762 if not vault_id:
763 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
764 extra_headers = {
765 **strip_not_given(
766 {
767 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
768 if is_given(betas)
769 else not_given,
770 "anthropic-workspace-id": workspace_id,
771 }
772 ),
773 **(extra_headers or {}),
774 }
775 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
776 return await self._delete(
777 path_template("/v1/vaults/{vault_id}?beta=true", vault_id=vault_id),
778 options=make_request_options(
779 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
780 ),
781 cast_to=BetaManagedAgentsDeletedVault,
782 )
783
784 async def archive(
785 self,
786 vault_id: str,
787 *,
788 betas: List[AnthropicBetaParam] | Omit = omit,
789 workspace_id: str | Omit = omit,
790 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
791 # The extra values given here take precedence over values defined on the client or passed to this method.
792 extra_headers: Headers | None = None,
793 extra_query: Query | None = None,
794 extra_body: Body | None = None,
795 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
796 ) -> BetaManagedAgentsVault:
797 """
798 Archive Vault
799
800 Args:
801 vault_id: Unique identifier of the vault to archive.
802
803 betas: Optional header to specify the beta version(s) you want to use.
804
805 workspace_id: Optional header to select the Workspace for this request. The value is a
806 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
807
808 Only needed for credentials that can act on more than one Workspace. A
809 credential that belongs to a specific Workspace may omit it; if sent, it must
810 match that Workspace.
811
812 extra_headers: Send extra headers
813
814 extra_query: Add additional query parameters to the request
815
816 extra_body: Add additional JSON properties to the request
817
818 timeout: Override the client-level default timeout for this request, in seconds
819 """
820 if not vault_id:
821 raise ValueError(f"Expected a non-empty value for `vault_id` but received {vault_id!r}")
822 extra_headers = {
823 **strip_not_given(
824 {
825 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["managed-agents-2026-04-01"]))
826 if is_given(betas)
827 else not_given,
828 "anthropic-workspace-id": workspace_id,
829 }
830 ),
831 **(extra_headers or {}),
832 }
833 extra_headers = {"anthropic-beta": "managed-agents-2026-04-01", **(extra_headers or {})}
834 return await self._post(
835 path_template("/v1/vaults/{vault_id}/archive?beta=true", vault_id=vault_id),
836 options=make_request_options(
837 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
838 ),
839 cast_to=BetaManagedAgentsVault,
840 )
841
842
843 class VaultsWithRawResponse:
844 def __init__(self, vaults: Vaults) -> None:
845 self._vaults = vaults
846
847 self.create = to_raw_response_wrapper(
848 vaults.create,
849 )
850 self.retrieve = to_raw_response_wrapper(
851 vaults.retrieve,
852 )
853 self.update = to_raw_response_wrapper(
854 vaults.update,
855 )
856 self.list = to_raw_response_wrapper(
857 vaults.list,
858 )
859 self.delete = to_raw_response_wrapper(
860 vaults.delete,
861 )
862 self.archive = to_raw_response_wrapper(
863 vaults.archive,
864 )
865
866 @cached_property
867 def credentials(self) -> CredentialsWithRawResponse:
868 return CredentialsWithRawResponse(self._vaults.credentials)
869
870
871 class AsyncVaultsWithRawResponse:
872 def __init__(self, vaults: AsyncVaults) -> None:
873 self._vaults = vaults
874
875 self.create = async_to_raw_response_wrapper(
876 vaults.create,
877 )
878 self.retrieve = async_to_raw_response_wrapper(
879 vaults.retrieve,
880 )
881 self.update = async_to_raw_response_wrapper(
882 vaults.update,
883 )
884 self.list = async_to_raw_response_wrapper(
885 vaults.list,
886 )
887 self.delete = async_to_raw_response_wrapper(
888 vaults.delete,
889 )
890 self.archive = async_to_raw_response_wrapper(
891 vaults.archive,
892 )
893
894 @cached_property
895 def credentials(self) -> AsyncCredentialsWithRawResponse:
896 return AsyncCredentialsWithRawResponse(self._vaults.credentials)
897
898
899 class VaultsWithStreamingResponse:
900 def __init__(self, vaults: Vaults) -> None:
901 self._vaults = vaults
902
903 self.create = to_streamed_response_wrapper(
904 vaults.create,
905 )
906 self.retrieve = to_streamed_response_wrapper(
907 vaults.retrieve,
908 )
909 self.update = to_streamed_response_wrapper(
910 vaults.update,
911 )
912 self.list = to_streamed_response_wrapper(
913 vaults.list,
914 )
915 self.delete = to_streamed_response_wrapper(
916 vaults.delete,
917 )
918 self.archive = to_streamed_response_wrapper(
919 vaults.archive,
920 )
921
922 @cached_property
923 def credentials(self) -> CredentialsWithStreamingResponse:
924 return CredentialsWithStreamingResponse(self._vaults.credentials)
925
926
927 class AsyncVaultsWithStreamingResponse:
928 def __init__(self, vaults: AsyncVaults) -> None:
929 self._vaults = vaults
930
931 self.create = async_to_streamed_response_wrapper(
932 vaults.create,
933 )
934 self.retrieve = async_to_streamed_response_wrapper(
935 vaults.retrieve,
936 )
937 self.update = async_to_streamed_response_wrapper(
938 vaults.update,
939 )
940 self.list = async_to_streamed_response_wrapper(
941 vaults.list,
942 )
943 self.delete = async_to_streamed_response_wrapper(
944 vaults.delete,
945 )
946 self.archive = async_to_streamed_response_wrapper(
947 vaults.archive,
948 )
949
950 @cached_property
951 def credentials(self) -> AsyncCredentialsWithStreamingResponse:
952 return AsyncCredentialsWithStreamingResponse(self._vaults.credentials)