feat: Add REST API for Functions CRUD operations#2091
Open
sunnymodi21 wants to merge 1 commit intosequinstream:mainfrom
Open
feat: Add REST API for Functions CRUD operations#2091sunnymodi21 wants to merge 1 commit intosequinstream:mainfrom
sunnymodi21 wants to merge 1 commit intosequinstream:mainfrom
Conversation
Implements a comprehensive REST API for Functions with full CRUD operations, following the same patterns as existing controllers (SinkConsumer, HttpEndpoint). ## Changes ### Backend Implementation - Add FunctionController with index, show, create, update, delete actions - Add FunctionJSON for response serialization - Add from_external_function/1 to Transforms module for input parsing - Enhance update_function/3 in Consumers module to support struct and ID-based updates - Fix unique constraint name in Function schema - Add /api/functions routes to router ### API Endpoints - GET /api/functions - List all functions - GET /api/functions/:id_or_name - Get function by ID or name - POST /api/functions - Create new function - PUT /api/functions/:id_or_name - Update function by ID or name - DELETE /api/functions/:id_or_name - Delete function by ID or name ### Features - Supports all 5 function types: filter, transform, enrichment, path, routing - Flexible input format (flat and nested structures) - ID and name-based lookups - Account-scoped operations - Proper validation and error handling ### Tests - Add comprehensive test suite with 19 tests covering all CRUD operations - Tests for all function types - Tests for ID and name-based lookups - Account isolation tests - Validation and error handling tests - All tests passing (19/19) ### Documentation - Add 5 API reference docs (create, list, get, update, delete) - Update docs.json to include Functions section - Add implementation guide (FUNCTIONS_REST_API.md) - Add test scripts for API validation ### Code Quality - All code formatted with mix format - No compiler warnings - Follows existing controller patterns - All existing tests still passing (1299/1299) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a comprehensive REST API for Functions with full CRUD operations, following the same patterns as existing controllers (SinkConsumer, HttpEndpoint).
Changes
Backend Implementation
from_external_function/1for input parsingupdate_function/3/api/functionsroutesAPI Endpoints
Function Types Supported
Features
Tests
Documentation
Code Quality
mix formatmix compile --warnings-as-errorspassesTesting
All tests pass:
Test the API manually:
Example Usage
Create a filter function:
List all functions:
Files Changed
New Files (8):
lib/sequin_web/controllers/function_controller.exlib/sequin_web/controllers/function_json.extest/sequin_web/controllers/function_controller_test.exsdocs/management-api/functions/create.mdxdocs/management-api/functions/list.mdxdocs/management-api/functions/get.mdxdocs/management-api/functions/update.mdxdocs/management-api/functions/delete.mdxModified Files (5):
lib/sequin/transforms/transforms.exlib/sequin/consumers/consumers.exlib/sequin/consumers/function.exlib/sequin_web/router.exdocs/docs.jsonChecklist
closes #2043