From 9153ccc58a65d87d25209fcbb04f78e9ee656cd8 Mon Sep 17 00:00:00 2001 From: Son Do Date: Mon, 4 Aug 2025 09:50:47 +0700 Subject: [PATCH] Remove partial_delete api --- docs/api/api.rst | 7 ---- tdclient/api.py | 2 - tdclient/client.py | 30 --------------- tdclient/partial_delete_api.py | 49 ------------------------ tdclient/test/client_test.py | 9 ----- tdclient/test/partial_delete_api_test.py | 35 ----------------- 6 files changed, 132 deletions(-) delete mode 100644 tdclient/partial_delete_api.py delete mode 100644 tdclient/test/partial_delete_api_test.py diff --git a/docs/api/api.rst b/docs/api/api.rst index 93eddf4..16efd5f 100644 --- a/docs/api/api.rst +++ b/docs/api/api.rst @@ -59,13 +59,6 @@ tdclient.job\_api :undoc-members: :show-inheritance: -tdclient.partial\_delete\_api ------------------------------------- - -.. automodule:: tdclient.partial_delete_api - :members: - :undoc-members: - :show-inheritance: tdclient.result\_api --------------------------- diff --git a/tdclient/api.py b/tdclient/api.py index 043637e..296d9ce 100644 --- a/tdclient/api.py +++ b/tdclient/api.py @@ -28,7 +28,6 @@ from tdclient.export_api import ExportAPI from tdclient.import_api import ImportAPI from tdclient.job_api import JobAPI -from tdclient.partial_delete_api import PartialDeleteAPI from tdclient.result_api import ResultAPI from tdclient.schedule_api import ScheduleAPI from tdclient.server_status_api import ServerStatusAPI @@ -63,7 +62,6 @@ class API( ExportAPI, ImportAPI, JobAPI, - PartialDeleteAPI, ResultAPI, ScheduleAPI, ServerStatusAPI, diff --git a/tdclient/client.py b/tdclient/client.py index 30b93cc..b4b779f 100644 --- a/tdclient/client.py +++ b/tdclient/client.py @@ -421,36 +421,6 @@ def export_data(self, db_name, table_name, storage_type, params=None): job_id = self.api.export_data(db_name, table_name, storage_type, params) return models.Job(self, job_id, "export", None) - def partial_delete(self, db_name, table_name, to, _from, params=None): - """Create a job to partially delete the contents of the table with the given - time range. - - Args: - db_name (str): Target database name. - table_name (str): Target table name. - to (int): Time in Unix Epoch format indicating the End date and time of the - data to be deleted. Should be set only by the hour. Minutes and seconds - values will not be accepted. - _from (int): Time in Unix Epoch format indicating the Start date and time of - the data to be deleted. Should be set only by the hour. Minutes and - seconds values will not be accepted. - params (dict, optional): Extra parameters. - - - pool_name (str, optional): - Indicates the resource pool to execute this - job. If not provided, the account's default resource pool would be - used. - - domain_key (str, optional): - Domain key that will be assigned to the - partial delete job to be created - - Returns: - :class:`tdclient.models.Job` - """ - params = {} if params is None else params - job_id = self.api.partial_delete(db_name, table_name, to, _from, params) - return models.Job(self, job_id, "partialdelete", None) - def create_bulk_import(self, name, database, table, params=None): """Create new bulk import session diff --git a/tdclient/partial_delete_api.py b/tdclient/partial_delete_api.py deleted file mode 100644 index 04e5310..0000000 --- a/tdclient/partial_delete_api.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python - -from .util import create_url - - -class PartialDeleteAPI: - """Create a job to partially delete the contents of the table with the given - time range. - - This class is inherited by :class:`tdclient.api.API`. - """ - - def partial_delete(self, db, table, to, _from, params=None): - """Create a job to partially delete the contents of the table with the given - time range. - - Args: - db (str): Target database name. - table (str): Target table name. - to (int): Time in Unix Epoch format indicating the End date and time of the - data to be deleted. Should be set only by the hour. Minutes and seconds - values will not be accepted. - _from (int): Time in Unix Epoch format indicating the Start date and time of - the data to be deleted. Should be set only by the hour. Minutes and - seconds values will not be accepted. - params (dict, optional): Extra parameters. - - - pool_name (str, optional): - Indicates the resource pool to execute this - job. If not provided, the account's default resource pool would be - used. - - domain_key (str, optional): - Domain key that will be assigned to the - partial delete job to be created - Returns: - str: Job ID. - """ - params = {} if params is None else params - params["to"] = str(to) - params["from"] = str(_from) - with self.post( - create_url("/v3/table/partialdelete/{db}/{table}", db=db, table=table), - params, - ) as res: - code, body = res.status, res.read() - if code != 200: - self.raise_error("Partial delete failed", res, body) - js = self.checked_json(body, ["job_id"]) - return str(js["job_id"]) diff --git a/tdclient/test/client_test.py b/tdclient/test/client_test.py index 34d949c..4197527 100644 --- a/tdclient/test/client_test.py +++ b/tdclient/test/client_test.py @@ -313,15 +313,6 @@ def test_kill(): td.api.kill.assert_called_with("12345") -def test_partial_delete(): - td = client.Client("APIKEY") - td._api = mock.MagicMock() - td._api.partial_delete = mock.MagicMock(return_value=("12345")) - job = td.partial_delete("db_name", "table_name", 0, 2) - td.api.partial_delete.assert_called_with("db_name", "table_name", 0, 2, {}) - assert job.job_id == "12345" - - def test_create_bulk_import(): td = client.Client("APIKEY") td._api = mock.MagicMock() diff --git a/tdclient/test/partial_delete_api_test.py b/tdclient/test/partial_delete_api_test.py deleted file mode 100644 index 9ab1a43..0000000 --- a/tdclient/test/partial_delete_api_test.py +++ /dev/null @@ -1,35 +0,0 @@ -#!/usr/bin/env python - -from unittest import mock - -import pytest - -from tdclient import api -from tdclient.test.test_helper import * - - -def setup_function(function): - unset_environ() - - -def test_partial_delete_success(): - td = api.API("APIKEY") - # TODO: should be replaced by wire dump - body = b""" - { - "job_id":"12345" - } - """ - td.post = mock.MagicMock(return_value=make_response(200, body)) - partial_delete = td.partial_delete("sample_datasets", "nasdaq", 0, 10) - td.post.assert_called_with( - "/v3/table/partialdelete/sample_datasets/nasdaq", {"from": "10", "to": "0"} - ) - - -def test_partial_delete_failure(): - td = api.API("APIKEY") - td.post = mock.MagicMock(return_value=make_response(500, b"error")) - with pytest.raises(api.APIError) as error: - td.partial_delete("sample_datasets", "nasdaq", 0, 10) - assert error.value.args == ("500: Partial delete failed: error",)