Debian Codegraph @

src/anthropic/resources/beta/organization/federation/issuers.py

raw
1 from __future__ import annotations
2
3 from typing import List, Optional
4
5 import httpx2
6
7 from ....._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
8 from ....._utils import is_given, path_template, strip_not_given
9 from ....._compat import cached_property
10 from ....._resource import SyncAPIResource, AsyncAPIResource
11 from ....._response import (
12 to_raw_response_wrapper,
13 to_streamed_response_wrapper,
14 async_to_raw_response_wrapper,
15 async_to_streamed_response_wrapper,
16 )
17 from .....pagination import SyncPageCursor, AsyncPageCursor
18 from ....._base_client import AsyncPaginator, make_request_options
19 from .....types.anthropic_beta_param import AnthropicBetaParam
20 from .....types.beta.organization.federation import issuer_create_params, issuer_update_params
21 from .....types.beta.organization.federation.beta_federation_issuer import BetaFederationIssuer
22
23 __all__ = ["Issuers", "AsyncIssuers"]
24
25
26 class Issuers(SyncAPIResource):
27 @cached_property
28 def with_raw_response(self) -> IssuersWithRawResponse:
29 """
30 This property can be used as a prefix for any HTTP method call to return
31 the raw response object instead of the parsed content.
32
33 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
34 """
35 return IssuersWithRawResponse(self)
36
37 @cached_property
38 def with_streaming_response(self) -> IssuersWithStreamingResponse:
39 """
40 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
41
42 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
43 """
44 return IssuersWithStreamingResponse(self)
45
46 def create(
47 self,
48 *,
49 issuer_url: str,
50 name: str,
51 check_jti: Optional[bool] | Omit = omit,
52 jwks: issuer_create_params.JWKS | Omit = omit,
53 max_jwt_lifetime_seconds: Optional[int] | Omit = omit,
54 betas: List[AnthropicBetaParam] | Omit = omit,
55 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
56 # The extra values given here take precedence over values defined on the client or passed to this method.
57 extra_headers: Headers | None = None,
58 extra_query: Query | None = None,
59 extra_body: Body | None = None,
60 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
61 ) -> BetaFederationIssuer:
62 """
63 **Requires an OAuth access token with the `org:admin` scope**, from
64 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
65 API keys are not accepted. See
66 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
67
68 Register an OIDC issuer that Anthropic will trust for workload identity
69 federation in your organization.
70
71 The `jwks` field controls how the issuer's signing keys are obtained and takes
72 one of three shapes selected by `type`: `discovery` (resolve keys through OIDC
73 discovery), `explicit_url` (fetch keys from a fixed JWKS URL), or `inline`
74 (provide a static key set). When `jwks.type` is `discovery` and no
75 `discovery_base` is set, the issuer URL must be publicly reachable over HTTPS so
76 Anthropic can fetch the discovery document; for `explicit_url` and `inline`
77 modes the issuer URL is only matched as the JWT's `iss` claim and is not
78 fetched.
79
80 Args:
81 issuer_url: The `iss` claim value to match against.
82
83 name: Slug identifier (lowercase, digits, hyphens). Unique within the organization; a
84 duplicate name returns 409.
85
86 check_jti: Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for
87 tokens from this issuer. Defaults to true. Applies only to assertions carrying a
88 `jti` claim; tokens without one are accepted without single-use enforcement.
89
90 jwks: How signing keys are obtained. Defaults to OIDC discovery.
91
92 max_jwt_lifetime_seconds: Maximum allowed iat→exp spread for assertions from this issuer (1-176400
93 seconds, i.e. up to 49h). Defaults to 3600 (1h). Assertions must carry both
94 `iat` and `exp`; a missing `iat` is rejected.
95
96 betas: Optional header to specify the beta version(s) you want to use.
97
98 extra_headers: Send extra headers
99
100 extra_query: Add additional query parameters to the request
101
102 extra_body: Add additional JSON properties to the request
103
104 timeout: Override the client-level default timeout for this request, in seconds
105 """
106 extra_headers = {
107 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
108 **(extra_headers or {}),
109 }
110 return self._post(
111 "/v1/organizations/federation_issuers?beta=true",
112 body={
113 "issuer_url": issuer_url,
114 "name": name,
115 "check_jti": check_jti,
116 "jwks": jwks,
117 "max_jwt_lifetime_seconds": max_jwt_lifetime_seconds,
118 },
119 options=make_request_options(
120 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
121 ),
122 cast_to=BetaFederationIssuer,
123 )
124
125 def retrieve(
126 self,
127 federation_issuer_id: str,
128 *,
129 betas: List[AnthropicBetaParam] | 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 ) -> BetaFederationIssuer:
137 """
138 **Requires an OAuth access token with the `org:admin` scope**, from
139 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
140 API keys are not accepted. See
141 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
142
143 Retrieve a federation issuer by its ID (`fdis_...`).
144
145 Args:
146 federation_issuer_id: ID of the federation issuer.
147
148 betas: Optional header to specify the beta version(s) you want to use.
149
150 extra_headers: Send extra headers
151
152 extra_query: Add additional query parameters to the request
153
154 extra_body: Add additional JSON properties to the request
155
156 timeout: Override the client-level default timeout for this request, in seconds
157 """
158 if not federation_issuer_id:
159 raise ValueError(
160 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
161 )
162 extra_headers = {
163 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
164 **(extra_headers or {}),
165 }
166 return self._get(
167 path_template(
168 "/v1/organizations/federation_issuers/{federation_issuer_id}?beta=true",
169 federation_issuer_id=federation_issuer_id,
170 ),
171 options=make_request_options(
172 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
173 ),
174 cast_to=BetaFederationIssuer,
175 )
176
177 def update(
178 self,
179 federation_issuer_id: str,
180 *,
181 check_jti: Optional[bool] | Omit = omit,
182 issuer_url: Optional[str] | Omit = omit,
183 jwks: Optional[issuer_update_params.JWKS] | Omit = omit,
184 jwks_polling_disabled: Optional[bool] | Omit = omit,
185 max_jwt_lifetime_seconds: Optional[int] | Omit = omit,
186 name: Optional[str] | Omit = omit,
187 betas: List[AnthropicBetaParam] | Omit = omit,
188 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
189 # The extra values given here take precedence over values defined on the client or passed to this method.
190 extra_headers: Headers | None = None,
191 extra_query: Query | None = None,
192 extra_body: Body | None = None,
193 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
194 ) -> BetaFederationIssuer:
195 """
196 **Requires an OAuth access token with the `org:admin` scope**, from
197 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
198 API keys are not accepted. See
199 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
200
201 Partially update a federation issuer.
202
203 Setting `jwks` replaces the full JWKS shape at once. Archived issuers cannot be
204 updated; this returns 400. Create a new issuer instead.
205
206 Updating an issuer that backs a rule with a scope outside `workspace:developer`
207 or `workspace:inference` requires a Console session.
208
209 Args:
210 federation_issuer_id: ID of the federation issuer to update.
211
212 check_jti: Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for
213 tokens from this issuer. Applies only to assertions carrying a `jti` claim;
214 tokens without one are accepted without single-use enforcement.
215
216 issuer_url: Replaces the `iss` claim value to match against. For discovery-mode issuers
217 without a `discovery_base`, this is also the URL Anthropic fetches the OIDC
218 discovery document and signing keys from, so changing it repoints the JWKS
219 source. Changing the issuer URL to a well-known shared platform is rejected
220 while any live rule under this issuer would not constrain tenant identity.
221
222 jwks: Replaces the entire JWKS configuration.
223
224 jwks_polling_disabled: Only `false` is accepted, to re-enable polling after the system pauses it.
225 Polling is paused automatically; sending `true` is rejected.
226
227 max_jwt_lifetime_seconds: Maximum allowed iat→exp spread for assertions from this issuer (1-176400
228 seconds, i.e. up to 49h). Assertions must carry both `iat` and `exp`; a missing
229 `iat` is rejected.
230
231 name: Replaces the slug identifier (lowercase, digits, hyphens). Unique within the
232 organization; a duplicate name returns 409.
233
234 betas: Optional header to specify the beta version(s) you want to use.
235
236 extra_headers: Send extra headers
237
238 extra_query: Add additional query parameters to the request
239
240 extra_body: Add additional JSON properties to the request
241
242 timeout: Override the client-level default timeout for this request, in seconds
243 """
244 if not federation_issuer_id:
245 raise ValueError(
246 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
247 )
248 extra_headers = {
249 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
250 **(extra_headers or {}),
251 }
252 return self._post(
253 path_template(
254 "/v1/organizations/federation_issuers/{federation_issuer_id}?beta=true",
255 federation_issuer_id=federation_issuer_id,
256 ),
257 body={
258 "check_jti": check_jti,
259 "issuer_url": issuer_url,
260 "jwks": jwks,
261 "jwks_polling_disabled": jwks_polling_disabled,
262 "max_jwt_lifetime_seconds": max_jwt_lifetime_seconds,
263 "name": name,
264 },
265 options=make_request_options(
266 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
267 ),
268 cast_to=BetaFederationIssuer,
269 )
270
271 def list(
272 self,
273 *,
274 include_archived: bool | Omit = omit,
275 limit: int | Omit = omit,
276 page: Optional[str] | Omit = omit,
277 betas: List[AnthropicBetaParam] | Omit = omit,
278 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
279 # The extra values given here take precedence over values defined on the client or passed to this method.
280 extra_headers: Headers | None = None,
281 extra_query: Query | None = None,
282 extra_body: Body | None = None,
283 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
284 ) -> SyncPageCursor[BetaFederationIssuer]:
285 """
286 **Requires an OAuth access token with the `org:admin` scope**, from
287 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
288 API keys are not accepted. See
289 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
290
291 List federation issuers in your organization.
292
293 Archived issuers are excluded unless `include_archived=true`.
294
295 Args:
296 include_archived: Include archived resources. Defaults to false.
297
298 limit: Number of results per page.
299
300 page: Opaque cursor from a previous response's `next_page`.
301
302 betas: Optional header to specify the beta version(s) you want to use.
303
304 extra_headers: Send extra headers
305
306 extra_query: Add additional query parameters to the request
307
308 extra_body: Add additional JSON properties to the request
309
310 timeout: Override the client-level default timeout for this request, in seconds
311 """
312 extra_headers = {
313 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
314 **(extra_headers or {}),
315 }
316 return self._get_api_list(
317 "/v1/organizations/federation_issuers?beta=true",
318 page=SyncPageCursor[BetaFederationIssuer],
319 options=make_request_options(
320 extra_headers=extra_headers,
321 extra_query=extra_query,
322 extra_body=extra_body,
323 timeout=timeout,
324 query={
325 "include_archived": include_archived,
326 "limit": limit,
327 "page": page,
328 },
329 ),
330 model=BetaFederationIssuer,
331 )
332
333 def archive(
334 self,
335 federation_issuer_id: str,
336 *,
337 betas: List[AnthropicBetaParam] | Omit = omit,
338 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
339 # The extra values given here take precedence over values defined on the client or passed to this method.
340 extra_headers: Headers | None = None,
341 extra_query: Query | None = None,
342 extra_body: Body | None = None,
343 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
344 ) -> BetaFederationIssuer:
345 """
346 **Requires an OAuth access token with the `org:admin` scope**, from
347 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
348 API keys are not accepted. See
349 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
350
351 Archive a federation issuer.
352
353 Idempotent; re-archiving returns the issuer with its original `archived_at`.
354 Rejected with 400 if any live (non-archived) federation rule still references
355 the issuer; archive those rules first (a rule's issuer cannot be changed), or
356 recreate them against another issuer.
357
358 Args:
359 federation_issuer_id: ID of the federation issuer to archive.
360
361 betas: Optional header to specify the beta version(s) you want to use.
362
363 extra_headers: Send extra headers
364
365 extra_query: Add additional query parameters to the request
366
367 extra_body: Add additional JSON properties to the request
368
369 timeout: Override the client-level default timeout for this request, in seconds
370 """
371 if not federation_issuer_id:
372 raise ValueError(
373 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
374 )
375 extra_headers = {
376 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
377 **(extra_headers or {}),
378 }
379 return self._post(
380 path_template(
381 "/v1/organizations/federation_issuers/{federation_issuer_id}/archive?beta=true",
382 federation_issuer_id=federation_issuer_id,
383 ),
384 options=make_request_options(
385 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
386 ),
387 cast_to=BetaFederationIssuer,
388 )
389
390
391 class AsyncIssuers(AsyncAPIResource):
392 @cached_property
393 def with_raw_response(self) -> AsyncIssuersWithRawResponse:
394 """
395 This property can be used as a prefix for any HTTP method call to return
396 the raw response object instead of the parsed content.
397
398 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
399 """
400 return AsyncIssuersWithRawResponse(self)
401
402 @cached_property
403 def with_streaming_response(self) -> AsyncIssuersWithStreamingResponse:
404 """
405 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
406
407 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
408 """
409 return AsyncIssuersWithStreamingResponse(self)
410
411 async def create(
412 self,
413 *,
414 issuer_url: str,
415 name: str,
416 check_jti: Optional[bool] | Omit = omit,
417 jwks: issuer_create_params.JWKS | Omit = omit,
418 max_jwt_lifetime_seconds: Optional[int] | Omit = omit,
419 betas: List[AnthropicBetaParam] | Omit = omit,
420 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
421 # The extra values given here take precedence over values defined on the client or passed to this method.
422 extra_headers: Headers | None = None,
423 extra_query: Query | None = None,
424 extra_body: Body | None = None,
425 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
426 ) -> BetaFederationIssuer:
427 """
428 **Requires an OAuth access token with the `org:admin` scope**, from
429 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
430 API keys are not accepted. See
431 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
432
433 Register an OIDC issuer that Anthropic will trust for workload identity
434 federation in your organization.
435
436 The `jwks` field controls how the issuer's signing keys are obtained and takes
437 one of three shapes selected by `type`: `discovery` (resolve keys through OIDC
438 discovery), `explicit_url` (fetch keys from a fixed JWKS URL), or `inline`
439 (provide a static key set). When `jwks.type` is `discovery` and no
440 `discovery_base` is set, the issuer URL must be publicly reachable over HTTPS so
441 Anthropic can fetch the discovery document; for `explicit_url` and `inline`
442 modes the issuer URL is only matched as the JWT's `iss` claim and is not
443 fetched.
444
445 Args:
446 issuer_url: The `iss` claim value to match against.
447
448 name: Slug identifier (lowercase, digits, hyphens). Unique within the organization; a
449 duplicate name returns 409.
450
451 check_jti: Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for
452 tokens from this issuer. Defaults to true. Applies only to assertions carrying a
453 `jti` claim; tokens without one are accepted without single-use enforcement.
454
455 jwks: How signing keys are obtained. Defaults to OIDC discovery.
456
457 max_jwt_lifetime_seconds: Maximum allowed iat→exp spread for assertions from this issuer (1-176400
458 seconds, i.e. up to 49h). Defaults to 3600 (1h). Assertions must carry both
459 `iat` and `exp`; a missing `iat` is rejected.
460
461 betas: Optional header to specify the beta version(s) you want to use.
462
463 extra_headers: Send extra headers
464
465 extra_query: Add additional query parameters to the request
466
467 extra_body: Add additional JSON properties to the request
468
469 timeout: Override the client-level default timeout for this request, in seconds
470 """
471 extra_headers = {
472 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
473 **(extra_headers or {}),
474 }
475 return await self._post(
476 "/v1/organizations/federation_issuers?beta=true",
477 body={
478 "issuer_url": issuer_url,
479 "name": name,
480 "check_jti": check_jti,
481 "jwks": jwks,
482 "max_jwt_lifetime_seconds": max_jwt_lifetime_seconds,
483 },
484 options=make_request_options(
485 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
486 ),
487 cast_to=BetaFederationIssuer,
488 )
489
490 async def retrieve(
491 self,
492 federation_issuer_id: str,
493 *,
494 betas: List[AnthropicBetaParam] | Omit = omit,
495 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
496 # The extra values given here take precedence over values defined on the client or passed to this method.
497 extra_headers: Headers | None = None,
498 extra_query: Query | None = None,
499 extra_body: Body | None = None,
500 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
501 ) -> BetaFederationIssuer:
502 """
503 **Requires an OAuth access token with the `org:admin` scope**, from
504 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
505 API keys are not accepted. See
506 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
507
508 Retrieve a federation issuer by its ID (`fdis_...`).
509
510 Args:
511 federation_issuer_id: ID of the federation issuer.
512
513 betas: Optional header to specify the beta version(s) you want to use.
514
515 extra_headers: Send extra headers
516
517 extra_query: Add additional query parameters to the request
518
519 extra_body: Add additional JSON properties to the request
520
521 timeout: Override the client-level default timeout for this request, in seconds
522 """
523 if not federation_issuer_id:
524 raise ValueError(
525 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
526 )
527 extra_headers = {
528 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
529 **(extra_headers or {}),
530 }
531 return await self._get(
532 path_template(
533 "/v1/organizations/federation_issuers/{federation_issuer_id}?beta=true",
534 federation_issuer_id=federation_issuer_id,
535 ),
536 options=make_request_options(
537 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
538 ),
539 cast_to=BetaFederationIssuer,
540 )
541
542 async def update(
543 self,
544 federation_issuer_id: str,
545 *,
546 check_jti: Optional[bool] | Omit = omit,
547 issuer_url: Optional[str] | Omit = omit,
548 jwks: Optional[issuer_update_params.JWKS] | Omit = omit,
549 jwks_polling_disabled: Optional[bool] | Omit = omit,
550 max_jwt_lifetime_seconds: Optional[int] | Omit = omit,
551 name: Optional[str] | Omit = omit,
552 betas: List[AnthropicBetaParam] | Omit = omit,
553 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
554 # The extra values given here take precedence over values defined on the client or passed to this method.
555 extra_headers: Headers | None = None,
556 extra_query: Query | None = None,
557 extra_body: Body | None = None,
558 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
559 ) -> BetaFederationIssuer:
560 """
561 **Requires an OAuth access token with the `org:admin` scope**, from
562 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
563 API keys are not accepted. See
564 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
565
566 Partially update a federation issuer.
567
568 Setting `jwks` replaces the full JWKS shape at once. Archived issuers cannot be
569 updated; this returns 400. Create a new issuer instead.
570
571 Updating an issuer that backs a rule with a scope outside `workspace:developer`
572 or `workspace:inference` requires a Console session.
573
574 Args:
575 federation_issuer_id: ID of the federation issuer to update.
576
577 check_jti: Whether the jwt-bearer exchange enforces JTI single-use (replay protection) for
578 tokens from this issuer. Applies only to assertions carrying a `jti` claim;
579 tokens without one are accepted without single-use enforcement.
580
581 issuer_url: Replaces the `iss` claim value to match against. For discovery-mode issuers
582 without a `discovery_base`, this is also the URL Anthropic fetches the OIDC
583 discovery document and signing keys from, so changing it repoints the JWKS
584 source. Changing the issuer URL to a well-known shared platform is rejected
585 while any live rule under this issuer would not constrain tenant identity.
586
587 jwks: Replaces the entire JWKS configuration.
588
589 jwks_polling_disabled: Only `false` is accepted, to re-enable polling after the system pauses it.
590 Polling is paused automatically; sending `true` is rejected.
591
592 max_jwt_lifetime_seconds: Maximum allowed iat→exp spread for assertions from this issuer (1-176400
593 seconds, i.e. up to 49h). Assertions must carry both `iat` and `exp`; a missing
594 `iat` is rejected.
595
596 name: Replaces the slug identifier (lowercase, digits, hyphens). Unique within the
597 organization; a duplicate name returns 409.
598
599 betas: Optional header to specify the beta version(s) you want to use.
600
601 extra_headers: Send extra headers
602
603 extra_query: Add additional query parameters to the request
604
605 extra_body: Add additional JSON properties to the request
606
607 timeout: Override the client-level default timeout for this request, in seconds
608 """
609 if not federation_issuer_id:
610 raise ValueError(
611 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
612 )
613 extra_headers = {
614 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
615 **(extra_headers or {}),
616 }
617 return await self._post(
618 path_template(
619 "/v1/organizations/federation_issuers/{federation_issuer_id}?beta=true",
620 federation_issuer_id=federation_issuer_id,
621 ),
622 body={
623 "check_jti": check_jti,
624 "issuer_url": issuer_url,
625 "jwks": jwks,
626 "jwks_polling_disabled": jwks_polling_disabled,
627 "max_jwt_lifetime_seconds": max_jwt_lifetime_seconds,
628 "name": name,
629 },
630 options=make_request_options(
631 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
632 ),
633 cast_to=BetaFederationIssuer,
634 )
635
636 def list(
637 self,
638 *,
639 include_archived: bool | Omit = omit,
640 limit: int | Omit = omit,
641 page: Optional[str] | Omit = omit,
642 betas: List[AnthropicBetaParam] | Omit = omit,
643 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
644 # The extra values given here take precedence over values defined on the client or passed to this method.
645 extra_headers: Headers | None = None,
646 extra_query: Query | None = None,
647 extra_body: Body | None = None,
648 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
649 ) -> AsyncPaginator[BetaFederationIssuer, AsyncPageCursor[BetaFederationIssuer]]:
650 """
651 **Requires an OAuth access token with the `org:admin` scope**, from
652 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
653 API keys are not accepted. See
654 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
655
656 List federation issuers in your organization.
657
658 Archived issuers are excluded unless `include_archived=true`.
659
660 Args:
661 include_archived: Include archived resources. Defaults to false.
662
663 limit: Number of results per page.
664
665 page: Opaque cursor from a previous response's `next_page`.
666
667 betas: Optional header to specify the beta version(s) you want to use.
668
669 extra_headers: Send extra headers
670
671 extra_query: Add additional query parameters to the request
672
673 extra_body: Add additional JSON properties to the request
674
675 timeout: Override the client-level default timeout for this request, in seconds
676 """
677 extra_headers = {
678 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
679 **(extra_headers or {}),
680 }
681 return self._get_api_list(
682 "/v1/organizations/federation_issuers?beta=true",
683 page=AsyncPageCursor[BetaFederationIssuer],
684 options=make_request_options(
685 extra_headers=extra_headers,
686 extra_query=extra_query,
687 extra_body=extra_body,
688 timeout=timeout,
689 query={
690 "include_archived": include_archived,
691 "limit": limit,
692 "page": page,
693 },
694 ),
695 model=BetaFederationIssuer,
696 )
697
698 async def archive(
699 self,
700 federation_issuer_id: str,
701 *,
702 betas: List[AnthropicBetaParam] | Omit = omit,
703 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
704 # The extra values given here take precedence over values defined on the client or passed to this method.
705 extra_headers: Headers | None = None,
706 extra_query: Query | None = None,
707 extra_body: Body | None = None,
708 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
709 ) -> BetaFederationIssuer:
710 """
711 **Requires an OAuth access token with the `org:admin` scope**, from
712 `ant auth login --scope org:admin` or a workload identity federation rule; Admin
713 API keys are not accepted. See
714 [Manage WIF with the Admin API](/docs/en/manage-claude/wif-admin-api).
715
716 Archive a federation issuer.
717
718 Idempotent; re-archiving returns the issuer with its original `archived_at`.
719 Rejected with 400 if any live (non-archived) federation rule still references
720 the issuer; archive those rules first (a rule's issuer cannot be changed), or
721 recreate them against another issuer.
722
723 Args:
724 federation_issuer_id: ID of the federation issuer to archive.
725
726 betas: Optional header to specify the beta version(s) you want to use.
727
728 extra_headers: Send extra headers
729
730 extra_query: Add additional query parameters to the request
731
732 extra_body: Add additional JSON properties to the request
733
734 timeout: Override the client-level default timeout for this request, in seconds
735 """
736 if not federation_issuer_id:
737 raise ValueError(
738 f"Expected a non-empty value for `federation_issuer_id` but received {federation_issuer_id!r}"
739 )
740 extra_headers = {
741 **strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else not_given}),
742 **(extra_headers or {}),
743 }
744 return await self._post(
745 path_template(
746 "/v1/organizations/federation_issuers/{federation_issuer_id}/archive?beta=true",
747 federation_issuer_id=federation_issuer_id,
748 ),
749 options=make_request_options(
750 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
751 ),
752 cast_to=BetaFederationIssuer,
753 )
754
755
756 class IssuersWithRawResponse:
757 def __init__(self, issuers: Issuers) -> None:
758 self._issuers = issuers
759
760 self.create = to_raw_response_wrapper(
761 issuers.create,
762 )
763 self.retrieve = to_raw_response_wrapper(
764 issuers.retrieve,
765 )
766 self.update = to_raw_response_wrapper(
767 issuers.update,
768 )
769 self.list = to_raw_response_wrapper(
770 issuers.list,
771 )
772 self.archive = to_raw_response_wrapper(
773 issuers.archive,
774 )
775
776
777 class AsyncIssuersWithRawResponse:
778 def __init__(self, issuers: AsyncIssuers) -> None:
779 self._issuers = issuers
780
781 self.create = async_to_raw_response_wrapper(
782 issuers.create,
783 )
784 self.retrieve = async_to_raw_response_wrapper(
785 issuers.retrieve,
786 )
787 self.update = async_to_raw_response_wrapper(
788 issuers.update,
789 )
790 self.list = async_to_raw_response_wrapper(
791 issuers.list,
792 )
793 self.archive = async_to_raw_response_wrapper(
794 issuers.archive,
795 )
796
797
798 class IssuersWithStreamingResponse:
799 def __init__(self, issuers: Issuers) -> None:
800 self._issuers = issuers
801
802 self.create = to_streamed_response_wrapper(
803 issuers.create,
804 )
805 self.retrieve = to_streamed_response_wrapper(
806 issuers.retrieve,
807 )
808 self.update = to_streamed_response_wrapper(
809 issuers.update,
810 )
811 self.list = to_streamed_response_wrapper(
812 issuers.list,
813 )
814 self.archive = to_streamed_response_wrapper(
815 issuers.archive,
816 )
817
818
819 class AsyncIssuersWithStreamingResponse:
820 def __init__(self, issuers: AsyncIssuers) -> None:
821 self._issuers = issuers
822
823 self.create = async_to_streamed_response_wrapper(
824 issuers.create,
825 )
826 self.retrieve = async_to_streamed_response_wrapper(
827 issuers.retrieve,
828 )
829 self.update = async_to_streamed_response_wrapper(
830 issuers.update,
831 )
832 self.list = async_to_streamed_response_wrapper(
833 issuers.list,
834 )
835 self.archive = async_to_streamed_response_wrapper(
836 issuers.archive,
837 )