feat: add import project API endpoint#643
Open
ajworkos wants to merge 2 commits intolaunchdarkly:mainfrom
Open
feat: add import project API endpoint#643ajworkos wants to merge 2 commits intolaunchdarkly:mainfrom
ajworkos wants to merge 2 commits intolaunchdarkly:mainfrom
Conversation
Add POST /projects/{projectKey}/import endpoint to the dev server API
that allows importing a project from JSON data. This provides HTTP API
parity with the existing CLI import-project command.
Changes:
- Add /projects/{projectKey}/import endpoint to OpenAPI spec
- Regenerate server.gen.go with new endpoint types
- Implement PostImportProject handler that reuses model.ImportProject()
- Validates required fields (sourceEnvironmentKey, flagsState)
- Returns 409 Conflict if project already exists
- Returns 400 Bad Request for missing fields
- Returns 201 Created with project data on success
The endpoint accepts the same JSON format as output from:
ldcli dev-server get-project --project=<key> \
--expand=overrides --expand=availableVariations
This enables programmatic project imports and UI integration.
Co-authored-by: Cursor <cursoragent@cursor.com>
Use the Project schema for the import endpoint request body instead of defining a custom schema with explicit required fields. This makes it clear that the import endpoint accepts the same JSON format that the export (get-project) endpoint produces. Changes: - Update api.yaml to use Project schema ref for import request body - Regenerate server.gen.go with simplified type alias - Update handler to properly handle nullable FlagsState pointer - Add description clarifying the endpoint accepts exported JSON format This aligns with the CLI import-project command which accepts the exported JSON file directly without requiring individual field specification. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
Author
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
Add
POST /projects/{projectKey}/importendpoint to the dev server API that allows importing a project from JSON data. This provides HTTP API parity with the existing CLIimport-projectcommand.Changes
/projects/{projectKey}/importendpoint to OpenAPI spec (api.yaml)server.gen.gowith new endpoint types and handlersPostImportProjecthandler inpost_import_project.gomodel.ImportProject()function for business logicMotivation
The import-project functionality was recently added as a CLI command (commit 4d945b6), but was not exposed through the HTTP API. This creates an API gap
Implementation Details
The endpoint accepts the same JSON format as output from:
This enables a simple export/import workflow: