Skip to content

Commit 9a615e4

Browse files
refactor(auth): simplify proxy configuration in OpenAPI schema
1 parent 8e144ab commit 9a615e4

File tree

5 files changed

+73
-13
lines changed

5 files changed

+73
-13
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 100
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-13e82ae9e725e2c3ca19da7248a7a9c8696a0dfe088654cf26aea07c76d6567a.yml
3-
openapi_spec_hash: 6d4151a6066a8474bc56923299aec18a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-eaf23b9711c16c82563be76641c9c89988288307278dcd630a36f4f186f85afa.yml
3+
openapi_spec_hash: 369570222f4f725e1de11285422837cc
44
config_hash: 82f0a04081a3ab7111d3a9c68cd3ff2b

src/kernel/resources/auth/connections.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ def create(
112112
113113
login_url: Optional login page URL to skip discovery
114114
115-
proxy: Optional proxy configuration
115+
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
116+
caller's org.
116117
117118
extra_headers: Send extra headers
118119
@@ -315,6 +316,7 @@ def login(
315316
self,
316317
id: str,
317318
*,
319+
proxy: connection_login_params.Proxy | Omit = omit,
318320
save_credential_as: str | Omit = omit,
319321
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
320322
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -330,6 +332,9 @@ def login(
330332
credentials are stored.
331333
332334
Args:
335+
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
336+
caller's org.
337+
333338
save_credential_as: If provided, saves credentials under this name upon successful login
334339
335340
extra_headers: Send extra headers
@@ -345,7 +350,11 @@ def login(
345350
return self._post(
346351
f"/auth/connections/{id}/login",
347352
body=maybe_transform(
348-
{"save_credential_as": save_credential_as}, connection_login_params.ConnectionLoginParams
353+
{
354+
"proxy": proxy,
355+
"save_credential_as": save_credential_as,
356+
},
357+
connection_login_params.ConnectionLoginParams,
349358
),
350359
options=make_request_options(
351360
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
@@ -485,7 +494,8 @@ async def create(
485494
486495
login_url: Optional login page URL to skip discovery
487496
488-
proxy: Optional proxy configuration
497+
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
498+
caller's org.
489499
490500
extra_headers: Send extra headers
491501
@@ -688,6 +698,7 @@ async def login(
688698
self,
689699
id: str,
690700
*,
701+
proxy: connection_login_params.Proxy | Omit = omit,
691702
save_credential_as: str | Omit = omit,
692703
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
693704
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -703,6 +714,9 @@ async def login(
703714
credentials are stored.
704715
705716
Args:
717+
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
718+
caller's org.
719+
706720
save_credential_as: If provided, saves credentials under this name upon successful login
707721
708722
extra_headers: Send extra headers
@@ -718,7 +732,11 @@ async def login(
718732
return await self._post(
719733
f"/auth/connections/{id}/login",
720734
body=await async_maybe_transform(
721-
{"save_credential_as": save_credential_as}, connection_login_params.ConnectionLoginParams
735+
{
736+
"proxy": proxy,
737+
"save_credential_as": save_credential_as,
738+
},
739+
connection_login_params.ConnectionLoginParams,
722740
),
723741
options=make_request_options(
724742
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout

src/kernel/types/auth/connection_create_params.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ class ConnectionCreateParams(TypedDict, total=False):
5757
"""Optional login page URL to skip discovery"""
5858

5959
proxy: Proxy
60-
"""Optional proxy configuration"""
60+
"""Proxy selection.
61+
62+
Provide either id or name. The proxy must belong to the caller's org.
63+
"""
6164

6265

6366
class Credential(TypedDict, total=False):
@@ -83,7 +86,13 @@ class Credential(TypedDict, total=False):
8386

8487

8588
class Proxy(TypedDict, total=False):
86-
"""Optional proxy configuration"""
89+
"""Proxy selection.
90+
91+
Provide either id or name. The proxy must belong to the caller's org.
92+
"""
93+
94+
id: str
95+
"""Proxy ID"""
8796

88-
proxy_id: str
89-
"""ID of the proxy to use"""
97+
name: str
98+
"""Proxy name"""

src/kernel/types/auth/connection_login_params.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@
44

55
from typing_extensions import TypedDict
66

7-
__all__ = ["ConnectionLoginParams"]
7+
__all__ = ["ConnectionLoginParams", "Proxy"]
88

99

1010
class ConnectionLoginParams(TypedDict, total=False):
11+
proxy: Proxy
12+
"""Proxy selection.
13+
14+
Provide either id or name. The proxy must belong to the caller's org.
15+
"""
16+
1117
save_credential_as: str
1218
"""If provided, saves credentials under this name upon successful login"""
19+
20+
21+
class Proxy(TypedDict, total=False):
22+
"""Proxy selection.
23+
24+
Provide either id or name. The proxy must belong to the caller's org.
25+
"""
26+
27+
id: str
28+
"""Proxy ID"""
29+
30+
name: str
31+
"""Proxy name"""

tests/api_resources/auth/test_connections.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
4646
},
4747
health_check_interval=3600,
4848
login_url="https://netflix.com/login",
49-
proxy={"proxy_id": "proxy_id"},
49+
proxy={
50+
"id": "id",
51+
"name": "name",
52+
},
5053
)
5154
assert_matches_type(ManagedAuth, connection, path=["response"])
5255

@@ -255,6 +258,10 @@ def test_method_login(self, client: Kernel) -> None:
255258
def test_method_login_with_all_params(self, client: Kernel) -> None:
256259
connection = client.auth.connections.login(
257260
id="id",
261+
proxy={
262+
"id": "id",
263+
"name": "name",
264+
},
258265
save_credential_as="my-netflix-login",
259266
)
260267
assert_matches_type(LoginResponse, connection, path=["response"])
@@ -395,7 +402,10 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
395402
},
396403
health_check_interval=3600,
397404
login_url="https://netflix.com/login",
398-
proxy={"proxy_id": "proxy_id"},
405+
proxy={
406+
"id": "id",
407+
"name": "name",
408+
},
399409
)
400410
assert_matches_type(ManagedAuth, connection, path=["response"])
401411

@@ -604,6 +614,10 @@ async def test_method_login(self, async_client: AsyncKernel) -> None:
604614
async def test_method_login_with_all_params(self, async_client: AsyncKernel) -> None:
605615
connection = await async_client.auth.connections.login(
606616
id="id",
617+
proxy={
618+
"id": "id",
619+
"name": "name",
620+
},
607621
save_credential_as="my-netflix-login",
608622
)
609623
assert_matches_type(LoginResponse, connection, path=["response"])

0 commit comments

Comments
 (0)