Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete calls endpoint #45

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 25 additions & 0 deletions getstream/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2306,6 +2306,31 @@ class DeleteCallResponse(DataClassJsonMixin):
)


@dataclass
class DeleteCallResult(DataClassJsonMixin):
error: str = dc_field(metadata=dc_config(field_name="error"))
status: str = dc_field(metadata=dc_config(field_name="status"))


@dataclass
class DeleteCallsRequest(DataClassJsonMixin):
hard: Optional[bool] = dc_field(default=None, metadata=dc_config(field_name="hard"))
cids: Optional[List[str]] = dc_field(
default=None, metadata=dc_config(field_name="cids")
)


@dataclass
class DeleteCallsResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
task_id: Optional[str] = dc_field(
default=None, metadata=dc_config(field_name="task_id")
)
result: "Optional[Dict[str, Optional[DeleteCallResult]]]" = dc_field(
default=None, metadata=dc_config(field_name="result")
)


@dataclass
class DeleteChannelResponse(DataClassJsonMixin):
duration: str = dc_field(metadata=dc_config(field_name="duration"))
Expand Down
7 changes: 7 additions & 0 deletions getstream/video/rest_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,13 @@ def query_calls(

return self.post("/api/v2/video/calls", QueryCallsResponse, json=json)

def delete_calls(
self, hard: Optional[bool] = None, cids: Optional[List[str]] = None
) -> StreamResponse[DeleteCallsResponse]:
json = build_body_dict(hard=hard, cids=cids)

return self.post("/api/v2/video/calls/delete", DeleteCallsResponse, json=json)

def list_call_types(self) -> StreamResponse[ListCallTypeResponse]:
return self.get("/api/v2/video/calltypes", ListCallTypeResponse)

Expand Down
17 changes: 17 additions & 0 deletions tests/test_video_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,3 +386,20 @@ def test_hard_delete(self, client: Stream, call: Call):
response = wait_for_task(client, task_id)
cid = call.call_type + ":" + call.id
assert response.data.result[cid]["status"] == "ok"

def test_delete_calls(self, client: Stream):
call1 = client.video.call("default", str(uuid.uuid4())).get_or_create(
data=CallRequest(
created_by_id="john",
),
)

call2 = client.video.call("default", str(uuid.uuid4())).get_or_create(
data=CallRequest(
created_by_id="john",
),
)
cid1 = call1.data.call.cid
cid2 = call2.data.call.cid
response = client.video.delete_calls(hard=False, cids=[cid1, cid2])
# TODO: check response
Loading