Debian Codegraph @

src/anthropic/resources/beta/organization/service_accounts/service_accounts.py

raw
1 from __future__ import annotations
2
3 from typing import List, Optional
4 from typing_extensions import Literal
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 .workspaces import (
11 Workspaces,
12 AsyncWorkspaces,
13 WorkspacesWithRawResponse,
14 AsyncWorkspacesWithRawResponse,
15 WorkspacesWithStreamingResponse,
16 AsyncWorkspacesWithStreamingResponse,
17 )
18 from ....._compat import cached_property
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.organization.beta_service_account import BetaServiceAccount
30
31 __all__ = ["ServiceAccounts", "AsyncServiceAccounts"]
32
33
34 class ServiceAccounts(SyncAPIResource):
35 @cached_property
36 def workspaces(self) -> Workspaces:
37 return Workspaces(self._client)
38
39 @cached_property
40 def with_raw_response(self) -> ServiceAccountsWithRawResponse:
41 """
42 This property can be used as a prefix for any HTTP method call to return
43 the raw response object instead of the parsed content.
44
45 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
46 """
47 return ServiceAccountsWithRawResponse(self)
48
49 @cached_property
50 def with_streaming_response(self) -> ServiceAccountsWithStreamingResponse:
51 """
52 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
53
54 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
55 """
56 return ServiceAccountsWithStreamingResponse(self)
57
58 def create(
59 self,
60 *,
61 name: str,
62 description: Optional[str] | Omit = omit,
63 organization_role: Literal["admin", "developer"] | Omit = omit,
64 betas: List[AnthropicBetaParam] | Omit = omit,
65 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
66 # The extra values given here take precedence over values defined on the client or passed to this method.
67 extra_headers: Headers | None = None,
68 extra_query: Query | None = None,
69 extra_body: Body | None = None,
70 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
71 ) -> BetaServiceAccount:
72 """
73 **Requires an OAuth access token with the `org:admin` scope**, from
74 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
75 API keys are not accepted. See
76 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
77
78 Create a service account.
79
80 A service account is a named workload identity that federation rules target.
81 `organization_role` is `developer` (default) or `admin`; a rule may only be
82 created or retargeted to grant `org:admin` scope when the target's
83 `organization_role` is `admin`. Creating an `admin`-role service account
84 requires an interactive credential (a user OAuth token or a Console session) — a
85 workload may only create `developer`-role service accounts.
86
87 Args:
88 name: Slug identifier (lowercase, digits, hyphens). Unique within the organization; a
89 duplicate name returns 409.
90
91 description: Optional free-text description.
92
93 organization_role: Org-level role. Defaults to `developer`.
94
95 betas: Optional header to specify the beta version(s) you want to use.
96
97 extra_headers: Send extra headers
98
99 extra_query: Add additional query parameters to the request
100
101 extra_body: Add additional JSON properties to the request
102
103 timeout: Override the client-level default timeout for this request, in seconds
104 """
105 extra_headers = {
106 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
107 **(extra_headers or {}),
108 }
109 return self._post(
110 "/v1/organizations/service_accounts?beta=true",
111 body={
112 "name": name,
113 "description": description,
114 "organization_role": organization_role,
115 },
116 options=make_request_options(
117 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
118 ),
119 cast_to=BetaServiceAccount,
120 )
121
122 def retrieve(
123 self,
124 service_account_id: str,
125 *,
126 betas: List[AnthropicBetaParam] | Omit = omit,
127 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
128 # The extra values given here take precedence over values defined on the client or passed to this method.
129 extra_headers: Headers | None = None,
130 extra_query: Query | None = None,
131 extra_body: Body | None = None,
132 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
133 ) -> BetaServiceAccount:
134 """
135 **Requires an OAuth access token with the `org:admin` scope**, from
136 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
137 API keys are not accepted. See
138 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
139
140 Retrieve a service account by its ID (`svac_...`).
141
142 Args:
143 service_account_id: ID of the service account.
144
145 betas: Optional header to specify the beta version(s) you want to use.
146
147 extra_headers: Send extra headers
148
149 extra_query: Add additional query parameters to the request
150
151 extra_body: Add additional JSON properties to the request
152
153 timeout: Override the client-level default timeout for this request, in seconds
154 """
155 if not service_account_id:
156 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
157 extra_headers = {
158 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
159 **(extra_headers or {}),
160 }
161 return self._get(
162 path_template(
163 "/v1/organizations/service_accounts/{service_account_id}?beta=true",
164 service_account_id=service_account_id,
165 ),
166 options=make_request_options(
167 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
168 ),
169 cast_to=BetaServiceAccount,
170 )
171
172 def update(
173 self,
174 service_account_id: str,
175 *,
176 description: Optional[str] | Omit = omit,
177 organization_role: Optional[Literal["admin", "developer"]] | Omit = omit,
178 betas: List[AnthropicBetaParam] | Omit = omit,
179 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
180 # The extra values given here take precedence over values defined on the client or passed to this method.
181 extra_headers: Headers | None = None,
182 extra_query: Query | None = None,
183 extra_body: Body | None = None,
184 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
185 ) -> BetaServiceAccount:
186 """
187 **Requires an OAuth access token with the `org:admin` scope**, from
188 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
189 API keys are not accepted. See
190 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
191
192 Update a service account.
193
194 Only `description` and `organization_role` are mutable; `name` cannot be
195 changed. Archived service accounts cannot be updated; this returns 400. Setting
196 `organization_role` to `admin` (even when unchanged) requires an interactive
197 credential (a user OAuth token or a Console session).
198
199 Args:
200 service_account_id: ID of the service account to update.
201
202 description: Replaces the description. Omit to leave unchanged; send `null` to clear (the
203 field is stored as an empty string).
204
205 organization_role: Replaces the org-level role. Omit or send `null` to leave unchanged.
206
207 betas: Optional header to specify the beta version(s) you want to use.
208
209 extra_headers: Send extra headers
210
211 extra_query: Add additional query parameters to the request
212
213 extra_body: Add additional JSON properties to the request
214
215 timeout: Override the client-level default timeout for this request, in seconds
216 """
217 if not service_account_id:
218 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
219 extra_headers = {
220 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
221 **(extra_headers or {}),
222 }
223 return self._post(
224 path_template(
225 "/v1/organizations/service_accounts/{service_account_id}?beta=true",
226 service_account_id=service_account_id,
227 ),
228 body={
229 "description": description,
230 "organization_role": organization_role,
231 },
232 options=make_request_options(
233 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
234 ),
235 cast_to=BetaServiceAccount,
236 )
237
238 def list(
239 self,
240 *,
241 include_archived: bool | Omit = omit,
242 limit: int | Omit = omit,
243 page: Optional[str] | Omit = omit,
244 betas: List[AnthropicBetaParam] | Omit = omit,
245 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
246 # The extra values given here take precedence over values defined on the client or passed to this method.
247 extra_headers: Headers | None = None,
248 extra_query: Query | None = None,
249 extra_body: Body | None = None,
250 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
251 ) -> SyncPageCursor[BetaServiceAccount]:
252 """
253 **Requires an OAuth access token with the `org:admin` scope**, from
254 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
255 API keys are not accepted. See
256 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
257
258 List service accounts in the caller's organization.
259
260 Results are ordered by creation time, newest first. Use `limit` and the
261 `next_page` cursor to paginate; set `include_archived=true` to include archived
262 service accounts.
263
264 Args:
265 include_archived: Include archived resources. Defaults to false.
266
267 limit: Number of results per page.
268
269 page: Opaque cursor from a previous response's `next_page`.
270
271 betas: Optional header to specify the beta version(s) you want to use.
272
273 extra_headers: Send extra headers
274
275 extra_query: Add additional query parameters to the request
276
277 extra_body: Add additional JSON properties to the request
278
279 timeout: Override the client-level default timeout for this request, in seconds
280 """
281 extra_headers = {
282 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
283 **(extra_headers or {}),
284 }
285 return self._get_api_list(
286 "/v1/organizations/service_accounts?beta=true",
287 page=SyncPageCursor[BetaServiceAccount],
288 options=make_request_options(
289 extra_headers=extra_headers,
290 extra_query=extra_query,
291 extra_body=extra_body,
292 timeout=timeout,
293 query={
294 "include_archived": include_archived,
295 "limit": limit,
296 "page": page,
297 },
298 ),
299 model=BetaServiceAccount,
300 )
301
302 def archive(
303 self,
304 service_account_id: str,
305 *,
306 betas: List[AnthropicBetaParam] | Omit = omit,
307 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
308 # The extra values given here take precedence over values defined on the client or passed to this method.
309 extra_headers: Headers | None = None,
310 extra_query: Query | None = None,
311 extra_body: Body | None = None,
312 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
313 ) -> BetaServiceAccount:
314 """
315 **Requires an OAuth access token with the `org:admin` scope**, from
316 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
317 API keys are not accepted. See
318 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
319
320 Archive a service account.
321
322 Idempotent; re-archiving returns the service account with its original
323 `archived_at`. Rejected with 400 if any live (non-archived) federation rule
324 still targets this service account, same as issuer archival; archive those rules
325 first or change their target to another service account.
326
327 Args:
328 service_account_id: ID of the service account to archive.
329
330 betas: Optional header to specify the beta version(s) you want to use.
331
332 extra_headers: Send extra headers
333
334 extra_query: Add additional query parameters to the request
335
336 extra_body: Add additional JSON properties to the request
337
338 timeout: Override the client-level default timeout for this request, in seconds
339 """
340 if not service_account_id:
341 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
342 extra_headers = {
343 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
344 **(extra_headers or {}),
345 }
346 return self._post(
347 path_template(
348 "/v1/organizations/service_accounts/{service_account_id}/archive?beta=true",
349 service_account_id=service_account_id,
350 ),
351 options=make_request_options(
352 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
353 ),
354 cast_to=BetaServiceAccount,
355 )
356
357
358 class AsyncServiceAccounts(AsyncAPIResource):
359 @cached_property
360 def workspaces(self) -> AsyncWorkspaces:
361 return AsyncWorkspaces(self._client)
362
363 @cached_property
364 def with_raw_response(self) -> AsyncServiceAccountsWithRawResponse:
365 """
366 This property can be used as a prefix for any HTTP method call to return
367 the raw response object instead of the parsed content.
368
369 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
370 """
371 return AsyncServiceAccountsWithRawResponse(self)
372
373 @cached_property
374 def with_streaming_response(self) -> AsyncServiceAccountsWithStreamingResponse:
375 """
376 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
377
378 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
379 """
380 return AsyncServiceAccountsWithStreamingResponse(self)
381
382 async def create(
383 self,
384 *,
385 name: str,
386 description: Optional[str] | Omit = omit,
387 organization_role: Literal["admin", "developer"] | Omit = omit,
388 betas: List[AnthropicBetaParam] | Omit = omit,
389 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
390 # The extra values given here take precedence over values defined on the client or passed to this method.
391 extra_headers: Headers | None = None,
392 extra_query: Query | None = None,
393 extra_body: Body | None = None,
394 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
395 ) -> BetaServiceAccount:
396 """
397 **Requires an OAuth access token with the `org:admin` scope**, from
398 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
399 API keys are not accepted. See
400 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
401
402 Create a service account.
403
404 A service account is a named workload identity that federation rules target.
405 `organization_role` is `developer` (default) or `admin`; a rule may only be
406 created or retargeted to grant `org:admin` scope when the target's
407 `organization_role` is `admin`. Creating an `admin`-role service account
408 requires an interactive credential (a user OAuth token or a Console session) — a
409 workload may only create `developer`-role service accounts.
410
411 Args:
412 name: Slug identifier (lowercase, digits, hyphens). Unique within the organization; a
413 duplicate name returns 409.
414
415 description: Optional free-text description.
416
417 organization_role: Org-level role. Defaults to `developer`.
418
419 betas: Optional header to specify the beta version(s) you want to use.
420
421 extra_headers: Send extra headers
422
423 extra_query: Add additional query parameters to the request
424
425 extra_body: Add additional JSON properties to the request
426
427 timeout: Override the client-level default timeout for this request, in seconds
428 """
429 extra_headers = {
430 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
431 **(extra_headers or {}),
432 }
433 return await self._post(
434 "/v1/organizations/service_accounts?beta=true",
435 body={
436 "name": name,
437 "description": description,
438 "organization_role": organization_role,
439 },
440 options=make_request_options(
441 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
442 ),
443 cast_to=BetaServiceAccount,
444 )
445
446 async def retrieve(
447 self,
448 service_account_id: str,
449 *,
450 betas: List[AnthropicBetaParam] | Omit = omit,
451 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
452 # The extra values given here take precedence over values defined on the client or passed to this method.
453 extra_headers: Headers | None = None,
454 extra_query: Query | None = None,
455 extra_body: Body | None = None,
456 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
457 ) -> BetaServiceAccount:
458 """
459 **Requires an OAuth access token with the `org:admin` scope**, from
460 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
461 API keys are not accepted. See
462 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
463
464 Retrieve a service account by its ID (`svac_...`).
465
466 Args:
467 service_account_id: ID of the service account.
468
469 betas: Optional header to specify the beta version(s) you want to use.
470
471 extra_headers: Send extra headers
472
473 extra_query: Add additional query parameters to the request
474
475 extra_body: Add additional JSON properties to the request
476
477 timeout: Override the client-level default timeout for this request, in seconds
478 """
479 if not service_account_id:
480 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
481 extra_headers = {
482 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
483 **(extra_headers or {}),
484 }
485 return await self._get(
486 path_template(
487 "/v1/organizations/service_accounts/{service_account_id}?beta=true",
488 service_account_id=service_account_id,
489 ),
490 options=make_request_options(
491 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
492 ),
493 cast_to=BetaServiceAccount,
494 )
495
496 async def update(
497 self,
498 service_account_id: str,
499 *,
500 description: Optional[str] | Omit = omit,
501 organization_role: Optional[Literal["admin", "developer"]] | Omit = omit,
502 betas: List[AnthropicBetaParam] | Omit = omit,
503 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
504 # The extra values given here take precedence over values defined on the client or passed to this method.
505 extra_headers: Headers | None = None,
506 extra_query: Query | None = None,
507 extra_body: Body | None = None,
508 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
509 ) -> BetaServiceAccount:
510 """
511 **Requires an OAuth access token with the `org:admin` scope**, from
512 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
513 API keys are not accepted. See
514 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
515
516 Update a service account.
517
518 Only `description` and `organization_role` are mutable; `name` cannot be
519 changed. Archived service accounts cannot be updated; this returns 400. Setting
520 `organization_role` to `admin` (even when unchanged) requires an interactive
521 credential (a user OAuth token or a Console session).
522
523 Args:
524 service_account_id: ID of the service account to update.
525
526 description: Replaces the description. Omit to leave unchanged; send `null` to clear (the
527 field is stored as an empty string).
528
529 organization_role: Replaces the org-level role. Omit or send `null` to leave unchanged.
530
531 betas: Optional header to specify the beta version(s) you want to use.
532
533 extra_headers: Send extra headers
534
535 extra_query: Add additional query parameters to the request
536
537 extra_body: Add additional JSON properties to the request
538
539 timeout: Override the client-level default timeout for this request, in seconds
540 """
541 if not service_account_id:
542 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
543 extra_headers = {
544 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
545 **(extra_headers or {}),
546 }
547 return await self._post(
548 path_template(
549 "/v1/organizations/service_accounts/{service_account_id}?beta=true",
550 service_account_id=service_account_id,
551 ),
552 body={
553 "description": description,
554 "organization_role": organization_role,
555 },
556 options=make_request_options(
557 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
558 ),
559 cast_to=BetaServiceAccount,
560 )
561
562 def list(
563 self,
564 *,
565 include_archived: bool | Omit = omit,
566 limit: int | Omit = omit,
567 page: Optional[str] | Omit = omit,
568 betas: List[AnthropicBetaParam] | Omit = omit,
569 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
570 # The extra values given here take precedence over values defined on the client or passed to this method.
571 extra_headers: Headers | None = None,
572 extra_query: Query | None = None,
573 extra_body: Body | None = None,
574 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
575 ) -> AsyncPaginator[BetaServiceAccount, AsyncPageCursor[BetaServiceAccount]]:
576 """
577 **Requires an OAuth access token with the `org:admin` scope**, from
578 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
579 API keys are not accepted. See
580 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
581
582 List service accounts in the caller's organization.
583
584 Results are ordered by creation time, newest first. Use `limit` and the
585 `next_page` cursor to paginate; set `include_archived=true` to include archived
586 service accounts.
587
588 Args:
589 include_archived: Include archived resources. Defaults to false.
590
591 limit: Number of results per page.
592
593 page: Opaque cursor from a previous response's `next_page`.
594
595 betas: Optional header to specify the beta version(s) you want to use.
596
597 extra_headers: Send extra headers
598
599 extra_query: Add additional query parameters to the request
600
601 extra_body: Add additional JSON properties to the request
602
603 timeout: Override the client-level default timeout for this request, in seconds
604 """
605 extra_headers = {
606 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
607 **(extra_headers or {}),
608 }
609 return self._get_api_list(
610 "/v1/organizations/service_accounts?beta=true",
611 page=AsyncPageCursor[BetaServiceAccount],
612 options=make_request_options(
613 extra_headers=extra_headers,
614 extra_query=extra_query,
615 extra_body=extra_body,
616 timeout=timeout,
617 query={
618 "include_archived": include_archived,
619 "limit": limit,
620 "page": page,
621 },
622 ),
623 model=BetaServiceAccount,
624 )
625
626 async def archive(
627 self,
628 service_account_id: str,
629 *,
630 betas: List[AnthropicBetaParam] | Omit = omit,
631 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
632 # The extra values given here take precedence over values defined on the client or passed to this method.
633 extra_headers: Headers | None = None,
634 extra_query: Query | None = None,
635 extra_body: Body | None = None,
636 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
637 ) -> BetaServiceAccount:
638 """
639 **Requires an OAuth access token with the `org:admin` scope**, from
640 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
641 API keys are not accepted. See
642 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
643
644 Archive a service account.
645
646 Idempotent; re-archiving returns the service account with its original
647 `archived_at`. Rejected with 400 if any live (non-archived) federation rule
648 still targets this service account, same as issuer archival; archive those rules
649 first or change their target to another service account.
650
651 Args:
652 service_account_id: ID of the service account to archive.
653
654 betas: Optional header to specify the beta version(s) you want to use.
655
656 extra_headers: Send extra headers
657
658 extra_query: Add additional query parameters to the request
659
660 extra_body: Add additional JSON properties to the request
661
662 timeout: Override the client-level default timeout for this request, in seconds
663 """
664 if not service_account_id:
665 raise ValueError(f"Expected a non-empty value for `service_account_id` but received {service_account_id!r}")
666 extra_headers = {
667 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
668 **(extra_headers or {}),
669 }
670 return await self._post(
671 path_template(
672 "/v1/organizations/service_accounts/{service_account_id}/archive?beta=true",
673 service_account_id=service_account_id,
674 ),
675 options=make_request_options(
676 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
677 ),
678 cast_to=BetaServiceAccount,
679 )
680
681
682 class ServiceAccountsWithRawResponse:
683 def __init__(self, service_accounts: ServiceAccounts) -> None:
684 self._service_accounts = service_accounts
685
686 self.create = to_raw_response_wrapper(
687 service_accounts.create,
688 )
689 self.retrieve = to_raw_response_wrapper(
690 service_accounts.retrieve,
691 )
692 self.update = to_raw_response_wrapper(
693 service_accounts.update,
694 )
695 self.list = to_raw_response_wrapper(
696 service_accounts.list,
697 )
698 self.archive = to_raw_response_wrapper(
699 service_accounts.archive,
700 )
701
702 @cached_property
703 def workspaces(self) -> WorkspacesWithRawResponse:
704 return WorkspacesWithRawResponse(self._service_accounts.workspaces)
705
706
707 class AsyncServiceAccountsWithRawResponse:
708 def __init__(self, service_accounts: AsyncServiceAccounts) -> None:
709 self._service_accounts = service_accounts
710
711 self.create = async_to_raw_response_wrapper(
712 service_accounts.create,
713 )
714 self.retrieve = async_to_raw_response_wrapper(
715 service_accounts.retrieve,
716 )
717 self.update = async_to_raw_response_wrapper(
718 service_accounts.update,
719 )
720 self.list = async_to_raw_response_wrapper(
721 service_accounts.list,
722 )
723 self.archive = async_to_raw_response_wrapper(
724 service_accounts.archive,
725 )
726
727 @cached_property
728 def workspaces(self) -> AsyncWorkspacesWithRawResponse:
729 return AsyncWorkspacesWithRawResponse(self._service_accounts.workspaces)
730
731
732 class ServiceAccountsWithStreamingResponse:
733 def __init__(self, service_accounts: ServiceAccounts) -> None:
734 self._service_accounts = service_accounts
735
736 self.create = to_streamed_response_wrapper(
737 service_accounts.create,
738 )
739 self.retrieve = to_streamed_response_wrapper(
740 service_accounts.retrieve,
741 )
742 self.update = to_streamed_response_wrapper(
743 service_accounts.update,
744 )
745 self.list = to_streamed_response_wrapper(
746 service_accounts.list,
747 )
748 self.archive = to_streamed_response_wrapper(
749 service_accounts.archive,
750 )
751
752 @cached_property
753 def workspaces(self) -> WorkspacesWithStreamingResponse:
754 return WorkspacesWithStreamingResponse(self._service_accounts.workspaces)
755
756
757 class AsyncServiceAccountsWithStreamingResponse:
758 def __init__(self, service_accounts: AsyncServiceAccounts) -> None:
759 self._service_accounts = service_accounts
760
761 self.create = async_to_streamed_response_wrapper(
762 service_accounts.create,
763 )
764 self.retrieve = async_to_streamed_response_wrapper(
765 service_accounts.retrieve,
766 )
767 self.update = async_to_streamed_response_wrapper(
768 service_accounts.update,
769 )
770 self.list = async_to_streamed_response_wrapper(
771 service_accounts.list,
772 )
773 self.archive = async_to_streamed_response_wrapper(
774 service_accounts.archive,
775 )
776
777 @cached_property
778 def workspaces(self) -> AsyncWorkspacesWithStreamingResponse:
779 return AsyncWorkspacesWithStreamingResponse(self._service_accounts.workspaces)