-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Implement Workspace and Source* API endpoints #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ffe1a10
first pass
cgardens 7a7d741
typo
cgardens dadec6d
move exception handling to handler
cgardens 64353f7
to read source impl
cgardens a37efed
shorten to read names
cgardens 65e0b0c
clean up
cgardens 28b9bb5
dumb
cgardens 4d2c3bf
yeah
cgardens b025fed
fix name
cgardens File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletions
6
data/config/STANDARD_WORKSPACE_CONFIGURATION/5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"workspaceId": "5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6", | ||
"name": "default", | ||
"slug": "default", | ||
"initialSetupComplete": false | ||
} |
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
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
81 changes: 81 additions & 0 deletions
81
dataline-server/src/main/java/io/dataline/server/handlers/SourceImplementationsHandler.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.dataline.server.handlers; | ||
|
||
import io.dataline.api.model.SourceImplementationCreate; | ||
import io.dataline.api.model.SourceImplementationRead; | ||
import io.dataline.config.SourceConnectionImplementation; | ||
import io.dataline.config.persistence.ConfigNotFoundException; | ||
import io.dataline.config.persistence.ConfigPersistence; | ||
import io.dataline.config.persistence.JsonValidationException; | ||
import io.dataline.config.persistence.PersistenceConfigType; | ||
import io.dataline.server.errors.KnownException; | ||
import io.dataline.server.validation.IntegrationSchemaValidation; | ||
import java.util.UUID; | ||
|
||
public class SourceImplementationsHandler { | ||
private final ConfigPersistence configPersistence; | ||
|
||
public SourceImplementationsHandler(ConfigPersistence configPersistence) { | ||
this.configPersistence = configPersistence; | ||
} | ||
|
||
public SourceImplementationRead createSourceImplementation( | ||
SourceImplementationCreate sourceImplementationCreate) { | ||
try { | ||
// validate configuration | ||
final IntegrationSchemaValidation validator = | ||
new IntegrationSchemaValidation(configPersistence); | ||
validator.validateSourceConnectionConfiguration( | ||
sourceImplementationCreate.getSourceSpecificationId(), | ||
sourceImplementationCreate.getConnectionConfiguration()); | ||
|
||
// persist | ||
final UUID sourceImplementationId = UUID.randomUUID(); | ||
final SourceConnectionImplementation newSourceConnectionImplementation = | ||
new SourceConnectionImplementation(); | ||
newSourceConnectionImplementation.setSourceSpecificationId( | ||
sourceImplementationCreate.getSourceSpecificationId()); | ||
newSourceConnectionImplementation.setSourceImplementationId(sourceImplementationId); | ||
newSourceConnectionImplementation.setConfiguration( | ||
sourceImplementationCreate.getConnectionConfiguration()); | ||
|
||
configPersistence.writeConfig( | ||
PersistenceConfigType.SOURCE_CONNECTION_IMPLEMENTATION, | ||
sourceImplementationId.toString(), | ||
newSourceConnectionImplementation); | ||
|
||
// read configuration from db | ||
final SourceConnectionImplementation retrievedSourceConnectionImplementation = | ||
configPersistence.getConfig( | ||
PersistenceConfigType.SOURCE_CONNECTION_IMPLEMENTATION, | ||
sourceImplementationId.toString(), | ||
SourceConnectionImplementation.class); | ||
|
||
return toSourceImplementationRead(retrievedSourceConnectionImplementation); | ||
} catch (JsonValidationException e) { | ||
throw new KnownException( | ||
422, | ||
String.format( | ||
"The provided configuration does not fulfill the specification. Errors: %s", | ||
e.getMessage())); | ||
} catch (ConfigNotFoundException e) { | ||
throw new KnownException( | ||
422, | ||
String.format( | ||
"Could not find source specification: %s.", | ||
sourceImplementationCreate.getSourceSpecificationId())); | ||
} | ||
} | ||
|
||
private SourceImplementationRead toSourceImplementationRead( | ||
SourceConnectionImplementation sourceConnectionImplementation) { | ||
final SourceImplementationRead sourceImplementationRead = new SourceImplementationRead(); | ||
sourceConnectionImplementation.setSourceImplementationId( | ||
sourceConnectionImplementation.getSourceImplementationId()); | ||
sourceConnectionImplementation.setSourceSpecificationId( | ||
sourceConnectionImplementation.getSourceSpecificationId()); | ||
sourceConnectionImplementation.setConfiguration( | ||
sourceConnectionImplementation.getConfiguration()); | ||
|
||
return sourceImplementationRead; | ||
} | ||
} |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well this feels dorky. not sure if i should just throw it in its own module. 🤷♀️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the is the default workspace that will ship with the app. in a world where there is one workspace, we can just set it up with some default values.
the data dir is where i plan to save configs for now until i figure out how to work with whatever mount point is configured.