def my_rpc(cls, *args, **kwargs): """ description : Generate and return a Thing based on name args: my_post_body_param: xxx pageable: false parameters: - name : my_query_string_param default : my_value """ print(kwargs) print(args) result = cls response = SAFRSFormattedResponse() try: instances = result.query links, instances, count = paginate(instances) data = [item for item in instances] meta = {} errors = None response.response = jsonapi_format_response( data, meta, links, errors, count) except Exception as exc: log.exception(exc) return response
def my_rpc(cls, *args, **kwargs): """ description : Generate and return a jsonapi-formatted response pageable: false parameters: - name : my_query_string_param default : my_value args: email: test email """ print(args) print(kwargs) response = SAFRSFormattedResponse() try: instances = cls.query links, instances, count = paginate(instances) data = [item for item in instances] meta = {"args": args, "kwargs": kwargs} errors = None response.response = jsonapi_format_response( data, meta, links, errors, count) except Exception as exc: safrs.log.exception(exc) return response
def get_by_name(cls, name, **kwargs): """ description : Generate and return a Thing based on name parameters: - name: name type : string """ thing = cls.query.filter_by(name=name).one_or_none() if not thing: # thing.description = populate_based_on_name() db.session.add(thing) db.session.commit() response = SAFRSFormattedResponse() result = jsonapi_format_response(thing, meta={}, count=1) response.response = result return response