Debian Codegraph @

src/anthropic/resources/beta/tunnels/certificates.py

raw
1 from __future__ import annotations
2
3 from typing import List
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 ...._resource import SyncAPIResource, AsyncAPIResource
12 from ...._response import (
13 to_raw_response_wrapper,
14 to_streamed_response_wrapper,
15 async_to_raw_response_wrapper,
16 async_to_streamed_response_wrapper,
17 )
18 from ....pagination import SyncPageCursor, AsyncPageCursor
19 from ...._base_client import AsyncPaginator, make_request_options
20 from ....types.anthropic_beta_param import AnthropicBetaParam
21 from ....types.beta.tunnels.beta_tunnel_certificate import BetaTunnelCertificate
22
23 __all__ = ["Certificates", "AsyncCertificates"]
24
25
26 class Certificates(SyncAPIResource):
27 @cached_property
28 def with_raw_response(self) -> CertificatesWithRawResponse:
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 CertificatesWithRawResponse(self)
36
37 @cached_property
38 def with_streaming_response(self) -> CertificatesWithStreamingResponse:
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 CertificatesWithStreamingResponse(self)
45
46 def create(
47 self,
48 tunnel_id: str,
49 *,
50 ca_certificate_pem: str,
51 betas: List[AnthropicBetaParam] | Omit = omit,
52 workspace_id: str | Omit = omit,
53 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
54 # The extra values given here take precedence over values defined on the client or passed to this method.
55 extra_headers: Headers | None = None,
56 extra_query: Query | None = None,
57 extra_body: Body | None = None,
58 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
59 ) -> BetaTunnelCertificate:
60 """The Tunnels API is in research preview.
61
62 It requires the
63 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
64 deprecation period. It supersedes the Admin API endpoints at
65 `/v1/organizations/tunnels`, which remain available during a migration window.
66
67 Registers a public CA certificate on a tunnel. Anthropic verifies the gateway's
68 server certificate against this CA when it terminates the inner TLS session. A
69 tunnel holds at most two non-archived certificates.
70
71 Args:
72 tunnel_id: ID of the tunnel (`tnl_...`).
73
74 ca_certificate_pem: PEM-encoded X.509 CA certificate. Must contain exactly one certificate and no
75 private-key material. Maximum 8KB.
76
77 betas: Optional header to specify the beta version(s) you want to use.
78
79 workspace_id: Optional header to select the Workspace for this request. The value is a
80 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
81
82 Only needed for credentials that can act on more than one Workspace. A
83 credential that belongs to a specific Workspace may omit it; if sent, it must
84 match that Workspace.
85
86 extra_headers: Send extra headers
87
88 extra_query: Add additional query parameters to the request
89
90 extra_body: Add additional JSON properties to the request
91
92 timeout: Override the client-level default timeout for this request, in seconds
93 """
94 if not tunnel_id:
95 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
96 extra_headers = {
97 **strip_not_given(
98 {
99 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
100 if is_given(betas)
101 else not_given,
102 "anthropic-workspace-id": workspace_id,
103 }
104 ),
105 **(extra_headers or {}),
106 }
107 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
108 return self._post(
109 path_template("/v1/tunnels/{tunnel_id}/certificates?beta=true", tunnel_id=tunnel_id),
110 body={"ca_certificate_pem": ca_certificate_pem},
111 options=make_request_options(
112 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
113 ),
114 cast_to=BetaTunnelCertificate,
115 )
116
117 def retrieve(
118 self,
119 certificate_id: str,
120 *,
121 tunnel_id: str,
122 betas: List[AnthropicBetaParam] | Omit = omit,
123 workspace_id: str | Omit = omit,
124 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
125 # The extra values given here take precedence over values defined on the client or passed to this method.
126 extra_headers: Headers | None = None,
127 extra_query: Query | None = None,
128 extra_body: Body | None = None,
129 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
130 ) -> BetaTunnelCertificate:
131 """The Tunnels API is in research preview.
132
133 It requires the
134 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
135 deprecation period. It supersedes the Admin API endpoints at
136 `/v1/organizations/tunnels`, which remain available during a migration window.
137
138 Fetches a tunnel certificate by ID.
139
140 Args:
141 tunnel_id: ID of the tunnel (`tnl_...`).
142
143 certificate_id: ID of the certificate (`tcrt_...`).
144
145 betas: Optional header to specify the beta version(s) you want to use.
146
147 workspace_id: Optional header to select the Workspace for this request. The value is a
148 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
149
150 Only needed for credentials that can act on more than one Workspace. A
151 credential that belongs to a specific Workspace may omit it; if sent, it must
152 match that Workspace.
153
154 extra_headers: Send extra headers
155
156 extra_query: Add additional query parameters to the request
157
158 extra_body: Add additional JSON properties to the request
159
160 timeout: Override the client-level default timeout for this request, in seconds
161 """
162 if not tunnel_id:
163 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
164 if not certificate_id:
165 raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
166 extra_headers = {
167 **strip_not_given(
168 {
169 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
170 if is_given(betas)
171 else not_given,
172 "anthropic-workspace-id": workspace_id,
173 }
174 ),
175 **(extra_headers or {}),
176 }
177 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
178 return self._get(
179 path_template(
180 "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}?beta=true",
181 tunnel_id=tunnel_id,
182 certificate_id=certificate_id,
183 ),
184 options=make_request_options(
185 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
186 ),
187 cast_to=BetaTunnelCertificate,
188 )
189
190 def list(
191 self,
192 tunnel_id: str,
193 *,
194 include_archived: bool | Omit = omit,
195 limit: int | Omit = omit,
196 page: str | Omit = omit,
197 betas: List[AnthropicBetaParam] | Omit = omit,
198 workspace_id: str | Omit = omit,
199 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
200 # The extra values given here take precedence over values defined on the client or passed to this method.
201 extra_headers: Headers | None = None,
202 extra_query: Query | None = None,
203 extra_body: Body | None = None,
204 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
205 ) -> SyncPageCursor[BetaTunnelCertificate]:
206 """The Tunnels API is in research preview.
207
208 It requires the
209 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
210 deprecation period. It supersedes the Admin API endpoints at
211 `/v1/organizations/tunnels`, which remain available during a migration window.
212
213 Lists the certificates registered on a tunnel. Archived certificates are
214 excluded unless include_archived is set.
215
216 Args:
217 tunnel_id: ID of the tunnel (`tnl_...`).
218
219 include_archived: Whether to include archived certificates in the results. Defaults to false.
220
221 limit: Maximum number of certificates to return per page. Defaults to 20, maximum 1000.
222
223 page: Opaque pagination cursor from a previous `list_tunnel_certificates` response.
224
225 betas: Optional header to specify the beta version(s) you want to use.
226
227 workspace_id: Optional header to select the Workspace for this request. The value is a
228 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
229
230 Only needed for credentials that can act on more than one Workspace. A
231 credential that belongs to a specific Workspace may omit it; if sent, it must
232 match that Workspace.
233
234 extra_headers: Send extra headers
235
236 extra_query: Add additional query parameters to the request
237
238 extra_body: Add additional JSON properties to the request
239
240 timeout: Override the client-level default timeout for this request, in seconds
241 """
242 if not tunnel_id:
243 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
244 extra_headers = {
245 **strip_not_given(
246 {
247 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
248 if is_given(betas)
249 else not_given,
250 "anthropic-workspace-id": workspace_id,
251 }
252 ),
253 **(extra_headers or {}),
254 }
255 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
256 return self._get_api_list(
257 path_template("/v1/tunnels/{tunnel_id}/certificates?beta=true", tunnel_id=tunnel_id),
258 page=SyncPageCursor[BetaTunnelCertificate],
259 options=make_request_options(
260 extra_headers=extra_headers,
261 extra_query=extra_query,
262 extra_body=extra_body,
263 timeout=timeout,
264 query={
265 "include_archived": include_archived,
266 "limit": limit,
267 "page": page,
268 },
269 ),
270 model=BetaTunnelCertificate,
271 )
272
273 def archive(
274 self,
275 certificate_id: str,
276 *,
277 tunnel_id: str,
278 betas: List[AnthropicBetaParam] | Omit = omit,
279 workspace_id: str | Omit = omit,
280 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
281 # The extra values given here take precedence over values defined on the client or passed to this method.
282 extra_headers: Headers | None = None,
283 extra_query: Query | None = None,
284 extra_body: Body | None = None,
285 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
286 ) -> BetaTunnelCertificate:
287 """The Tunnels API is in research preview.
288
289 It requires the
290 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
291 deprecation period. It supersedes the Admin API endpoints at
292 `/v1/organizations/tunnels`, which remain available during a migration window.
293
294 Archives a tunnel certificate, removing it from the set Anthropic trusts for the
295 tunnel. The certificate record is retained. Archiving the last non-archived
296 certificate is permitted; the tunnel rejects MCP traffic until a new certificate
297 is added.
298
299 Args:
300 tunnel_id: ID of the tunnel (`tnl_...`).
301
302 certificate_id: ID of the certificate to archive (`tcrt_...`).
303
304 betas: Optional header to specify the beta version(s) you want to use.
305
306 workspace_id: Optional header to select the Workspace for this request. The value is a
307 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
308
309 Only needed for credentials that can act on more than one Workspace. A
310 credential that belongs to a specific Workspace may omit it; if sent, it must
311 match that Workspace.
312
313 extra_headers: Send extra headers
314
315 extra_query: Add additional query parameters to the request
316
317 extra_body: Add additional JSON properties to the request
318
319 timeout: Override the client-level default timeout for this request, in seconds
320 """
321 if not tunnel_id:
322 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
323 if not certificate_id:
324 raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
325 extra_headers = {
326 **strip_not_given(
327 {
328 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
329 if is_given(betas)
330 else not_given,
331 "anthropic-workspace-id": workspace_id,
332 }
333 ),
334 **(extra_headers or {}),
335 }
336 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
337 return self._post(
338 path_template(
339 "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive?beta=true",
340 tunnel_id=tunnel_id,
341 certificate_id=certificate_id,
342 ),
343 options=make_request_options(
344 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
345 ),
346 cast_to=BetaTunnelCertificate,
347 )
348
349
350 class AsyncCertificates(AsyncAPIResource):
351 @cached_property
352 def with_raw_response(self) -> AsyncCertificatesWithRawResponse:
353 """
354 This property can be used as a prefix for any HTTP method call to return
355 the raw response object instead of the parsed content.
356
357 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#accessing-raw-response-data-eg-headers
358 """
359 return AsyncCertificatesWithRawResponse(self)
360
361 @cached_property
362 def with_streaming_response(self) -> AsyncCertificatesWithStreamingResponse:
363 """
364 An alternative to `.with_raw_response` that doesn't eagerly read the response body.
365
366 For more information, see https://www.github.com/anthropics/anthropic-sdk-python#with_streaming_response
367 """
368 return AsyncCertificatesWithStreamingResponse(self)
369
370 async def create(
371 self,
372 tunnel_id: str,
373 *,
374 ca_certificate_pem: str,
375 betas: List[AnthropicBetaParam] | Omit = omit,
376 workspace_id: str | Omit = omit,
377 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
378 # The extra values given here take precedence over values defined on the client or passed to this method.
379 extra_headers: Headers | None = None,
380 extra_query: Query | None = None,
381 extra_body: Body | None = None,
382 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
383 ) -> BetaTunnelCertificate:
384 """The Tunnels API is in research preview.
385
386 It requires the
387 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
388 deprecation period. It supersedes the Admin API endpoints at
389 `/v1/organizations/tunnels`, which remain available during a migration window.
390
391 Registers a public CA certificate on a tunnel. Anthropic verifies the gateway's
392 server certificate against this CA when it terminates the inner TLS session. A
393 tunnel holds at most two non-archived certificates.
394
395 Args:
396 tunnel_id: ID of the tunnel (`tnl_...`).
397
398 ca_certificate_pem: PEM-encoded X.509 CA certificate. Must contain exactly one certificate and no
399 private-key material. Maximum 8KB.
400
401 betas: Optional header to specify the beta version(s) you want to use.
402
403 workspace_id: Optional header to select the Workspace for this request. The value is a
404 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
405
406 Only needed for credentials that can act on more than one Workspace. A
407 credential that belongs to a specific Workspace may omit it; if sent, it must
408 match that Workspace.
409
410 extra_headers: Send extra headers
411
412 extra_query: Add additional query parameters to the request
413
414 extra_body: Add additional JSON properties to the request
415
416 timeout: Override the client-level default timeout for this request, in seconds
417 """
418 if not tunnel_id:
419 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
420 extra_headers = {
421 **strip_not_given(
422 {
423 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
424 if is_given(betas)
425 else not_given,
426 "anthropic-workspace-id": workspace_id,
427 }
428 ),
429 **(extra_headers or {}),
430 }
431 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
432 return await self._post(
433 path_template("/v1/tunnels/{tunnel_id}/certificates?beta=true", tunnel_id=tunnel_id),
434 body={"ca_certificate_pem": ca_certificate_pem},
435 options=make_request_options(
436 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
437 ),
438 cast_to=BetaTunnelCertificate,
439 )
440
441 async def retrieve(
442 self,
443 certificate_id: str,
444 *,
445 tunnel_id: str,
446 betas: List[AnthropicBetaParam] | Omit = omit,
447 workspace_id: str | Omit = omit,
448 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
449 # The extra values given here take precedence over values defined on the client or passed to this method.
450 extra_headers: Headers | None = None,
451 extra_query: Query | None = None,
452 extra_body: Body | None = None,
453 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
454 ) -> BetaTunnelCertificate:
455 """The Tunnels API is in research preview.
456
457 It requires the
458 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
459 deprecation period. It supersedes the Admin API endpoints at
460 `/v1/organizations/tunnels`, which remain available during a migration window.
461
462 Fetches a tunnel certificate by ID.
463
464 Args:
465 tunnel_id: ID of the tunnel (`tnl_...`).
466
467 certificate_id: ID of the certificate (`tcrt_...`).
468
469 betas: Optional header to specify the beta version(s) you want to use.
470
471 workspace_id: Optional header to select the Workspace for this request. The value is a
472 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
473
474 Only needed for credentials that can act on more than one Workspace. A
475 credential that belongs to a specific Workspace may omit it; if sent, it must
476 match that Workspace.
477
478 extra_headers: Send extra headers
479
480 extra_query: Add additional query parameters to the request
481
482 extra_body: Add additional JSON properties to the request
483
484 timeout: Override the client-level default timeout for this request, in seconds
485 """
486 if not tunnel_id:
487 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
488 if not certificate_id:
489 raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
490 extra_headers = {
491 **strip_not_given(
492 {
493 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
494 if is_given(betas)
495 else not_given,
496 "anthropic-workspace-id": workspace_id,
497 }
498 ),
499 **(extra_headers or {}),
500 }
501 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
502 return await self._get(
503 path_template(
504 "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}?beta=true",
505 tunnel_id=tunnel_id,
506 certificate_id=certificate_id,
507 ),
508 options=make_request_options(
509 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
510 ),
511 cast_to=BetaTunnelCertificate,
512 )
513
514 def list(
515 self,
516 tunnel_id: str,
517 *,
518 include_archived: bool | Omit = omit,
519 limit: int | Omit = omit,
520 page: str | Omit = omit,
521 betas: List[AnthropicBetaParam] | Omit = omit,
522 workspace_id: str | Omit = omit,
523 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
524 # The extra values given here take precedence over values defined on the client or passed to this method.
525 extra_headers: Headers | None = None,
526 extra_query: Query | None = None,
527 extra_body: Body | None = None,
528 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
529 ) -> AsyncPaginator[BetaTunnelCertificate, AsyncPageCursor[BetaTunnelCertificate]]:
530 """The Tunnels API is in research preview.
531
532 It requires the
533 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
534 deprecation period. It supersedes the Admin API endpoints at
535 `/v1/organizations/tunnels`, which remain available during a migration window.
536
537 Lists the certificates registered on a tunnel. Archived certificates are
538 excluded unless include_archived is set.
539
540 Args:
541 tunnel_id: ID of the tunnel (`tnl_...`).
542
543 include_archived: Whether to include archived certificates in the results. Defaults to false.
544
545 limit: Maximum number of certificates to return per page. Defaults to 20, maximum 1000.
546
547 page: Opaque pagination cursor from a previous `list_tunnel_certificates` response.
548
549 betas: Optional header to specify the beta version(s) you want to use.
550
551 workspace_id: Optional header to select the Workspace for this request. The value is a
552 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
553
554 Only needed for credentials that can act on more than one Workspace. A
555 credential that belongs to a specific Workspace may omit it; if sent, it must
556 match that Workspace.
557
558 extra_headers: Send extra headers
559
560 extra_query: Add additional query parameters to the request
561
562 extra_body: Add additional JSON properties to the request
563
564 timeout: Override the client-level default timeout for this request, in seconds
565 """
566 if not tunnel_id:
567 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
568 extra_headers = {
569 **strip_not_given(
570 {
571 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
572 if is_given(betas)
573 else not_given,
574 "anthropic-workspace-id": workspace_id,
575 }
576 ),
577 **(extra_headers or {}),
578 }
579 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
580 return self._get_api_list(
581 path_template("/v1/tunnels/{tunnel_id}/certificates?beta=true", tunnel_id=tunnel_id),
582 page=AsyncPageCursor[BetaTunnelCertificate],
583 options=make_request_options(
584 extra_headers=extra_headers,
585 extra_query=extra_query,
586 extra_body=extra_body,
587 timeout=timeout,
588 query={
589 "include_archived": include_archived,
590 "limit": limit,
591 "page": page,
592 },
593 ),
594 model=BetaTunnelCertificate,
595 )
596
597 async def archive(
598 self,
599 certificate_id: str,
600 *,
601 tunnel_id: str,
602 betas: List[AnthropicBetaParam] | Omit = omit,
603 workspace_id: str | Omit = omit,
604 # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
605 # The extra values given here take precedence over values defined on the client or passed to this method.
606 extra_headers: Headers | None = None,
607 extra_query: Query | None = None,
608 extra_body: Body | None = None,
609 timeout: float | httpx2.Timeout | None | NotGiven = not_given,
610 ) -> BetaTunnelCertificate:
611 """The Tunnels API is in research preview.
612
613 It requires the
614 `anthropic-beta: mcp-tunnels-2026-06-22` header and may change without a
615 deprecation period. It supersedes the Admin API endpoints at
616 `/v1/organizations/tunnels`, which remain available during a migration window.
617
618 Archives a tunnel certificate, removing it from the set Anthropic trusts for the
619 tunnel. The certificate record is retained. Archiving the last non-archived
620 certificate is permitted; the tunnel rejects MCP traffic until a new certificate
621 is added.
622
623 Args:
624 tunnel_id: ID of the tunnel (`tnl_...`).
625
626 certificate_id: ID of the certificate to archive (`tcrt_...`).
627
628 betas: Optional header to specify the beta version(s) you want to use.
629
630 workspace_id: Optional header to select the Workspace for this request. The value is a
631 Workspace ID (for example, `wrkspc_011CZkZaBF1tNoB5wlCeusgy`).
632
633 Only needed for credentials that can act on more than one Workspace. A
634 credential that belongs to a specific Workspace may omit it; if sent, it must
635 match that Workspace.
636
637 extra_headers: Send extra headers
638
639 extra_query: Add additional query parameters to the request
640
641 extra_body: Add additional JSON properties to the request
642
643 timeout: Override the client-level default timeout for this request, in seconds
644 """
645 if not tunnel_id:
646 raise ValueError(f"Expected a non-empty value for `tunnel_id` but received {tunnel_id!r}")
647 if not certificate_id:
648 raise ValueError(f"Expected a non-empty value for `certificate_id` but received {certificate_id!r}")
649 extra_headers = {
650 **strip_not_given(
651 {
652 "anthropic-beta": ",".join(chain((str(e) for e in betas), ["mcp-tunnels-2026-06-22"]))
653 if is_given(betas)
654 else not_given,
655 "anthropic-workspace-id": workspace_id,
656 }
657 ),
658 **(extra_headers or {}),
659 }
660 extra_headers = {"anthropic-beta": "mcp-tunnels-2026-06-22", **(extra_headers or {})}
661 return await self._post(
662 path_template(
663 "/v1/tunnels/{tunnel_id}/certificates/{certificate_id}/archive?beta=true",
664 tunnel_id=tunnel_id,
665 certificate_id=certificate_id,
666 ),
667 options=make_request_options(
668 extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
669 ),
670 cast_to=BetaTunnelCertificate,
671 )
672
673
674 class CertificatesWithRawResponse:
675 def __init__(self, certificates: Certificates) -> None:
676 self._certificates = certificates
677
678 self.create = to_raw_response_wrapper(
679 certificates.create,
680 )
681 self.retrieve = to_raw_response_wrapper(
682 certificates.retrieve,
683 )
684 self.list = to_raw_response_wrapper(
685 certificates.list,
686 )
687 self.archive = to_raw_response_wrapper(
688 certificates.archive,
689 )
690
691
692 class AsyncCertificatesWithRawResponse:
693 def __init__(self, certificates: AsyncCertificates) -> None:
694 self._certificates = certificates
695
696 self.create = async_to_raw_response_wrapper(
697 certificates.create,
698 )
699 self.retrieve = async_to_raw_response_wrapper(
700 certificates.retrieve,
701 )
702 self.list = async_to_raw_response_wrapper(
703 certificates.list,
704 )
705 self.archive = async_to_raw_response_wrapper(
706 certificates.archive,
707 )
708
709
710 class CertificatesWithStreamingResponse:
711 def __init__(self, certificates: Certificates) -> None:
712 self._certificates = certificates
713
714 self.create = to_streamed_response_wrapper(
715 certificates.create,
716 )
717 self.retrieve = to_streamed_response_wrapper(
718 certificates.retrieve,
719 )
720 self.list = to_streamed_response_wrapper(
721 certificates.list,
722 )
723 self.archive = to_streamed_response_wrapper(
724 certificates.archive,
725 )
726
727
728 class AsyncCertificatesWithStreamingResponse:
729 def __init__(self, certificates: AsyncCertificates) -> None:
730 self._certificates = certificates
731
732 self.create = async_to_streamed_response_wrapper(
733 certificates.create,
734 )
735 self.retrieve = async_to_streamed_response_wrapper(
736 certificates.retrieve,
737 )
738 self.list = async_to_streamed_response_wrapper(
739 certificates.list,
740 )
741 self.archive = async_to_streamed_response_wrapper(
742 certificates.archive,
743 )