|
|
@@ -3,6 +3,8 @@
|
|
|
#
|
|
|
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
|
|
|
#
|
|
|
+# Warning: module edited below.
|
|
|
+#
|
|
|
# options string: py
|
|
|
#
|
|
|
|
|
|
@@ -16,6 +18,43 @@ try:
|
|
|
except:
|
|
|
fastbinary = None
|
|
|
|
|
|
+from django.utils.functional import wraps
|
|
|
+
|
|
|
+
|
|
|
+### Do as / Impersonation support.
|
|
|
+### This should be put back if rerenerating the Thrift.
|
|
|
+### As well as all the @do_as in Client.
|
|
|
+
|
|
|
+import logging
|
|
|
+
|
|
|
+from django.utils.encoding import smart_str
|
|
|
+from hbase.hbase_site import is_impersonation_enabled
|
|
|
+
|
|
|
+LOG = logging.getLogger(__name__)
|
|
|
+
|
|
|
+
|
|
|
+def do_as(func):
|
|
|
+ def decorate(*args, **kwargs):
|
|
|
+ self = args[0]
|
|
|
+ username = kwargs.pop('doas')
|
|
|
+
|
|
|
+ try:
|
|
|
+ if is_impersonation_enabled():
|
|
|
+ if hasattr(self._oprot.trans, 'TFramedTransport'):
|
|
|
+ trans_client = self._oprot.trans._TFramedTransport__trans
|
|
|
+ else:
|
|
|
+ trans_client = self._oprot.trans._TBufferedTransport__trans
|
|
|
+
|
|
|
+ trans_client.setCustomHeaders({'doAs': username})
|
|
|
+
|
|
|
+ except AttributeError, e:
|
|
|
+ LOG.error('Could not set doAs parameter: %s' % smart_str(e))
|
|
|
+
|
|
|
+ return func(*args, **kwargs)
|
|
|
+ return wraps(func)(decorate)
|
|
|
+
|
|
|
+###
|
|
|
+
|
|
|
|
|
|
class Iface:
|
|
|
def enableTable(self, tableName):
|
|
|
@@ -619,6 +658,7 @@ class Client(Iface):
|
|
|
self._oprot = oprot
|
|
|
self._seqid = 0
|
|
|
|
|
|
+ @do_as
|
|
|
def enableTable(self, tableName):
|
|
|
"""
|
|
|
Brings a table on-line (enables it)
|
|
|
@@ -651,6 +691,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def disableTable(self, tableName):
|
|
|
"""
|
|
|
Disables a table (takes it off-line) If it is being served, the master
|
|
|
@@ -684,6 +725,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def isTableEnabled(self, tableName):
|
|
|
"""
|
|
|
@return true if table is on-line
|
|
|
@@ -718,6 +760,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "isTableEnabled failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def compact(self, tableNameOrRegionName):
|
|
|
"""
|
|
|
Parameters:
|
|
|
@@ -748,6 +791,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def majorCompact(self, tableNameOrRegionName):
|
|
|
"""
|
|
|
Parameters:
|
|
|
@@ -778,7 +822,8 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
- def getTableNames(self, ):
|
|
|
+ @do_as
|
|
|
+ def getTableNames(self):
|
|
|
"""
|
|
|
List all the userspace tables.
|
|
|
|
|
|
@@ -810,6 +855,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableNames failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getColumnDescriptors(self, tableName):
|
|
|
"""
|
|
|
List all the column families assoicated with a table.
|
|
|
@@ -846,6 +892,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getColumnDescriptors failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getTableRegions(self, tableName):
|
|
|
"""
|
|
|
List the regions associated with a table.
|
|
|
@@ -882,6 +929,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getTableRegions failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def createTable(self, tableName, columnFamilies):
|
|
|
"""
|
|
|
Create a table with the specified column families. The name
|
|
|
@@ -927,6 +975,7 @@ class Client(Iface):
|
|
|
raise result.exist
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def deleteTable(self, tableName):
|
|
|
"""
|
|
|
Deletes a table
|
|
|
@@ -962,6 +1011,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def get(self, tableName, row, column, attributes):
|
|
|
"""
|
|
|
Get a single TCell for the specified table, row, and column at the
|
|
|
@@ -1005,6 +1055,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "get failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getVer(self, tableName, row, column, numVersions, attributes):
|
|
|
"""
|
|
|
Get the specified number of versions for the specified table,
|
|
|
@@ -1050,6 +1101,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getVer failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getVerTs(self, tableName, row, column, timestamp, numVersions, attributes):
|
|
|
"""
|
|
|
Get the specified number of versions for the specified table,
|
|
|
@@ -1098,6 +1150,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getVerTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRow(self, tableName, row, attributes):
|
|
|
"""
|
|
|
Get all the data for the specified table and row at the latest
|
|
|
@@ -1139,6 +1192,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRow failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowWithColumns(self, tableName, row, columns, attributes):
|
|
|
"""
|
|
|
Get the specified columns for the specified table and row at the latest
|
|
|
@@ -1182,6 +1236,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumns failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowTs(self, tableName, row, timestamp, attributes):
|
|
|
"""
|
|
|
Get all the data for the specified table and row at the specified
|
|
|
@@ -1225,6 +1280,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowWithColumnsTs(self, tableName, row, columns, timestamp, attributes):
|
|
|
"""
|
|
|
Get the specified columns for the specified table and row at the specified
|
|
|
@@ -1270,6 +1326,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowWithColumnsTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRows(self, tableName, rows, attributes):
|
|
|
"""
|
|
|
Get all the data for the specified table and rows at the latest
|
|
|
@@ -1311,6 +1368,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRows failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowsWithColumns(self, tableName, rows, columns, attributes):
|
|
|
"""
|
|
|
Get the specified columns for the specified table and rows at the latest
|
|
|
@@ -1354,6 +1412,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowsWithColumns failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowsTs(self, tableName, rows, timestamp, attributes):
|
|
|
"""
|
|
|
Get all the data for the specified table and rows at the specified
|
|
|
@@ -1397,6 +1456,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowsTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowsWithColumnsTs(self, tableName, rows, columns, timestamp, attributes):
|
|
|
"""
|
|
|
Get the specified columns for the specified table and rows at the specified
|
|
|
@@ -1442,6 +1502,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowsWithColumnsTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def mutateRow(self, tableName, row, mutations, attributes):
|
|
|
"""
|
|
|
Apply a series of mutations (updates/deletes) to a row in a
|
|
|
@@ -1485,6 +1546,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def mutateRowTs(self, tableName, row, mutations, timestamp, attributes):
|
|
|
"""
|
|
|
Apply a series of mutations (updates/deletes) to a row in a
|
|
|
@@ -1530,6 +1592,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def mutateRows(self, tableName, rowBatches, attributes):
|
|
|
"""
|
|
|
Apply a series of batches (each a series of mutations on a single row)
|
|
|
@@ -1571,6 +1634,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def mutateRowsTs(self, tableName, rowBatches, timestamp, attributes):
|
|
|
"""
|
|
|
Apply a series of batches (each a series of mutations on a single row)
|
|
|
@@ -1614,6 +1678,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def atomicIncrement(self, tableName, row, column, value):
|
|
|
"""
|
|
|
Atomically increment the column value specified. Returns the next value post increment.
|
|
|
@@ -1656,6 +1721,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "atomicIncrement failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def deleteAll(self, tableName, row, column, attributes):
|
|
|
"""
|
|
|
Delete all cells that match the passed row and column.
|
|
|
@@ -1694,6 +1760,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def deleteAllTs(self, tableName, row, column, timestamp, attributes):
|
|
|
"""
|
|
|
Delete all cells that match the passed row and column and whose
|
|
|
@@ -1735,6 +1802,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def deleteAllRow(self, tableName, row, attributes):
|
|
|
"""
|
|
|
Completely delete the row's cells.
|
|
|
@@ -1771,6 +1839,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def increment(self, increment):
|
|
|
"""
|
|
|
Increment a cell by the ammount.
|
|
|
@@ -1806,6 +1875,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def incrementRows(self, increments):
|
|
|
"""
|
|
|
Parameters:
|
|
|
@@ -1836,6 +1906,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def deleteAllRowTs(self, tableName, row, timestamp, attributes):
|
|
|
"""
|
|
|
Completely delete the row's cells marked with a timestamp
|
|
|
@@ -1875,6 +1946,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpenWithScan(self, tableName, scan, attributes):
|
|
|
"""
|
|
|
Get a scanner on the current table, using the Scan instance
|
|
|
@@ -1914,6 +1986,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithScan failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpen(self, tableName, startRow, columns, attributes):
|
|
|
"""
|
|
|
Get a scanner on the current table starting at the specified row and
|
|
|
@@ -1960,6 +2033,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpen failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpenWithStop(self, tableName, startRow, stopRow, columns, attributes):
|
|
|
"""
|
|
|
Get a scanner on the current table starting and stopping at the
|
|
|
@@ -2010,6 +2084,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithStop failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpenWithPrefix(self, tableName, startAndPrefix, columns, attributes):
|
|
|
"""
|
|
|
Open a scanner for a given prefix. That is all rows will have the specified
|
|
|
@@ -2053,6 +2128,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithPrefix failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpenTs(self, tableName, startRow, columns, timestamp, attributes):
|
|
|
"""
|
|
|
Get a scanner on the current table starting at the specified row and
|
|
|
@@ -2102,6 +2178,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerOpenWithStopTs(self, tableName, startRow, stopRow, columns, timestamp, attributes):
|
|
|
"""
|
|
|
Get a scanner on the current table starting and stopping at the
|
|
|
@@ -2155,6 +2232,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerOpenWithStopTs failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerGet(self, id):
|
|
|
"""
|
|
|
Returns the scanner's current row value and advances to the next
|
|
|
@@ -2200,6 +2278,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerGet failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerGetList(self, id, nbRows):
|
|
|
"""
|
|
|
Returns, starting at the scanner's current row value nbRows worth of
|
|
|
@@ -2247,6 +2326,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "scannerGetList failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def scannerClose(self, id):
|
|
|
"""
|
|
|
Closes the server-state associated with an open scanner.
|
|
|
@@ -2283,6 +2363,7 @@ class Client(Iface):
|
|
|
raise result.ia
|
|
|
return
|
|
|
|
|
|
+ @do_as
|
|
|
def getRowOrBefore(self, tableName, row, family):
|
|
|
"""
|
|
|
Get the row just before the specified one.
|
|
|
@@ -2323,6 +2404,7 @@ class Client(Iface):
|
|
|
raise result.io
|
|
|
raise TApplicationException(TApplicationException.MISSING_RESULT, "getRowOrBefore failed: unknown result");
|
|
|
|
|
|
+ @do_as
|
|
|
def getRegionInfo(self, row):
|
|
|
"""
|
|
|
Get the regininfo for the specified row. It scans
|