-
Notifications
You must be signed in to change notification settings - Fork 0
/
metadata.py
83 lines (58 loc) · 2.43 KB
/
metadata.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
class Metadata(object):
def __init__(self, client):
self.client = client
# schemas
def get_schemas(self, nested=False):
if nested:
return self.client.get('/metadata/api/schemas/management/')
else:
return self.client.get('/metadata/api/schemas/')
def get_schema(self, pk):
return self.client.get('/metadata/api/schemas/%i/' % pk)
def create_schema(self, data):
return self.client.post('/metadata/api/schemas/', data)
def update_schema(self, pk, data):
obj = self.get_schema(pk)
obj.update(data)
return self.client.put('/metadata/api/schemas/%i/' % pk, obj)
def delete_schema(self, pk):
return self.client.delete('/metadata/api/schemas/%i/' % pk)
# tables
def get_tables(self):
return self.client.get('/metadata/api/tables/')
def get_table(self, pk):
return self.client.get('/metadata/api/tables/%i/' % pk)
def create_table(self, data):
return self.client.post('/metadata/api/tables/', data)
def update_table(self, pk, data):
obj = self.get_table(pk)
obj.update(data)
return self.client.put('/metadata/api/tables/%i/' % pk, obj)
def delete_table(self, pk):
return self.client.delete('/metadata/api/tables/%i/' % pk)
# columns
def get_columns(self):
return self.client.get('/metadata/api/columns/')
def get_column(self, pk):
return self.client.get('/metadata/api/columns/%i/' % pk)
def create_column(self, data):
return self.client.post('/metadata/api/columns/', data)
def update_column(self, pk, data):
obj = self.get_column(pk)
obj.update(data)
return self.client.put('/metadata/api/columns/%i/' % pk, obj)
def delete_column(self, pk):
return self.client.delete('/metadata/api/columns/%i/' % pk)
# functions
def get_functions(self):
return self.client.get('/metadata/api/functions/')
def get_function(self, pk):
return self.client.get('/metadata/api/functions/%i/' % pk)
def create_function(self, data):
return self.client.post('/metadata/api/functions/', data)
def update_function(self, pk, data):
obj = self.get_function(pk)
obj.update(data)
return self.client.put('/metadata/api/functions/%i/' % pk, obj)
def delete_function(self, pk):
return self.client.delete('/metadata/api/functions/%i/' % pk)