Skip to content

Instantly share code, notes, and snippets.

@eevans
Created September 2, 2010 21:15
Show Gist options
  • Save eevans/562965 to your computer and use it in GitHub Desktop.
Save eevans/562965 to your computer and use it in GitHub Desktop.
class MissingFieldException(Exception):
pass
class ColumnPath(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('column_family'):
raise MissingFieldException('column_family')
self['column_family'] = kwargs.get('column_family', None)
self['super_column'] = kwargs.get('super_column', None)
self['column'] = kwargs.get('column', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class ColumnParent(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('column_family'):
raise MissingFieldException('column_family')
self['column_family'] = kwargs.get('column_family', None)
self['super_column'] = kwargs.get('super_column', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class Clock(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('timestamp'):
raise MissingFieldException('timestamp')
self['timestamp'] = kwargs.get('timestamp', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class Column(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('name'):
raise MissingFieldException('name')
self['name'] = kwargs.get('name', None)
if not kwargs.has_key('value'):
raise MissingFieldException('value')
self['value'] = kwargs.get('value', None)
if not kwargs.has_key('clock'):
raise MissingFieldException('clock')
self['clock'] = kwargs.get('clock', None)
self['ttl'] = kwargs.get('ttl', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class SuperColumn(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('name'):
raise MissingFieldException('name')
self['name'] = kwargs.get('name', None)
if not kwargs.has_key('columns'):
raise MissingFieldException('columns')
self['columns'] = kwargs.get('columns', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class ColumnOrSuperColumn(dict):
def __init__(self, **kwargs):
self['column'] = kwargs.get('column', None)
self['super_column'] = kwargs.get('super_column', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class SliceRange(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('start'):
raise MissingFieldException('start')
self['start'] = kwargs.get('start', None)
if not kwargs.has_key('finish'):
raise MissingFieldException('finish')
self['finish'] = kwargs.get('finish', None)
if not kwargs.has_key('reversed'):
raise MissingFieldException('reversed')
self['reversed'] = kwargs.get('reversed', None)
if not kwargs.has_key('count'):
raise MissingFieldException('count')
self['count'] = kwargs.get('count', None)
self['bitmasks'] = kwargs.get('bitmasks', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class SlicePredicate(dict):
def __init__(self, **kwargs):
self['column_names'] = kwargs.get('column_names', None)
self['slice_range'] = kwargs.get('slice_range', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class TokenRange(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('start_token'):
raise MissingFieldException('start_token')
self['start_token'] = kwargs.get('start_token', None)
if not kwargs.has_key('end_token'):
raise MissingFieldException('end_token')
self['end_token'] = kwargs.get('end_token', None)
if not kwargs.has_key('endpoints'):
raise MissingFieldException('endpoints')
self['endpoints'] = kwargs.get('endpoints', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class IndexExpression(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('column_name'):
raise MissingFieldException('column_name')
self['column_name'] = kwargs.get('column_name', None)
if not kwargs.has_key('op'):
raise MissingFieldException('op')
self['op'] = kwargs.get('op', None)
if not kwargs.has_key('value'):
raise MissingFieldException('value')
self['value'] = kwargs.get('value', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class IndexClause(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('expressions'):
raise MissingFieldException('expressions')
self['expressions'] = kwargs.get('expressions', None)
if not kwargs.has_key('start_key'):
raise MissingFieldException('start_key')
self['start_key'] = kwargs.get('start_key', None)
if not kwargs.has_key('count'):
raise MissingFieldException('count')
self['count'] = kwargs.get('count', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class KeyRange(dict):
def __init__(self, **kwargs):
self['start_key'] = kwargs.get('start_key', None)
self['end_key'] = kwargs.get('end_key', None)
self['start_token'] = kwargs.get('start_token', None)
self['end_token'] = kwargs.get('end_token', None)
if not kwargs.has_key('count'):
raise MissingFieldException('count')
self['count'] = kwargs.get('count', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class KeySlice(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('key'):
raise MissingFieldException('key')
self['key'] = kwargs.get('key', None)
if not kwargs.has_key('columns'):
raise MissingFieldException('columns')
self['columns'] = kwargs.get('columns', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class Deletion(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('clock'):
raise MissingFieldException('clock')
self['clock'] = kwargs.get('clock', None)
self['super_column'] = kwargs.get('super_column', None)
self['predicate'] = kwargs.get('predicate', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class Mutation(dict):
def __init__(self, **kwargs):
self['column_or_supercolumn'] = kwargs.get('column_or_supercolumn', None)
self['deletion'] = kwargs.get('deletion', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class ColumnDef(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('name'):
raise MissingFieldException('name')
self['name'] = kwargs.get('name', None)
if not kwargs.has_key('validation_class'):
raise MissingFieldException('validation_class')
self['validation_class'] = kwargs.get('validation_class', None)
self['index_type'] = kwargs.get('index_type', None)
self['index_name'] = kwargs.get('index_name', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class CfDef(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('keyspace'):
raise MissingFieldException('keyspace')
self['keyspace'] = kwargs.get('keyspace', None)
if not kwargs.has_key('name'):
raise MissingFieldException('name')
self['name'] = kwargs.get('name', None)
self['column_type'] = kwargs.get('column_type', None)
self['clock_type'] = kwargs.get('clock_type', None)
self['comparator_type'] = kwargs.get('comparator_type', None)
self['subcomparator_type'] = kwargs.get('subcomparator_type', None)
self['reconciler'] = kwargs.get('reconciler', None)
self['comment'] = kwargs.get('comment', None)
self['row_cache_size'] = kwargs.get('row_cache_size', None)
self['preload_row_cache'] = kwargs.get('preload_row_cache', None)
self['key_cache_size'] = kwargs.get('key_cache_size', None)
self['read_repair_chance'] = kwargs.get('read_repair_chance', None)
self['gc_grace_seconds'] = kwargs.get('gc_grace_seconds', None)
self['default_validation_class'] = kwargs.get('default_validation_class', None)
self['id'] = kwargs.get('id', None)
self['column_metadata'] = kwargs.get('column_metadata', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class KsDef(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('name'):
raise MissingFieldException('name')
self['name'] = kwargs.get('name', None)
if not kwargs.has_key('strategy_class'):
raise MissingFieldException('strategy_class')
self['strategy_class'] = kwargs.get('strategy_class', None)
self['strategy_options'] = kwargs.get('strategy_options', None)
if not kwargs.has_key('replication_factor'):
raise MissingFieldException('replication_factor')
self['replication_factor'] = kwargs.get('replication_factor', None)
if not kwargs.has_key('cf_defs'):
raise MissingFieldException('cf_defs')
self['cf_defs'] = kwargs.get('cf_defs', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class MutationsMapEntry(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('key'):
raise MissingFieldException('key')
self['key'] = kwargs.get('key', None)
if not kwargs.has_key('mutations'):
raise MissingFieldException('mutations')
self['mutations'] = kwargs.get('mutations', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class CoscsMapEntry(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('key'):
raise MissingFieldException('key')
self['key'] = kwargs.get('key', None)
if not kwargs.has_key('columns'):
raise MissingFieldException('columns')
self['columns'] = kwargs.get('columns', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class KeyCountMapEntry(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('key'):
raise MissingFieldException('key')
self['key'] = kwargs.get('key', None)
if not kwargs.has_key('count'):
raise MissingFieldException('count')
self['count'] = kwargs.get('count', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
class AuthenticationRequest(dict):
def __init__(self, **kwargs):
if not kwargs.has_key('credentials'):
raise MissingFieldException('credentials')
self['credentials'] = kwargs.get('credentials', None)
def __setattr__(self, name, value):
self[name] = value
def __getattr__(self, name):
return self[name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment