-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Extract Operation API * Extract scheduler API * Format * extract source api
- Loading branch information
1 parent
a53b947
commit 22efa07
Showing
6 changed files
with
199 additions
and
15 deletions.
There are no files selected for viewing
This file contains 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 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 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
84 changes: 84 additions & 0 deletions
84
airbyte-server/src/main/java/io/airbyte/server/apis/SourceApiController.java
This file contains 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,84 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.SourceApi; | ||
import io.airbyte.api.model.generated.CheckConnectionRead; | ||
import io.airbyte.api.model.generated.SourceCloneRequestBody; | ||
import io.airbyte.api.model.generated.SourceCreate; | ||
import io.airbyte.api.model.generated.SourceDiscoverSchemaRead; | ||
import io.airbyte.api.model.generated.SourceDiscoverSchemaRequestBody; | ||
import io.airbyte.api.model.generated.SourceIdRequestBody; | ||
import io.airbyte.api.model.generated.SourceRead; | ||
import io.airbyte.api.model.generated.SourceReadList; | ||
import io.airbyte.api.model.generated.SourceSearch; | ||
import io.airbyte.api.model.generated.SourceUpdate; | ||
import io.airbyte.api.model.generated.WorkspaceIdRequestBody; | ||
import io.airbyte.server.handlers.SchedulerHandler; | ||
import io.airbyte.server.handlers.SourceHandler; | ||
import javax.ws.rs.Path; | ||
import lombok.AllArgsConstructor; | ||
|
||
@Path("/v1/sources") | ||
@AllArgsConstructor | ||
public class SourceApiController implements SourceApi { | ||
|
||
private final SchedulerHandler schedulerHandler; | ||
private final SourceHandler sourceHandler; | ||
|
||
@Override | ||
public CheckConnectionRead checkConnectionToSource(final SourceIdRequestBody sourceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> schedulerHandler.checkSourceConnectionFromSourceId(sourceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public CheckConnectionRead checkConnectionToSourceForUpdate(final SourceUpdate sourceUpdate) { | ||
return ConfigurationApi.execute(() -> schedulerHandler.checkSourceConnectionFromSourceIdForUpdate(sourceUpdate)); | ||
} | ||
|
||
@Override | ||
public SourceRead cloneSource(final SourceCloneRequestBody sourceCloneRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceHandler.cloneSource(sourceCloneRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceRead createSource(final SourceCreate sourceCreate) { | ||
return ConfigurationApi.execute(() -> sourceHandler.createSource(sourceCreate)); | ||
} | ||
|
||
@Override | ||
public void deleteSource(final SourceIdRequestBody sourceIdRequestBody) { | ||
ConfigurationApi.execute(() -> { | ||
sourceHandler.deleteSource(sourceIdRequestBody); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public SourceDiscoverSchemaRead discoverSchemaForSource(final SourceDiscoverSchemaRequestBody sourceDiscoverSchemaRequestBody) { | ||
return ConfigurationApi.execute(() -> schedulerHandler.discoverSchemaForSourceFromSourceId(sourceDiscoverSchemaRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceRead getSource(final SourceIdRequestBody sourceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceHandler.getSource(sourceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceReadList listSourcesForWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> sourceHandler.listSourcesForWorkspace(workspaceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public SourceReadList searchSources(final SourceSearch sourceSearch) { | ||
return ConfigurationApi.execute(() -> sourceHandler.searchSources(sourceSearch)); | ||
} | ||
|
||
@Override | ||
public SourceRead updateSource(final SourceUpdate sourceUpdate) { | ||
return ConfigurationApi.execute(() -> sourceHandler.updateSource(sourceUpdate)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/SourceApiBinder.java
This file contains 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,21 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.binders; | ||
|
||
import io.airbyte.server.apis.SourceApiController; | ||
import io.airbyte.server.apis.factories.SourceApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class SourceApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(SourceApiFactory.class) | ||
.to(SourceApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
airbyte-server/src/main/java/io/airbyte/server/apis/factories/SourceApiFactory.java
This file contains 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,32 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.factories; | ||
|
||
import io.airbyte.server.apis.SourceApiController; | ||
import io.airbyte.server.handlers.SchedulerHandler; | ||
import io.airbyte.server.handlers.SourceHandler; | ||
import org.glassfish.hk2.api.Factory; | ||
|
||
public class SourceApiFactory implements Factory<SourceApiController> { | ||
|
||
private static SchedulerHandler schedulerHandler; | ||
private static SourceHandler sourceHandler; | ||
|
||
public static void setValues(final SchedulerHandler schedulerHandler, final SourceHandler sourceHandler) { | ||
SourceApiFactory.schedulerHandler = schedulerHandler; | ||
SourceApiFactory.sourceHandler = sourceHandler; | ||
} | ||
|
||
@Override | ||
public SourceApiController provide() { | ||
return new SourceApiController(schedulerHandler, sourceHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final SourceApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |