diff --git a/tests/test_client.py b/tests/test_client.py index 6445463..5469fec 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -233,11 +233,12 @@ def test_post_object(httpserver): def test_delete(httpserver): httpserver.expect_request( - "/api/v3/foo", method="DELETE", headers={"X-Apikey": "dummy_api_key"} + "/api/v3/foo", method="DELETE", headers={"X-Apikey": "dummy_api_key"}, + json={"hello": "world"}, ).respond_with_json({"data": "dummy_data"}) with new_client(httpserver) as client: - response = client.delete("/foo") + response = client.delete("/foo", json_data={"hello": "world"}) assert response.status == 200 diff --git a/vt/client.py b/vt/client.py index f5ed657..a7c342b 100644 --- a/vt/client.py +++ b/vt/client.py @@ -336,26 +336,43 @@ def close(self) -> None: """ return make_sync(self.close_async()) - def delete(self, path: str, *path_args: typing.Any) -> ClientResponse: + def delete( + self, + path: str, + *path_args: typing.Any, + data: typing.Optional[typing.Union[str, bytes]] = None, + json_data: typing.Optional[typing.Dict] = None + ) -> ClientResponse: """Sends a DELETE request to a given API endpoint. :param path: Path to API endpoint, can contain format placeholders {}. :param path_args: A variable number of arguments that are put into any placeholders used in path. + :param data: Data sent in the request body. + :param json_data: dict containing data to send in the request body as JSON. :type path: str + :type data: A string or bytes + :type json_data: dict :returns: An instance of :class:`ClientResponse`. """ - return make_sync(self.delete_async(path, *path_args)) + return make_sync( + self.delete_async(path, *path_args, data=data, json_data=json_data) + ) async def delete_async( self, path: str, - *path_args: typing.Any + *path_args: typing.Any, + data: typing.Optional[typing.Union[str, bytes]] = None, + json_data: typing.Optional[typing.Dict] = None ) -> ClientResponse: """Like :func:`delete` but returns a coroutine.""" return ClientResponse( await self._get_session().delete( - self._full_url(path, *path_args), proxy=self._proxy + self._full_url(path, *path_args), + data=data, + json=json_data, + proxy=self._proxy ) ) diff --git a/vt/iterator.py b/vt/iterator.py index 58ff6ca..7c2b576 100644 --- a/vt/iterator.py +++ b/vt/iterator.py @@ -77,7 +77,7 @@ def __init__( """Initializes an iterator. This function is not intended to be called directly. Client.iterator() is - the preferred way for creating an iteraror. + the preferred way for creating an iterator. """ self._client = client self._path = path