Debian Codegraph @

tests/api_resources/beta/vaults/test_credentials.py

raw
1 from __future__ import annotations
2
3 import os
4 from typing import Any, cast
5
6 import pytest
7
8 from anthropic import Anthropic, AsyncAnthropic
9 from tests.utils import assert_matches_type
10 from anthropic._utils import parse_datetime
11 from anthropic.pagination import SyncPageCursor, AsyncPageCursor
12 from anthropic.types.beta.vaults import (
13 BetaManagedAgentsCredential,
14 BetaManagedAgentsDeletedCredential,
15 BetaManagedAgentsCredentialValidation,
16 )
17
18 base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
19
20
21 class TestCredentials:
22 parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])
23
24 @parametrize
25 def test_method_create(self, client: Anthropic) -> None:
26 credential = client.beta.vaults.credentials.create(
27 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
28 auth={
29 "token": "bearer_exampletoken",
30 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
31 "type": "static_bearer",
32 },
33 )
34 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
35
36 @parametrize
37 def test_method_create_with_all_params(self, client: Anthropic) -> None:
38 credential = client.beta.vaults.credentials.create(
39 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
40 auth={
41 "token": "bearer_exampletoken",
42 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
43 "type": "static_bearer",
44 },
45 display_name="Example credential",
46 metadata={"environment": "production"},
47 betas=["message-batches-2024-09-24"],
48 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
49 )
50 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
51
52 @parametrize
53 def test_raw_response_create(self, client: Anthropic) -> None:
54 response = client.beta.vaults.credentials.with_raw_response.create(
55 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
56 auth={
57 "token": "bearer_exampletoken",
58 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
59 "type": "static_bearer",
60 },
61 )
62
63 assert response.is_closed is True
64 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
65 credential = response.parse()
66 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
67
68 @parametrize
69 def test_streaming_response_create(self, client: Anthropic) -> None:
70 with client.beta.vaults.credentials.with_streaming_response.create(
71 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
72 auth={
73 "token": "bearer_exampletoken",
74 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
75 "type": "static_bearer",
76 },
77 ) as response:
78 assert not response.is_closed
79 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
80
81 credential = response.parse()
82 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
83
84 assert cast(Any, response.is_closed) is True
85
86 @parametrize
87 def test_path_params_create(self, client: Anthropic) -> None:
88 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
89 client.beta.vaults.credentials.with_raw_response.create(
90 vault_id="",
91 auth={
92 "token": "bearer_exampletoken",
93 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
94 "type": "static_bearer",
95 },
96 )
97
98 @parametrize
99 def test_method_retrieve(self, client: Anthropic) -> None:
100 credential = client.beta.vaults.credentials.retrieve(
101 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
102 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
103 )
104 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
105
106 @parametrize
107 def test_method_retrieve_with_all_params(self, client: Anthropic) -> None:
108 credential = client.beta.vaults.credentials.retrieve(
109 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
110 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
111 betas=["message-batches-2024-09-24"],
112 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
113 )
114 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
115
116 @parametrize
117 def test_raw_response_retrieve(self, client: Anthropic) -> None:
118 response = client.beta.vaults.credentials.with_raw_response.retrieve(
119 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
120 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
121 )
122
123 assert response.is_closed is True
124 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
125 credential = response.parse()
126 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
127
128 @parametrize
129 def test_streaming_response_retrieve(self, client: Anthropic) -> None:
130 with client.beta.vaults.credentials.with_streaming_response.retrieve(
131 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
132 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
133 ) as response:
134 assert not response.is_closed
135 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
136
137 credential = response.parse()
138 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
139
140 assert cast(Any, response.is_closed) is True
141
142 @parametrize
143 def test_path_params_retrieve(self, client: Anthropic) -> None:
144 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
145 client.beta.vaults.credentials.with_raw_response.retrieve(
146 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
147 vault_id="",
148 )
149
150 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
151 client.beta.vaults.credentials.with_raw_response.retrieve(
152 credential_id="",
153 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
154 )
155
156 @parametrize
157 def test_method_update(self, client: Anthropic) -> None:
158 credential = client.beta.vaults.credentials.update(
159 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
160 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
161 )
162 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
163
164 @parametrize
165 def test_method_update_with_all_params(self, client: Anthropic) -> None:
166 credential = client.beta.vaults.credentials.update(
167 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
168 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
169 auth={
170 "type": "mcp_oauth",
171 "access_token": "x",
172 "expires_at": parse_datetime("2019-12-27T18:11:19.117Z"),
173 "refresh": {
174 "refresh_token": "x",
175 "scope": "scope",
176 "token_endpoint_auth": {
177 "type": "client_secret_basic",
178 "client_secret": "x",
179 },
180 },
181 },
182 display_name="Example credential",
183 metadata={"environment": "production"},
184 betas=["message-batches-2024-09-24"],
185 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
186 )
187 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
188
189 @parametrize
190 def test_raw_response_update(self, client: Anthropic) -> None:
191 response = client.beta.vaults.credentials.with_raw_response.update(
192 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
193 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
194 )
195
196 assert response.is_closed is True
197 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
198 credential = response.parse()
199 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
200
201 @parametrize
202 def test_streaming_response_update(self, client: Anthropic) -> None:
203 with client.beta.vaults.credentials.with_streaming_response.update(
204 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
205 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
206 ) as response:
207 assert not response.is_closed
208 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
209
210 credential = response.parse()
211 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
212
213 assert cast(Any, response.is_closed) is True
214
215 @parametrize
216 def test_path_params_update(self, client: Anthropic) -> None:
217 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
218 client.beta.vaults.credentials.with_raw_response.update(
219 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
220 vault_id="",
221 )
222
223 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
224 client.beta.vaults.credentials.with_raw_response.update(
225 credential_id="",
226 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
227 )
228
229 @pytest.mark.skip(reason="buildURL drops path-level query params")
230 @parametrize
231 def test_method_list(self, client: Anthropic) -> None:
232 credential = client.beta.vaults.credentials.list(
233 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
234 )
235 assert_matches_type(SyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
236
237 @pytest.mark.skip(reason="buildURL drops path-level query params")
238 @parametrize
239 def test_method_list_with_all_params(self, client: Anthropic) -> None:
240 credential = client.beta.vaults.credentials.list(
241 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
242 include_archived=True,
243 limit=0,
244 page="page",
245 betas=["message-batches-2024-09-24"],
246 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
247 )
248 assert_matches_type(SyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
249
250 @pytest.mark.skip(reason="buildURL drops path-level query params")
251 @parametrize
252 def test_raw_response_list(self, client: Anthropic) -> None:
253 response = client.beta.vaults.credentials.with_raw_response.list(
254 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
255 )
256
257 assert response.is_closed is True
258 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
259 credential = response.parse()
260 assert_matches_type(SyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
261
262 @pytest.mark.skip(reason="buildURL drops path-level query params")
263 @parametrize
264 def test_streaming_response_list(self, client: Anthropic) -> None:
265 with client.beta.vaults.credentials.with_streaming_response.list(
266 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
267 ) as response:
268 assert not response.is_closed
269 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
270
271 credential = response.parse()
272 assert_matches_type(SyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
273
274 assert cast(Any, response.is_closed) is True
275
276 @pytest.mark.skip(reason="buildURL drops path-level query params")
277 @parametrize
278 def test_path_params_list(self, client: Anthropic) -> None:
279 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
280 client.beta.vaults.credentials.with_raw_response.list(
281 vault_id="",
282 )
283
284 @parametrize
285 def test_method_delete(self, client: Anthropic) -> None:
286 credential = client.beta.vaults.credentials.delete(
287 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
288 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
289 )
290 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
291
292 @parametrize
293 def test_method_delete_with_all_params(self, client: Anthropic) -> None:
294 credential = client.beta.vaults.credentials.delete(
295 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
296 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
297 betas=["message-batches-2024-09-24"],
298 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
299 )
300 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
301
302 @parametrize
303 def test_raw_response_delete(self, client: Anthropic) -> None:
304 response = client.beta.vaults.credentials.with_raw_response.delete(
305 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
306 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
307 )
308
309 assert response.is_closed is True
310 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
311 credential = response.parse()
312 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
313
314 @parametrize
315 def test_streaming_response_delete(self, client: Anthropic) -> None:
316 with client.beta.vaults.credentials.with_streaming_response.delete(
317 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
318 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
319 ) as response:
320 assert not response.is_closed
321 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
322
323 credential = response.parse()
324 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
325
326 assert cast(Any, response.is_closed) is True
327
328 @parametrize
329 def test_path_params_delete(self, client: Anthropic) -> None:
330 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
331 client.beta.vaults.credentials.with_raw_response.delete(
332 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
333 vault_id="",
334 )
335
336 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
337 client.beta.vaults.credentials.with_raw_response.delete(
338 credential_id="",
339 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
340 )
341
342 @parametrize
343 def test_method_archive(self, client: Anthropic) -> None:
344 credential = client.beta.vaults.credentials.archive(
345 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
346 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
347 )
348 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
349
350 @parametrize
351 def test_method_archive_with_all_params(self, client: Anthropic) -> None:
352 credential = client.beta.vaults.credentials.archive(
353 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
354 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
355 betas=["message-batches-2024-09-24"],
356 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
357 )
358 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
359
360 @parametrize
361 def test_raw_response_archive(self, client: Anthropic) -> None:
362 response = client.beta.vaults.credentials.with_raw_response.archive(
363 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
364 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
365 )
366
367 assert response.is_closed is True
368 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
369 credential = response.parse()
370 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
371
372 @parametrize
373 def test_streaming_response_archive(self, client: Anthropic) -> None:
374 with client.beta.vaults.credentials.with_streaming_response.archive(
375 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
376 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
377 ) as response:
378 assert not response.is_closed
379 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
380
381 credential = response.parse()
382 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
383
384 assert cast(Any, response.is_closed) is True
385
386 @parametrize
387 def test_path_params_archive(self, client: Anthropic) -> None:
388 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
389 client.beta.vaults.credentials.with_raw_response.archive(
390 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
391 vault_id="",
392 )
393
394 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
395 client.beta.vaults.credentials.with_raw_response.archive(
396 credential_id="",
397 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
398 )
399
400 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
401 @parametrize
402 def test_method_mcp_oauth_validate(self, client: Anthropic) -> None:
403 credential = client.beta.vaults.credentials.mcp_oauth_validate(
404 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
405 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
406 )
407 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
408
409 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
410 @parametrize
411 def test_method_mcp_oauth_validate_with_all_params(self, client: Anthropic) -> None:
412 credential = client.beta.vaults.credentials.mcp_oauth_validate(
413 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
414 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
415 betas=["message-batches-2024-09-24"],
416 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
417 )
418 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
419
420 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
421 @parametrize
422 def test_raw_response_mcp_oauth_validate(self, client: Anthropic) -> None:
423 response = client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
424 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
425 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
426 )
427
428 assert response.is_closed is True
429 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
430 credential = response.parse()
431 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
432
433 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
434 @parametrize
435 def test_streaming_response_mcp_oauth_validate(self, client: Anthropic) -> None:
436 with client.beta.vaults.credentials.with_streaming_response.mcp_oauth_validate(
437 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
438 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
439 ) as response:
440 assert not response.is_closed
441 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
442
443 credential = response.parse()
444 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
445
446 assert cast(Any, response.is_closed) is True
447
448 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
449 @parametrize
450 def test_path_params_mcp_oauth_validate(self, client: Anthropic) -> None:
451 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
452 client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
453 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
454 vault_id="",
455 )
456
457 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
458 client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
459 credential_id="",
460 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
461 )
462
463
464 class TestAsyncCredentials:
465 parametrize = pytest.mark.parametrize(
466 "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"]
467 )
468
469 @parametrize
470 async def test_method_create(self, async_client: AsyncAnthropic) -> None:
471 credential = await async_client.beta.vaults.credentials.create(
472 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
473 auth={
474 "token": "bearer_exampletoken",
475 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
476 "type": "static_bearer",
477 },
478 )
479 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
480
481 @parametrize
482 async def test_method_create_with_all_params(self, async_client: AsyncAnthropic) -> None:
483 credential = await async_client.beta.vaults.credentials.create(
484 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
485 auth={
486 "token": "bearer_exampletoken",
487 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
488 "type": "static_bearer",
489 },
490 display_name="Example credential",
491 metadata={"environment": "production"},
492 betas=["message-batches-2024-09-24"],
493 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
494 )
495 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
496
497 @parametrize
498 async def test_raw_response_create(self, async_client: AsyncAnthropic) -> None:
499 response = await async_client.beta.vaults.credentials.with_raw_response.create(
500 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
501 auth={
502 "token": "bearer_exampletoken",
503 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
504 "type": "static_bearer",
505 },
506 )
507
508 assert response.is_closed is True
509 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
510 credential = await response.parse()
511 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
512
513 @parametrize
514 async def test_streaming_response_create(self, async_client: AsyncAnthropic) -> None:
515 async with async_client.beta.vaults.credentials.with_streaming_response.create(
516 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
517 auth={
518 "token": "bearer_exampletoken",
519 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
520 "type": "static_bearer",
521 },
522 ) as response:
523 assert not response.is_closed
524 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
525
526 credential = await response.parse()
527 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
528
529 assert cast(Any, response.is_closed) is True
530
531 @parametrize
532 async def test_path_params_create(self, async_client: AsyncAnthropic) -> None:
533 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
534 await async_client.beta.vaults.credentials.with_raw_response.create(
535 vault_id="",
536 auth={
537 "token": "bearer_exampletoken",
538 "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
539 "type": "static_bearer",
540 },
541 )
542
543 @parametrize
544 async def test_method_retrieve(self, async_client: AsyncAnthropic) -> None:
545 credential = await async_client.beta.vaults.credentials.retrieve(
546 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
547 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
548 )
549 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
550
551 @parametrize
552 async def test_method_retrieve_with_all_params(self, async_client: AsyncAnthropic) -> None:
553 credential = await async_client.beta.vaults.credentials.retrieve(
554 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
555 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
556 betas=["message-batches-2024-09-24"],
557 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
558 )
559 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
560
561 @parametrize
562 async def test_raw_response_retrieve(self, async_client: AsyncAnthropic) -> None:
563 response = await async_client.beta.vaults.credentials.with_raw_response.retrieve(
564 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
565 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
566 )
567
568 assert response.is_closed is True
569 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
570 credential = await response.parse()
571 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
572
573 @parametrize
574 async def test_streaming_response_retrieve(self, async_client: AsyncAnthropic) -> None:
575 async with async_client.beta.vaults.credentials.with_streaming_response.retrieve(
576 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
577 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
578 ) as response:
579 assert not response.is_closed
580 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
581
582 credential = await response.parse()
583 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
584
585 assert cast(Any, response.is_closed) is True
586
587 @parametrize
588 async def test_path_params_retrieve(self, async_client: AsyncAnthropic) -> None:
589 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
590 await async_client.beta.vaults.credentials.with_raw_response.retrieve(
591 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
592 vault_id="",
593 )
594
595 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
596 await async_client.beta.vaults.credentials.with_raw_response.retrieve(
597 credential_id="",
598 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
599 )
600
601 @parametrize
602 async def test_method_update(self, async_client: AsyncAnthropic) -> None:
603 credential = await async_client.beta.vaults.credentials.update(
604 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
605 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
606 )
607 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
608
609 @parametrize
610 async def test_method_update_with_all_params(self, async_client: AsyncAnthropic) -> None:
611 credential = await async_client.beta.vaults.credentials.update(
612 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
613 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
614 auth={
615 "type": "mcp_oauth",
616 "access_token": "x",
617 "expires_at": parse_datetime("2019-12-27T18:11:19.117Z"),
618 "refresh": {
619 "refresh_token": "x",
620 "scope": "scope",
621 "token_endpoint_auth": {
622 "type": "client_secret_basic",
623 "client_secret": "x",
624 },
625 },
626 },
627 display_name="Example credential",
628 metadata={"environment": "production"},
629 betas=["message-batches-2024-09-24"],
630 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
631 )
632 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
633
634 @parametrize
635 async def test_raw_response_update(self, async_client: AsyncAnthropic) -> None:
636 response = await async_client.beta.vaults.credentials.with_raw_response.update(
637 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
638 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
639 )
640
641 assert response.is_closed is True
642 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
643 credential = await response.parse()
644 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
645
646 @parametrize
647 async def test_streaming_response_update(self, async_client: AsyncAnthropic) -> None:
648 async with async_client.beta.vaults.credentials.with_streaming_response.update(
649 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
650 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
651 ) as response:
652 assert not response.is_closed
653 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
654
655 credential = await response.parse()
656 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
657
658 assert cast(Any, response.is_closed) is True
659
660 @parametrize
661 async def test_path_params_update(self, async_client: AsyncAnthropic) -> None:
662 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
663 await async_client.beta.vaults.credentials.with_raw_response.update(
664 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
665 vault_id="",
666 )
667
668 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
669 await async_client.beta.vaults.credentials.with_raw_response.update(
670 credential_id="",
671 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
672 )
673
674 @pytest.mark.skip(reason="buildURL drops path-level query params")
675 @parametrize
676 async def test_method_list(self, async_client: AsyncAnthropic) -> None:
677 credential = await async_client.beta.vaults.credentials.list(
678 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
679 )
680 assert_matches_type(AsyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
681
682 @pytest.mark.skip(reason="buildURL drops path-level query params")
683 @parametrize
684 async def test_method_list_with_all_params(self, async_client: AsyncAnthropic) -> None:
685 credential = await async_client.beta.vaults.credentials.list(
686 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
687 include_archived=True,
688 limit=0,
689 page="page",
690 betas=["message-batches-2024-09-24"],
691 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
692 )
693 assert_matches_type(AsyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
694
695 @pytest.mark.skip(reason="buildURL drops path-level query params")
696 @parametrize
697 async def test_raw_response_list(self, async_client: AsyncAnthropic) -> None:
698 response = await async_client.beta.vaults.credentials.with_raw_response.list(
699 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
700 )
701
702 assert response.is_closed is True
703 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
704 credential = await response.parse()
705 assert_matches_type(AsyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
706
707 @pytest.mark.skip(reason="buildURL drops path-level query params")
708 @parametrize
709 async def test_streaming_response_list(self, async_client: AsyncAnthropic) -> None:
710 async with async_client.beta.vaults.credentials.with_streaming_response.list(
711 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
712 ) as response:
713 assert not response.is_closed
714 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
715
716 credential = await response.parse()
717 assert_matches_type(AsyncPageCursor[BetaManagedAgentsCredential], credential, path=["response"])
718
719 assert cast(Any, response.is_closed) is True
720
721 @pytest.mark.skip(reason="buildURL drops path-level query params")
722 @parametrize
723 async def test_path_params_list(self, async_client: AsyncAnthropic) -> None:
724 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
725 await async_client.beta.vaults.credentials.with_raw_response.list(
726 vault_id="",
727 )
728
729 @parametrize
730 async def test_method_delete(self, async_client: AsyncAnthropic) -> None:
731 credential = await async_client.beta.vaults.credentials.delete(
732 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
733 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
734 )
735 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
736
737 @parametrize
738 async def test_method_delete_with_all_params(self, async_client: AsyncAnthropic) -> None:
739 credential = await async_client.beta.vaults.credentials.delete(
740 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
741 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
742 betas=["message-batches-2024-09-24"],
743 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
744 )
745 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
746
747 @parametrize
748 async def test_raw_response_delete(self, async_client: AsyncAnthropic) -> None:
749 response = await async_client.beta.vaults.credentials.with_raw_response.delete(
750 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
751 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
752 )
753
754 assert response.is_closed is True
755 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
756 credential = await response.parse()
757 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
758
759 @parametrize
760 async def test_streaming_response_delete(self, async_client: AsyncAnthropic) -> None:
761 async with async_client.beta.vaults.credentials.with_streaming_response.delete(
762 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
763 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
764 ) as response:
765 assert not response.is_closed
766 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
767
768 credential = await response.parse()
769 assert_matches_type(BetaManagedAgentsDeletedCredential, credential, path=["response"])
770
771 assert cast(Any, response.is_closed) is True
772
773 @parametrize
774 async def test_path_params_delete(self, async_client: AsyncAnthropic) -> None:
775 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
776 await async_client.beta.vaults.credentials.with_raw_response.delete(
777 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
778 vault_id="",
779 )
780
781 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
782 await async_client.beta.vaults.credentials.with_raw_response.delete(
783 credential_id="",
784 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
785 )
786
787 @parametrize
788 async def test_method_archive(self, async_client: AsyncAnthropic) -> None:
789 credential = await async_client.beta.vaults.credentials.archive(
790 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
791 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
792 )
793 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
794
795 @parametrize
796 async def test_method_archive_with_all_params(self, async_client: AsyncAnthropic) -> None:
797 credential = await async_client.beta.vaults.credentials.archive(
798 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
799 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
800 betas=["message-batches-2024-09-24"],
801 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
802 )
803 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
804
805 @parametrize
806 async def test_raw_response_archive(self, async_client: AsyncAnthropic) -> None:
807 response = await async_client.beta.vaults.credentials.with_raw_response.archive(
808 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
809 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
810 )
811
812 assert response.is_closed is True
813 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
814 credential = await response.parse()
815 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
816
817 @parametrize
818 async def test_streaming_response_archive(self, async_client: AsyncAnthropic) -> None:
819 async with async_client.beta.vaults.credentials.with_streaming_response.archive(
820 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
821 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
822 ) as response:
823 assert not response.is_closed
824 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
825
826 credential = await response.parse()
827 assert_matches_type(BetaManagedAgentsCredential, credential, path=["response"])
828
829 assert cast(Any, response.is_closed) is True
830
831 @parametrize
832 async def test_path_params_archive(self, async_client: AsyncAnthropic) -> None:
833 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
834 await async_client.beta.vaults.credentials.with_raw_response.archive(
835 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
836 vault_id="",
837 )
838
839 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
840 await async_client.beta.vaults.credentials.with_raw_response.archive(
841 credential_id="",
842 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
843 )
844
845 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
846 @parametrize
847 async def test_method_mcp_oauth_validate(self, async_client: AsyncAnthropic) -> None:
848 credential = await async_client.beta.vaults.credentials.mcp_oauth_validate(
849 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
850 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
851 )
852 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
853
854 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
855 @parametrize
856 async def test_method_mcp_oauth_validate_with_all_params(self, async_client: AsyncAnthropic) -> None:
857 credential = await async_client.beta.vaults.credentials.mcp_oauth_validate(
858 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
859 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
860 betas=["message-batches-2024-09-24"],
861 workspace_id="wrkspc_011CZkZaBF1tNoB5wlCeusgy",
862 )
863 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
864
865 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
866 @parametrize
867 async def test_raw_response_mcp_oauth_validate(self, async_client: AsyncAnthropic) -> None:
868 response = await async_client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
869 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
870 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
871 )
872
873 assert response.is_closed is True
874 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
875 credential = await response.parse()
876 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
877
878 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
879 @parametrize
880 async def test_streaming_response_mcp_oauth_validate(self, async_client: AsyncAnthropic) -> None:
881 async with async_client.beta.vaults.credentials.with_streaming_response.mcp_oauth_validate(
882 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
883 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
884 ) as response:
885 assert not response.is_closed
886 assert response.http_request.headers.get("X-Stainless-Lang") == "python"
887
888 credential = await response.parse()
889 assert_matches_type(BetaManagedAgentsCredentialValidation, credential, path=["response"])
890
891 assert cast(Any, response.is_closed) is True
892
893 @pytest.mark.skip(reason="prism can't find endpoint with beta only tag")
894 @parametrize
895 async def test_path_params_mcp_oauth_validate(self, async_client: AsyncAnthropic) -> None:
896 with pytest.raises(ValueError, match=r"Expected a non-empty value for `vault_id` but received ''"):
897 await async_client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
898 credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
899 vault_id="",
900 )
901
902 with pytest.raises(ValueError, match=r"Expected a non-empty value for `credential_id` but received ''"):
903 await async_client.beta.vaults.credentials.with_raw_response.mcp_oauth_validate(
904 credential_id="",
905 vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
906 )