|
8 | 8 | from ..._resource import AsyncAPIResource, SyncAPIResource |
9 | 9 | from ..._types import NOT_GIVEN, NotGiven |
10 | 10 | from ...types.session.agent_identifier import AgentIdentifier |
| 11 | +from ...types.session.agent_with_upgrades import AgentWithUpgrades |
11 | 12 | from ...types.session.checkpoint_restore_config import CheckpointRestoreConfig |
12 | 13 | from ...types.session.delete_session_response import DeleteSessionResponse |
| 14 | +from ...types.session.environment_with_upgrades import EnvironmentWithUpgrades |
13 | 15 | from ...types.session.list_sessions_order import ListSessionsOrder |
14 | 16 | from ...types.session.list_sessions_response import ListSessionsResponse |
| 17 | +from ...types.session.managed_agents_event_params import ManagedAgentsEventParams |
15 | 18 | from ...types.session.session import Session |
16 | 19 | from ...types.session.session_resource import SessionResource |
17 | 20 | from ...types.session.session_status import SessionStatus |
@@ -192,6 +195,48 @@ def update( |
192 | 195 | cast_to=Session, |
193 | 196 | ) |
194 | 197 |
|
| 198 | + def upgrade( |
| 199 | + self, |
| 200 | + session_id: str, |
| 201 | + *, |
| 202 | + agent: Optional[AgentWithUpgrades] | NotGiven = NOT_GIVEN, |
| 203 | + environment: Optional[EnvironmentWithUpgrades] | NotGiven = NOT_GIVEN, |
| 204 | + vault_ids: Optional[List[str]] | NotGiven = NOT_GIVEN, |
| 205 | + initial_events: Optional[List[ManagedAgentsEventParams]] | NotGiven = NOT_GIVEN, |
| 206 | + extra_headers=None, |
| 207 | + extra_query=None, |
| 208 | + extra_body=None, |
| 209 | + timeout=None, |
| 210 | + ) -> Session: |
| 211 | + """Upgrade an existing Session's runtime configuration. |
| 212 | +
|
| 213 | + At least one of ``agent``, ``environment``, or ``vault_ids`` must be |
| 214 | + provided. Agent and environment IDs must match the current Session. |
| 215 | + Agent array fields use whole-list replacement semantics: an explicit |
| 216 | + ``[]`` clears the list, while an omitted field keeps its current value. |
| 217 | + ``vault_ids`` may only refresh the currently bound set; it cannot |
| 218 | + change that set. An omitted or zero agent version keeps the current |
| 219 | + snapshot rather than selecting the latest version. Self-hosted |
| 220 | + environments reject runtime config overrides other than ``config.type``. |
| 221 | + """ |
| 222 | + if not session_id: |
| 223 | + raise ValueError("session_id is required") |
| 224 | + return self._post( |
| 225 | + f"{_PREFIX}/{session_id}/upgrades", |
| 226 | + body=dump_body( |
| 227 | + { |
| 228 | + "agent": agent, |
| 229 | + "environment": environment, |
| 230 | + "vault_ids": vault_ids, |
| 231 | + "initial_events": initial_events, |
| 232 | + } |
| 233 | + ), |
| 234 | + options=make_request_options( |
| 235 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 236 | + ), |
| 237 | + cast_to=Session, |
| 238 | + ) |
| 239 | + |
195 | 240 | def delete( |
196 | 241 | self, session_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None |
197 | 242 | ) -> DeleteSessionResponse: |
@@ -333,6 +378,48 @@ async def update( |
333 | 378 | cast_to=Session, |
334 | 379 | ) |
335 | 380 |
|
| 381 | + async def upgrade( |
| 382 | + self, |
| 383 | + session_id: str, |
| 384 | + *, |
| 385 | + agent: Optional[AgentWithUpgrades] | NotGiven = NOT_GIVEN, |
| 386 | + environment: Optional[EnvironmentWithUpgrades] | NotGiven = NOT_GIVEN, |
| 387 | + vault_ids: Optional[List[str]] | NotGiven = NOT_GIVEN, |
| 388 | + initial_events: Optional[List[ManagedAgentsEventParams]] | NotGiven = NOT_GIVEN, |
| 389 | + extra_headers=None, |
| 390 | + extra_query=None, |
| 391 | + extra_body=None, |
| 392 | + timeout=None, |
| 393 | + ) -> Session: |
| 394 | + """Upgrade an existing Session's runtime configuration. |
| 395 | +
|
| 396 | + At least one of ``agent``, ``environment``, or ``vault_ids`` must be |
| 397 | + provided. Agent and environment IDs must match the current Session. |
| 398 | + Agent array fields use whole-list replacement semantics: an explicit |
| 399 | + ``[]`` clears the list, while an omitted field keeps its current value. |
| 400 | + ``vault_ids`` may only refresh the currently bound set; it cannot |
| 401 | + change that set. An omitted or zero agent version keeps the current |
| 402 | + snapshot rather than selecting the latest version. Self-hosted |
| 403 | + environments reject runtime config overrides other than ``config.type``. |
| 404 | + """ |
| 405 | + if not session_id: |
| 406 | + raise ValueError("session_id is required") |
| 407 | + return await self._post( |
| 408 | + f"{_PREFIX}/{session_id}/upgrades", |
| 409 | + body=dump_body( |
| 410 | + { |
| 411 | + "agent": agent, |
| 412 | + "environment": environment, |
| 413 | + "vault_ids": vault_ids, |
| 414 | + "initial_events": initial_events, |
| 415 | + } |
| 416 | + ), |
| 417 | + options=make_request_options( |
| 418 | + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout |
| 419 | + ), |
| 420 | + cast_to=Session, |
| 421 | + ) |
| 422 | + |
336 | 423 | async def delete( |
337 | 424 | self, session_id: str, *, extra_headers=None, extra_query=None, extra_body=None, timeout=None |
338 | 425 | ) -> DeleteSessionResponse: |
|
0 commit comments