-
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.
Bmoric/extract destination api (#18502)
* Tmp * Extract the Attempt API from the V1 API * Add comments * Move Connection API out of configuration API * format * format * Rename to Controller * Rename to Controller * Add values to the factory * Change the constructor to use hadler instead of objects needed by the handler * Update with new tags. * Fix PMD errors * Add explicit path to the controller * Extract destiantion API
- Loading branch information
1 parent
8635d97
commit 9505596
Showing
6 changed files
with
208 additions
and
14 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
77 changes: 77 additions & 0 deletions
77
airbyte-server/src/main/java/io/airbyte/server/apis/DestinationApiController.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,77 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.DestinationApi; | ||
import io.airbyte.api.model.generated.CheckConnectionRead; | ||
import io.airbyte.api.model.generated.DestinationCloneRequestBody; | ||
import io.airbyte.api.model.generated.DestinationCreate; | ||
import io.airbyte.api.model.generated.DestinationIdRequestBody; | ||
import io.airbyte.api.model.generated.DestinationRead; | ||
import io.airbyte.api.model.generated.DestinationReadList; | ||
import io.airbyte.api.model.generated.DestinationSearch; | ||
import io.airbyte.api.model.generated.DestinationUpdate; | ||
import io.airbyte.api.model.generated.WorkspaceIdRequestBody; | ||
import io.airbyte.server.handlers.DestinationHandler; | ||
import io.airbyte.server.handlers.SchedulerHandler; | ||
import javax.ws.rs.Path; | ||
import lombok.AllArgsConstructor; | ||
|
||
@Path("/v1/destinations") | ||
@AllArgsConstructor | ||
public class DestinationApiController implements DestinationApi { | ||
|
||
private final DestinationHandler destinationHandler; | ||
private final SchedulerHandler schedulerHandler; | ||
|
||
@Override | ||
public CheckConnectionRead checkConnectionToDestination(final DestinationIdRequestBody destinationIdRequestBody) { | ||
return ConfigurationApi.execute(() -> schedulerHandler.checkDestinationConnectionFromDestinationId(destinationIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public CheckConnectionRead checkConnectionToDestinationForUpdate(final DestinationUpdate destinationUpdate) { | ||
return ConfigurationApi.execute(() -> schedulerHandler.checkDestinationConnectionFromDestinationIdForUpdate(destinationUpdate)); | ||
} | ||
|
||
@Override | ||
public DestinationRead cloneDestination(final DestinationCloneRequestBody destinationCloneRequestBody) { | ||
return ConfigurationApi.execute(() -> destinationHandler.cloneDestination(destinationCloneRequestBody)); | ||
} | ||
|
||
@Override | ||
public DestinationRead createDestination(final DestinationCreate destinationCreate) { | ||
return ConfigurationApi.execute(() -> destinationHandler.createDestination(destinationCreate)); | ||
} | ||
|
||
@Override | ||
public void deleteDestination(final DestinationIdRequestBody destinationIdRequestBody) { | ||
ConfigurationApi.execute(() -> { | ||
destinationHandler.deleteDestination(destinationIdRequestBody); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public DestinationRead getDestination(final DestinationIdRequestBody destinationIdRequestBody) { | ||
return ConfigurationApi.execute(() -> destinationHandler.getDestination(destinationIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public DestinationReadList listDestinationsForWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) { | ||
return ConfigurationApi.execute(() -> destinationHandler.listDestinationsForWorkspace(workspaceIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public DestinationReadList searchDestinations(final DestinationSearch destinationSearch) { | ||
return ConfigurationApi.execute(() -> destinationHandler.searchDestinations(destinationSearch)); | ||
} | ||
|
||
@Override | ||
public DestinationRead updateDestination(final DestinationUpdate destinationUpdate) { | ||
return ConfigurationApi.execute(() -> destinationHandler.updateDestination(destinationUpdate)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/DestinationApiBinder.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.DestinationApiController; | ||
import io.airbyte.server.apis.factories.DestinationApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class DestinationApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(DestinationApiFactory.class) | ||
.to(DestinationApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
airbyte-server/src/main/java/io/airbyte/server/apis/factories/DestinationApiFactory.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,40 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.factories; | ||
|
||
import io.airbyte.server.apis.DestinationApiController; | ||
import io.airbyte.server.handlers.DestinationHandler; | ||
import io.airbyte.server.handlers.SchedulerHandler; | ||
import java.util.Map; | ||
import org.glassfish.hk2.api.Factory; | ||
import org.slf4j.MDC; | ||
|
||
public class DestinationApiFactory implements Factory<DestinationApiController> { | ||
|
||
private static DestinationHandler destinationHandler; | ||
private static SchedulerHandler schedulerHandler; | ||
private static Map<String, String> mdc; | ||
|
||
public static void setValues(final DestinationHandler destinationHandler, | ||
final SchedulerHandler schedulerHandler, | ||
final Map<String, String> mdc) { | ||
DestinationApiFactory.destinationHandler = destinationHandler; | ||
DestinationApiFactory.schedulerHandler = schedulerHandler; | ||
DestinationApiFactory.mdc = mdc; | ||
} | ||
|
||
@Override | ||
public DestinationApiController provide() { | ||
MDC.setContextMap(DestinationApiFactory.mdc); | ||
|
||
return new DestinationApiController(destinationHandler, schedulerHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final DestinationApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |