Skip to content

Commit

Permalink
Revert "Update response for database, table, result and schedule list…
Browse files Browse the repository at this point in the history
… APIs (#117)" (#123)

This reverts commit e8d1b95.
  • Loading branch information
tung-vu-td authored Nov 12, 2024
1 parent abd3e04 commit 647c403
Show file tree
Hide file tree
Showing 15 changed files with 21 additions and 122 deletions.
4 changes: 2 additions & 2 deletions tdclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,8 +854,8 @@ def results(self):
results = self.api.list_result()

def result(m):
name, url, organizations, id, user_id = m
return models.Result(self, name, url, organizations, id, user_id)
name, url, organizations = m
return models.Result(self, name, url, organizations)

return [result(m) for m in results]

Expand Down
24 changes: 0 additions & 24 deletions tdclient/database_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ def __init__(self, client, db_name, **kwargs):
self._updated_at = kwargs.get("updated_at")
self._org_name = kwargs.get("org_name")
self._permission = kwargs.get("permission")
self._id = kwargs.get("id")
self._user_id = kwargs.get("user_id")
self._description = kwargs.get("description")

@property
def org_name(self):
Expand Down Expand Up @@ -50,27 +47,6 @@ def name(self):
"""
return self._db_name

@property
def id(self):
"""
int: id of the database
"""
return self._id

@property
def user_id(self):
"""
int: owner's id of the database
"""
return self._user_id

@property
def description(self):
"""
str: description of the database
"""
return self._description

def tables(self):
"""
Returns:
Expand Down
7 changes: 3 additions & 4 deletions tdclient/result_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ def list_result(self):
"""Get the list of all the available authentications.
Returns:
[(str, str, None, int, int)]: The list of tuple of name, Result output url,
organization name (always `None` for api compatibility), result id and user id
[(str, str, None)]: The list of tuple of name, Result output url, and
organization name (always `None` for api compatibility).
"""
with self.get("/v3/result/list") as res:
code, body = res.status, res.read()
if code != 200:
self.raise_error("List result table failed", res, body)
js = self.checked_json(body, ["results"])
return [
(m["name"], m["url"], None, m["id"], m["user_id"])
for m in js["results"]
(m["name"], m["url"], None) for m in js["results"]
] # same as database

def create_result(self, name, url, params=None):
Expand Down
13 changes: 1 addition & 12 deletions tdclient/result_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
class Result(Model):
"""Result on Treasure Data Service"""

def __init__(self, client, name, url, org_name, id, user_id):
def __init__(self, client, name, url, org_name):
super(Result, self).__init__(client)
self._name = name
self._url = url
self._org_name = org_name
self._id = id
self._user_id = user_id

@property
def name(self):
Expand All @@ -29,12 +27,3 @@ def org_name(self):
"""str: organization name"""
return self._org_name

@property
def id(self):
"""int: result id"""
return self._id

@property
def user_id(self):
"""int: result's owner id"""
return self._user_id
18 changes: 0 additions & 18 deletions tdclient/schedule_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ def __init__(self, client, *args, **kwargs):
self._result = kwargs.get("result")
self._next_time = kwargs.get("next_time")
self._org_name = kwargs.get("org_name")
self._id = kwargs.get("id")
self._executing_user_id = kwargs.get("executing_user_id")
self._description = kwargs.get("description")

@property
def name(self):
Expand Down Expand Up @@ -133,21 +130,6 @@ def user_name(self):
"""User name of a scheduled job"""
return self._user_name

@property
def id(self):
"""int: id of the query"""
return self._id

@property
def executing_user_id(self):
"""int: executor's id of the query"""
return self._executing_user_id

@property
def description(self):
"""str: description of the query"""
return self._description

def run(self, time, num=None):
"""Run a scheduled job
Expand Down
2 changes: 0 additions & 2 deletions tdclient/table_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ def list_tables(self, db):
['species', 'string', 'species']],
'expire_days': None,
'last_import': datetime.datetime(2019, 9, 18, 7, 14, 28, tzinfo=tzutc())},
'user_id': 1,
'description': 'table description'
}
"""
with self.get(create_url("/v3/table/list/{db}", db=db)) as res:
Expand Down
12 changes: 0 additions & 12 deletions tdclient/table_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ def __init__(self, *args, **kwargs):
self._schema = kwargs.get("schema")
self._count = kwargs.get("count")

self._user_id = kwargs.get("user_id")
self._description = kwargs.get("description")
self._created_at = kwargs.get("created_at")
self._updated_at = kwargs.get("updated_at")
self._estimated_storage_size = kwargs.get("estimated_storage_size")
Expand Down Expand Up @@ -132,16 +130,6 @@ def identifier(self):
"""a string identifier of the table"""
return "%s.%s" % (self._db_name, self._table_name)

@property
def user_id(self):
"""int: owner's id of the table"""
return self._user_id

@property
def description(self):
"""str: description of the table"""
return self._description

def delete(self):
"""a string represents the type of deleted table"""
return self._client.delete_table(self._db_name, self._table_name)
Expand Down
6 changes: 3 additions & 3 deletions tdclient/test/database_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ def test_list_databases_success():
body = b"""
{
"databases":[
{"name":"sample_datasets","count":8812278,"created_at":"2014-10-04 01:13:11 UTC","updated_at":"2014-10-08 18:42:12 UTC","organization":null,"permission":"administrator","id":123,"user_id":1,"description":"database description 1"},
{"name":"jma_weather","count":29545,"created_at":"2014-10-12 06:33:01 UTC","updated_at":"2014-10-12 06:33:01 UTC","organization":null,"permission":"administrator","id":124,"user_id":1,"description":"database description 2"},
{"name":"test_db","count":15,"created_at":"2014-10-16 09:48:44 UTC","updated_at":"2014-10-16 09:48:44 UTC","organization":null,"permission":"administrator","id":125,"user_id":1,"description":"database description 3"}
{"name":"sample_datasets","count":8812278,"created_at":"2014-10-04 01:13:11 UTC","updated_at":"2014-10-08 18:42:12 UTC","organization":null,"permission":"administrator"},
{"name":"jma_weather","count":29545,"created_at":"2014-10-12 06:33:01 UTC","updated_at":"2014-10-12 06:33:01 UTC","organization":null,"permission":"administrator"},
{"name":"test_db","count":15,"created_at":"2014-10-16 09:48:44 UTC","updated_at":"2014-10-16 09:48:44 UTC","organization":null,"permission":"administrator"}
]
}
"""
Expand Down
6 changes: 0 additions & 6 deletions tdclient/test/database_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ def test_database():
updated_at="updated_at",
org_name="org_name",
permission="administrator",
id=123,
user_id=1,
description="database description",
)
assert database.org_name == "org_name"
assert database.permission == "administrator"
Expand All @@ -35,9 +32,6 @@ def test_database():
assert database.tables() == ["nasdaq", "www_access"]
assert database.created_at == "created_at"
assert database.updated_at == "updated_at"
assert database.id == 123
assert database.user_id == 1
assert database.description == "database description"


def test_database_update_tables():
Expand Down
18 changes: 6 additions & 12 deletions tdclient/test/result_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,17 @@ def test_list_result_success():
{
"name": "foo",
"organization": null,
"url": "mysql://example.com/db/foo",
"id": 123,
"user_id": 1
"url": "mysql://example.com/db/foo"
},
{
"name": "bar",
"organization": null,
"url": "postgresql://example.com/db/bar",
"id": 124,
"user_id": 1
"url": "postgresql://example.com/db/bar"
},
{
"name": "baz",
"organization": null,
"url": "s3://s3.example.com/baz.csv",
"id": 125,
"user_id": 1
"url": "s3://s3.example.com/baz.csv"
}
]
}
Expand All @@ -45,9 +39,9 @@ def test_list_result_success():
results = td.list_result()
td.get.assert_called_with("/v3/result/list")
assert len(results) == 3
assert results[0] == ("foo", "mysql://example.com/db/foo", None, 123, 1)
assert results[1] == ("bar", "postgresql://example.com/db/bar", None, 124, 1)
assert results[2] == ("baz", "s3://s3.example.com/baz.csv", None, 125, 1)
assert results[0] == ("foo", "mysql://example.com/db/foo", None)
assert results[1] == ("bar", "postgresql://example.com/db/bar", None)
assert results[2] == ("baz", "s3://s3.example.com/baz.csv", None)


def test_list_result_failure():
Expand Down
4 changes: 1 addition & 3 deletions tdclient/test/result_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ def setup_function(function):

