pfunk.contrib.generic
View Source
from pfunk.resources import Function, Index from pfunk.client import q class GenericFunction(Function): action = 'create' def get_role(self): return None # pragma: no cover def get_name(self): return f"{self.action}_{self.collection.get_class_name()}" def get_fields(self): return self.collection.get_fields() class AllFunction(GenericFunction): def get_name(self): return self.collection.all_function_name() def get_body(self): return q.query( q.lambda_(["input"], q.map_( q.lambda_(['ref'], q.get(q.var('ref')) ), q.paginate( q.match(q.index(self.collection.all_index_name())), q.select('size', q.var('input')) ) ) ) ) class GenericCreate(GenericFunction): def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.create( q.collection(self.collection.get_collection_name()), data_dict ) )) class GenericUpdate(GenericFunction): action = 'update' def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.update( q.collection(self.collection.get_collection_name(), q.select('id', q.var("input"))), data_dict ) )) class GenericDelete(GenericFunction): action = 'delete' def get_body(self): return q.query( q.lambda_(["input"], q.delete(q.ref(q.collection(self.collection.get_collection_name()), q.select('id', q.var("input")))) ) )
View Source
class GenericFunction(Function): action = 'create' def get_role(self): return None # pragma: no cover def get_name(self): return f"{self.action}_{self.collection.get_class_name()}" def get_fields(self): return self.collection.get_fields()
Resource class is the base class for Function, Role, and Index class.
View Source
def get_role(self): return None # pragma: no cover
Gets the role to use when calling the function.
View Source
def get_name(self): return f"{self.action}_{self.collection.get_class_name()}"
Returns the name of the resource
Returns: str
View Source
def get_fields(self): return self.collection.get_fields()
Inherited Members
View Source
class AllFunction(GenericFunction): def get_name(self): return self.collection.all_function_name() def get_body(self): return q.query( q.lambda_(["input"], q.map_( q.lambda_(['ref'], q.get(q.var('ref')) ), q.paginate( q.match(q.index(self.collection.all_index_name())), q.select('size', q.var('input')) ) ) ) )
Resource class is the base class for Function, Role, and Index class.
View Source
def get_name(self): return self.collection.all_function_name()
Returns the name of the resource
Returns: str
View Source
def get_body(self): return q.query( q.lambda_(["input"], q.map_( q.lambda_(['ref'], q.get(q.var('ref')) ), q.paginate( q.match(q.index(self.collection.all_index_name())), q.select('size', q.var('input')) ) ) ) )
View Source
class GenericCreate(GenericFunction): def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.create( q.collection(self.collection.get_collection_name()), data_dict ) ))
Resource class is the base class for Function, Role, and Index class.
View Source
def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.create( q.collection(self.collection.get_collection_name()), data_dict ) ))
View Source
class GenericUpdate(GenericFunction): action = 'update' def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.update( q.collection(self.collection.get_collection_name(), q.select('id', q.var("input"))), data_dict ) ))
Resource class is the base class for Function, Role, and Index class.
View Source
def get_body(self): data_dict = { "data": self.get_fields(), } return q.query( q.lambda_(["input"], q.update( q.collection(self.collection.get_collection_name(), q.select('id', q.var("input"))), data_dict ) ))
View Source
class GenericDelete(GenericFunction): action = 'delete' def get_body(self): return q.query( q.lambda_(["input"], q.delete(q.ref(q.collection(self.collection.get_collection_name()), q.select('id', q.var("input")))) ) )
Resource class is the base class for Function, Role, and Index class.
View Source
def get_body(self): return q.query( q.lambda_(["input"], q.delete(q.ref(q.collection(self.collection.get_collection_name()), q.select('id', q.var("input")))) ) )