Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion foxglove/client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,17 @@ def update_session(
session_id: Optional[str] = None,
session_key: Optional[str] = None,
project_id: str,
new_key: Optional[str] = None,
add_recording_ids: Optional[List[str]] = None,
remove_recording_ids: Optional[List[str]] = None,
properties: Optional[Dict[str, Union[str, bool, float, int]]] = None,
):
"""Updates a session.

session_id: The ID of the session to update.
session_key: The key of the session to update.
session_key: The current key of the session to update.
project_id: The Project ID to which the session belongs.
new_key: Optional new user-supplied identifier, unique within the project.
add_recording_ids: IDs of recordings to add to the session.
remove_recording_ids: IDs of recordings to remove from the session.
properties: Optional custom properties to add to or edit on the session.
Expand All @@ -1319,6 +1321,7 @@ def update_session(
identifier = _session_identifier_for_path(session_id, session_key)

params = {
"key": new_key,
"addRecordingIds": add_recording_ids,
"removeRecordingIds": remove_recording_ids,
"properties": properties,
Expand Down
53 changes: 53 additions & 0 deletions tests/test_sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,59 @@ def test_update_session():
assert result["properties"] == props


@responses.activate
def test_update_session_key():
session_id = fake.uuid4()
project_id = fake.uuid4()
new_key = "renamed-session"
s = _make_session_json(
session_id=session_id,
project_id=project_id,
key=new_key,
)
responses.add(
responses.PATCH,
api_url(f"/v1/sessions/{session_id}"),
match=[
query_string_matcher(f"projectId={project_id}"),
json_params_matcher({"key": new_key}),
],
json=s,
)
client = Client("test")
result = client.update_session(
session_id=session_id,
project_id=project_id,
new_key=new_key,
)
assert result["id"] == session_id
assert result["key"] == new_key


@responses.activate
def test_update_session_key_by_existing_key():
session_key = "old-session"
new_key = "new-session"
project_id = fake.uuid4()
s = _make_session_json(key=new_key, project_id=project_id)
responses.add(
responses.PATCH,
api_url(f"/v1/sessions/{session_key}"),
match=[
query_string_matcher(f"projectId={project_id}"),
json_params_matcher({"key": new_key}),
],
json=s,
)
client = Client("test")
result = client.update_session(
session_key=session_key,
project_id=project_id,
new_key=new_key,
)
assert result["key"] == new_key


@responses.activate
def test_delete_session():
session_id = fake.uuid4()
Expand Down
Loading