def test_result():
client = mock.MagicMock()
result = models.Result(client, "name", "url", "org_name", 123, 1)
result = models.Result(client, "name", "url", "org_name")
assert result.name == "name"
assert result.url == "url"
assert result.org_name == "org_name"
assert result.id == 123
assert result.user_id == 1
15 changes: 3 additions & 12 deletions tdclient/test/schedule_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,7 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": null,
"id": 123,
"executing_user_id": 1,
"description": "query description 1"
"next_time": null
},
{
"name": "bar",
Expand All @@ -106,10 +103,7 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": "2016-09-24T00:00:00Z",
"id": 124,
"executing_user_id": 1,
"description": "query description 2"
"next_time": "2016-09-24T00:00:00Z"
},
{
"name": "baz",
Expand All @@ -124,10 +118,7 @@ def test_list_schedules_success():
"priority": 0,
"retry_limit": 0,
"result": "",
"next_time": "2016-07-06T00:00:00Z",
"id": 125,
"executing_user_id": 1,
"description": "query description 3"
"next_time": "2016-07-06T00:00:00Z"
}
]
}
Expand Down
6 changes: 0 additions & 6 deletions tdclient/test/schedule_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ def test_schedule():
retry_limit="retry_limit",
org_name="org_name",
user_name="user_name",
id=123,
executing_user_id=1,
description="query description 1",
)
assert schedule.name == "name"
assert schedule.cron == "cron"
Expand All @@ -54,9 +51,6 @@ def test_schedule():
assert schedule.retry_limit == "retry_limit"
assert schedule.org_name == "org_name"
assert schedule.user_name == "user_name"
assert schedule.id == 123
assert schedule.executing_user_id == 1
assert schedule.description == "query description 1"


def test_schedule_run():
Expand Down
4 changes: 2 additions & 2 deletions tdclient/test/table_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def test_list_tables_success():
body = b"""
{
"tables":[
{"id":210906,"name":"nasdaq","estimated_storage_size":168205061,"counter_updated_at":null,"last_log_timestamp":null,"type":"log","count":8807278,"expire_days":null,"created_at":"2014-10-08 02:57:38 UTC","updated_at":"2014-10-08 03:16:59 UTC","schema":"[[\\"symbol\\",\\"string\\"],[\\"open\\",\\"double\\"],[\\"volume\\",\\"long\\"],[\\"high\\",\\"double\\"],[\\"low\\",\\"double\\"],[\\"close\\",\\"double\\"]]","user_id":1,"description":"table description"},
{"id":208715,"name":"www_access","estimated_storage_size":0,"counter_updated_at":"2014-10-04T01:13:20Z","last_log_timestamp":"2014-10-04T01:13:15Z","type":"log","count":5000,"expire_days":null,"created_at":"2014-10-04 01:13:12 UTC","updated_at":"2014-10-22 07:02:19 UTC","schema":"[[\\"user\\",\\"int\\"],[\\"host\\",\\"string\\"],[\\"path\\",\\"string\\"],[\\"referer\\",\\"string\\"],[\\"code\\",\\"long\\"],[\\"agent\\",\\"string\\"],[\\"size\\",\\"long\\"],[\\"method\\",\\"string\\"]]","user_id":1,"description":"table description"}
{"id":210906,"name":"nasdaq","estimated_storage_size":168205061,"counter_updated_at":null,"last_log_timestamp":null,"type":"log","count":8807278,"expire_days":null,"created_at":"2014-10-08 02:57:38 UTC","updated_at":"2014-10-08 03:16:59 UTC","schema":"[[\\"symbol\\",\\"string\\"],[\\"open\\",\\"double\\"],[\\"volume\\",\\"long\\"],[\\"high\\",\\"double\\"],[\\"low\\",\\"double\\"],[\\"close\\",\\"double\\"]]"},
{"id":208715,"name":"www_access","estimated_storage_size":0,"counter_updated_at":"2014-10-04T01:13:20Z","last_log_timestamp":"2014-10-04T01:13:15Z","type":"log","count":5000,"expire_days":null,"created_at":"2014-10-04 01:13:12 UTC","updated_at":"2014-10-22 07:02:19 UTC","schema":"[[\\"user\\",\\"int\\"],[\\"host\\",\\"string\\"],[\\"path\\",\\"string\\"],[\\"referer\\",\\"string\\"],[\\"code\\",\\"long\\"],[\\"agent\\",\\"string\\"],[\\"size\\",\\"long\\"],[\\"method\\",\\"string\\"]]"}
],
"database":"sample_datasets"
}
Expand Down
4 changes: 0 additions & 4 deletions tdclient/test/table_model_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def test_table():
expire_days="expire_days",
primary_key="primary_key",
primary_key_type="primary_key_type",
user_id=1,
description="table description",
)
assert table.type == "type"
assert table.db_name == "db_name"
Expand All @@ -46,8 +44,6 @@ def test_table():
assert table.last_log_timestamp == "last_log_timestamp"
assert table.expire_days == "expire_days"
assert table.identifier == "db_name.table_name"
assert table.user_id == 1
assert table.description == "table description"


def test_table_permission():
Expand Down

0 comments on commit 647c403

Please sign in to comment.