def post(self):
        """Return the JSON representation of a new resource created through
        an HTTP POST call.

        :returns: ``HTTP 201`` if a resource is properly created
        :returns: ``HTTP 204`` if the resource already exists
        :returns: ``HTTP 400`` if the request is malformed or missing data
        """
        resource = self.__model__.query.filter_by(**request.json).first()
        if resource:
            error_message = is_valid_method(self.__model__, resource)
            if error_message:
                raise BadRequestException(error_message)
            return self._no_content_response()

        resource = self.__model__(**request.json)  # pylint: disable=not-callable
        error_message = is_valid_method(self.__model__, resource)
        if error_message:
            raise BadRequestException(error_message)
        db.session().add(resource)
        db.session().commit()
        return self._created_response(resource)
def post ( self ) : resource = self . __model__ . query . filter_by ( ** request . json ) . first ( ) if resource : error_message = is_valid_method ( self . __model__ , resource ) if error_message : raise BadRequestException ( error_message ) return self . _no_content_response ( ) resource = self . __model__ ( ** request . json ) error_message = is_valid_method ( self . __model__ , resource ) if error_message : raise BadRequestException ( error_message ) db . session ( ) . add ( resource ) db . session ( ) . commit ( ) return self . _created_response ( resource )
Return the JSON representation of a new resource created through
        an HTTP POST call.

        :returns: ``HTTP 201`` if a resource is properly created
        :returns: ``HTTP 204`` if the resource already exists
        :returns: ``HTTP 400`` if the request is malformed or missing data