def configure_account_routes(graph): controller = graph.account_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewAccountSchema(), response_schema=AccountSchema(), ), Operation.Delete: EndpointDefinition(func=transactional(controller.delete), ), Operation.Retrieve: EndpointDefinition( func=auth_group("app-users-group")(controller.retrieve), response_schema=AccountSchema(), ), Operation.Search: EndpointDefinition( func=auth_group("app-admins-group")(controller.search), request_schema=SearchAccountSchema(), response_schema=AccountSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_topping_routes(graph): controller = graph.topping_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewToppingSchema(), response_schema=ToppingSchema(), ), Operation.Delete: EndpointDefinition(func=transactional(controller.delete), ), Operation.Replace: EndpointDefinition( func=transactional(controller.replace), request_schema=NewToppingSchema(), response_schema=ToppingSchema(), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=ToppingSchema(), ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=SearchToppingSchema(), response_schema=ToppingSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_follower_relationship_routes(graph): controller = graph.follower_relationship_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewFollowerRelationshipSchema(), response_schema=FollowerRelationshipSchema(), ), Operation.Delete: EndpointDefinition(func=transactional(controller.delete), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=FollowerRelationshipSchema(), ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=SearchFollowerRelationshipSchema(), response_schema=FollowerRelationshipSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_example_routes(graph): controller = graph.example_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewExampleSchema(), response_schema=ExampleSchema(), ), Operation.Delete: EndpointDefinition( func=transactional(controller.delete), ), Operation.Replace: EndpointDefinition( func=transactional(controller.replace), request_schema=NewExampleSchema(), response_schema=ExampleSchema(), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=ExampleSchema(), ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=SearchExampleSchema(), response_schema=ExampleSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_user_routes(graph): controller = graph.user_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewUserSchema(), response_schema=UserSchema(), ), Operation.Delete: EndpointDefinition( func=transactional(controller.delete), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=UserSchema(), ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=SearchUserSchema(), response_schema=UserSchema(), ), Operation.Update: EndpointDefinition( func=transactional(controller.update), request_schema=UpdateUserSchema(), response_schema=UserSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_order_routes(graph): controller = graph.order_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewOrderSchema(), response_schema=OrderSchema(), ), Operation.Delete: EndpointDefinition(func=transactional(controller.delete), ), Operation.Replace: EndpointDefinition( func=transactional(controller.replace), request_schema=NewOrderSchema(), response_schema=OrderSchema(), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=OrderSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_event_crud( graph, controller, event_schema, new_event_schema, search_event_schema, use_deferred_batch=False, ): if use_deferred_batch: create_func = transactional( deferred_batch(controller)(controller.create)) else: create_func = transactional(controller.create) mappings = { Operation.Create: EndpointDefinition( func=create_func, request_schema=new_event_schema, response_schema=event_schema, ), Operation.Delete: EndpointDefinition(func=transactional(controller.delete), ), Operation.Replace: EndpointDefinition( func=transactional(controller.replace), request_schema=new_event_schema, response_schema=event_schema, ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=event_schema, ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=search_event_schema, response_schema=event_schema, ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def configure_order_event_routes(graph): controller = graph.order_event_controller mappings = { Operation.Create: EndpointDefinition( func=transactional(controller.create), request_schema=NewOrderEventSchema(), response_schema=OrderEventSchema(), ), Operation.Retrieve: EndpointDefinition( func=controller.retrieve, response_schema=OrderEventSchema(), ), Operation.Search: EndpointDefinition( func=controller.search, request_schema=SearchOrderEventSchema(), response_schema=OrderEventSchema(), ), } configure_crud(graph, controller.ns, mappings) return controller.ns
def _make_transactional_func(self, func): if not self.mark_transactional: return func from microcosm_postgres.context import transactional return transactional(func)