Skip to content

Commit 53fea1c

Browse files
feat: Add opt-in record_session flag to managed auth
1 parent fd4ffe4 commit 53fea1c

7 files changed

Lines changed: 69 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 112
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-38c6ce8b0ce54e6c62517b9635acaf65369c26cdb1b55eb66290c13a8ab2b33d.yml
3-
openapi_spec_hash: e6f6ed157b1e318d1a1db72fd1d27091
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-64dac369ae935b0318cd611e1735d45359a663eb55cf43fbb8b09e9dd814d7a2.yml
3+
openapi_spec_hash: cc0c6a4e716977df4b9eab5f4658d41b
44
config_hash: 08d55086449943a8fec212b870061a3f

src/kernel/resources/auth/connections.py

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def create(
6666
health_check_interval: int | Omit = omit,
6767
login_url: str | Omit = omit,
6868
proxy: connection_create_params.Proxy | Omit = omit,
69+
record_session: bool | Omit = omit,
6970
save_credentials: bool | Omit = omit,
7071
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
7172
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -122,6 +123,9 @@ def create(
122123
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
123124
caller's org.
124125
126+
record_session: Whether to record browser sessions for this connection by default. Useful for
127+
debugging. Can be overridden per-login. Defaults to false.
128+
125129
save_credentials: Whether to save credentials after every successful login. Defaults to true.
126130
One-time codes (TOTP, SMS, etc.) are not saved.
127131
@@ -144,6 +148,7 @@ def create(
144148
"health_check_interval": health_check_interval,
145149
"login_url": login_url,
146150
"proxy": proxy,
151+
"record_session": record_session,
147152
"save_credentials": save_credentials,
148153
},
149154
connection_create_params.ConnectionCreateParams,
@@ -198,6 +203,7 @@ def update(
198203
health_check_interval: int | Omit = omit,
199204
login_url: str | Omit = omit,
200205
proxy: connection_update_params.Proxy | Omit = omit,
206+
record_session: bool | Omit = omit,
201207
save_credentials: bool | Omit = omit,
202208
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
203209
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -228,6 +234,8 @@ def update(
228234
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
229235
caller's org.
230236
237+
record_session: Whether to record browser sessions for this connection by default
238+
231239
save_credentials: Whether to save credentials after every successful login
232240
233241
extra_headers: Send extra headers
@@ -249,6 +257,7 @@ def update(
249257
"health_check_interval": health_check_interval,
250258
"login_url": login_url,
251259
"proxy": proxy,
260+
"record_session": record_session,
252261
"save_credentials": save_credentials,
253262
},
254263
connection_update_params.ConnectionUpdateParams,
@@ -398,6 +407,7 @@ def login(
398407
id: str,
399408
*,
400409
proxy: connection_login_params.Proxy | Omit = omit,
410+
record_session: bool | Omit = omit,
401411
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
402412
# The extra values given here take precedence over values defined on the client or passed to this method.
403413
extra_headers: Headers | None = None,
@@ -415,6 +425,9 @@ def login(
415425
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
416426
caller's org.
417427
428+
record_session: Override the connection's default for recording this login's browser session.
429+
When omitted, the connection's record_session default is used.
430+
418431
extra_headers: Send extra headers
419432
420433
extra_query: Add additional query parameters to the request
@@ -427,7 +440,13 @@ def login(
427440
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
428441
return self._post(
429442
path_template("/auth/connections/{id}/login", id=id),
430-
body=maybe_transform({"proxy": proxy}, connection_login_params.ConnectionLoginParams),
443+
body=maybe_transform(
444+
{
445+
"proxy": proxy,
446+
"record_session": record_session,
447+
},
448+
connection_login_params.ConnectionLoginParams,
449+
),
431450
options=make_request_options(
432451
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
433452
),
@@ -529,6 +548,7 @@ async def create(
529548
health_check_interval: int | Omit = omit,
530549
login_url: str | Omit = omit,
531550
proxy: connection_create_params.Proxy | Omit = omit,
551+
record_session: bool | Omit = omit,
532552
save_credentials: bool | Omit = omit,
533553
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
534554
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -585,6 +605,9 @@ async def create(
585605
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
586606
caller's org.
587607
608+
record_session: Whether to record browser sessions for this connection by default. Useful for
609+
debugging. Can be overridden per-login. Defaults to false.
610+
588611
save_credentials: Whether to save credentials after every successful login. Defaults to true.
589612
One-time codes (TOTP, SMS, etc.) are not saved.
590613
@@ -607,6 +630,7 @@ async def create(
607630
"health_check_interval": health_check_interval,
608631
"login_url": login_url,
609632
"proxy": proxy,
633+
"record_session": record_session,
610634
"save_credentials": save_credentials,
611635
},
612636
connection_create_params.ConnectionCreateParams,
@@ -661,6 +685,7 @@ async def update(
661685
health_check_interval: int | Omit = omit,
662686
login_url: str | Omit = omit,
663687
proxy: connection_update_params.Proxy | Omit = omit,
688+
record_session: bool | Omit = omit,
664689
save_credentials: bool | Omit = omit,
665690
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
666691
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -691,6 +716,8 @@ async def update(
691716
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
692717
caller's org.
693718
719+
record_session: Whether to record browser sessions for this connection by default
720+
694721
save_credentials: Whether to save credentials after every successful login
695722
696723
extra_headers: Send extra headers
@@ -712,6 +739,7 @@ async def update(
712739
"health_check_interval": health_check_interval,
713740
"login_url": login_url,
714741
"proxy": proxy,
742+
"record_session": record_session,
715743
"save_credentials": save_credentials,
716744
},
717745
connection_update_params.ConnectionUpdateParams,
@@ -861,6 +889,7 @@ async def login(
861889
id: str,
862890
*,
863891
proxy: connection_login_params.Proxy | Omit = omit,
892+
record_session: bool | Omit = omit,
864893
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
865894
# The extra values given here take precedence over values defined on the client or passed to this method.
866895
extra_headers: Headers | None = None,
@@ -878,6 +907,9 @@ async def login(
878907
proxy: Proxy selection. Provide either id or name. The proxy must belong to the
879908
caller's org.
880909
910+
record_session: Override the connection's default for recording this login's browser session.
911+
When omitted, the connection's record_session default is used.
912+
881913
extra_headers: Send extra headers
882914
883915
extra_query: Add additional query parameters to the request
@@ -890,7 +922,13 @@ async def login(
890922
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
891923
return await self._post(
892924
path_template("/auth/connections/{id}/login", id=id),
893-
body=await async_maybe_transform({"proxy": proxy}, connection_login_params.ConnectionLoginParams),
925+
body=await async_maybe_transform(
926+
{
927+
"proxy": proxy,
928+
"record_session": record_session,
929+
},
930+
connection_login_params.ConnectionLoginParams,
931+
),
894932
options=make_request_options(
895933
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
896934
),

src/kernel/types/auth/connection_create_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ class ConnectionCreateParams(TypedDict, total=False):
6666
Provide either id or name. The proxy must belong to the caller's org.
6767
"""
6868

69+
record_session: bool
70+
"""Whether to record browser sessions for this connection by default.
71+
72+
Useful for debugging. Can be overridden per-login. Defaults to false.
73+
"""
74+
6975
save_credentials: bool
7076
"""Whether to save credentials after every successful login.
7177

src/kernel/types/auth/connection_login_params.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ class ConnectionLoginParams(TypedDict, total=False):
1414
Provide either id or name. The proxy must belong to the caller's org.
1515
"""
1616

17+
record_session: bool
18+
"""Override the connection's default for recording this login's browser session.
19+
20+
When omitted, the connection's record_session default is used.
21+
"""
22+
1723

1824
class Proxy(TypedDict, total=False):
1925
"""Proxy selection.

src/kernel/types/auth/connection_update_params.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ class ConnectionUpdateParams(TypedDict, total=False):
3333
Provide either id or name. The proxy must belong to the caller's org.
3434
"""
3535

36+
record_session: bool
37+
"""Whether to record browser sessions for this connection by default"""
38+
3639
save_credentials: bool
3740
"""Whether to save credentials after every successful login"""
3841

src/kernel/types/auth/managed_auth.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ class ManagedAuth(BaseModel):
130130
profile_name: str
131131
"""Name of the profile associated with this auth connection"""
132132

133+
record_session: bool
134+
"""
135+
Whether browser sessions for this connection are recorded by default for
136+
debugging. Can be overridden per-login.
137+
"""
138+
133139
save_credentials: bool
134140
"""Whether credentials are saved after every successful login.
135141

tests/api_resources/auth/test_connections.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
5050
"id": "id",
5151
"name": "name",
5252
},
53+
record_session=False,
5354
save_credentials=True,
5455
)
5556
assert_matches_type(ManagedAuth, connection, path=["response"])
@@ -150,6 +151,7 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
150151
"id": "id",
151152
"name": "name",
152153
},
154+
record_session=False,
153155
save_credentials=True,
154156
)
155157
assert_matches_type(ManagedAuth, connection, path=["response"])
@@ -327,6 +329,7 @@ def test_method_login_with_all_params(self, client: Kernel) -> None:
327329
"id": "id",
328330
"name": "name",
329331
},
332+
record_session=True,
330333
)
331334
assert_matches_type(LoginResponse, connection, path=["response"])
332335

@@ -456,6 +459,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
456459
"id": "id",
457460
"name": "name",
458461
},
462+
record_session=False,
459463
save_credentials=True,
460464
)
461465
assert_matches_type(ManagedAuth, connection, path=["response"])
@@ -556,6 +560,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
556560
"id": "id",
557561
"name": "name",
558562
},
563+
record_session=False,
559564
save_credentials=True,
560565
)
561566
assert_matches_type(ManagedAuth, connection, path=["response"])
@@ -733,6 +738,7 @@ async def test_method_login_with_all_params(self, async_client: AsyncKernel) ->
733738
"id": "id",
734739
"name": "name",
735740
},
741+
record_session=True,
736742
)
737743
assert_matches_type(LoginResponse, connection, path=["response"])
738744

0 commit comments

Comments
 (0)