-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
146 additions
and
9 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
59 changes: 59 additions & 0 deletions
59
airbyte-server/src/main/java/io/airbyte/server/apis/OperationApiController.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,59 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis; | ||
|
||
import io.airbyte.api.generated.OperationApi; | ||
import io.airbyte.api.model.generated.CheckOperationRead; | ||
import io.airbyte.api.model.generated.ConnectionIdRequestBody; | ||
import io.airbyte.api.model.generated.OperationCreate; | ||
import io.airbyte.api.model.generated.OperationIdRequestBody; | ||
import io.airbyte.api.model.generated.OperationRead; | ||
import io.airbyte.api.model.generated.OperationReadList; | ||
import io.airbyte.api.model.generated.OperationUpdate; | ||
import io.airbyte.api.model.generated.OperatorConfiguration; | ||
import io.airbyte.server.handlers.OperationsHandler; | ||
import javax.ws.rs.Path; | ||
import lombok.AllArgsConstructor; | ||
|
||
@Path("/v1/operations") | ||
@AllArgsConstructor | ||
public class OperationApiController implements OperationApi { | ||
|
||
private final OperationsHandler operationsHandler; | ||
|
||
@Override | ||
public CheckOperationRead checkOperation(final OperatorConfiguration operatorConfiguration) { | ||
return ConfigurationApi.execute(() -> operationsHandler.checkOperation(operatorConfiguration)); | ||
} | ||
|
||
@Override | ||
public OperationRead createOperation(final OperationCreate operationCreate) { | ||
return ConfigurationApi.execute(() -> operationsHandler.createOperation(operationCreate)); | ||
} | ||
|
||
@Override | ||
public void deleteOperation(final OperationIdRequestBody operationIdRequestBody) { | ||
ConfigurationApi.execute(() -> { | ||
operationsHandler.deleteOperation(operationIdRequestBody); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public OperationRead getOperation(final OperationIdRequestBody operationIdRequestBody) { | ||
return ConfigurationApi.execute(() -> operationsHandler.getOperation(operationIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public OperationReadList listOperationsForConnection(final ConnectionIdRequestBody connectionIdRequestBody) { | ||
return ConfigurationApi.execute(() -> operationsHandler.listOperationsForConnection(connectionIdRequestBody)); | ||
} | ||
|
||
@Override | ||
public OperationRead updateOperation(final OperationUpdate operationUpdate) { | ||
return ConfigurationApi.execute(() -> operationsHandler.updateOperation(operationUpdate)); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
airbyte-server/src/main/java/io/airbyte/server/apis/binders/OperationApiBinder.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.OperationApiController; | ||
import io.airbyte.server.apis.factories.OperationApiFactory; | ||
import org.glassfish.hk2.utilities.binding.AbstractBinder; | ||
import org.glassfish.jersey.process.internal.RequestScoped; | ||
|
||
public class OperationApiBinder extends AbstractBinder { | ||
|
||
@Override | ||
protected void configure() { | ||
bindFactory(OperationApiFactory.class) | ||
.to(OperationApiController.class) | ||
.in(RequestScoped.class); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
airbyte-server/src/main/java/io/airbyte/server/apis/factories/OperationApiFactory.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,29 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.apis.factories; | ||
|
||
import io.airbyte.server.apis.OperationApiController; | ||
import io.airbyte.server.handlers.OperationsHandler; | ||
import org.glassfish.hk2.api.Factory; | ||
|
||
public class OperationApiFactory implements Factory<OperationApiController> { | ||
|
||
private static OperationsHandler operationsHandler; | ||
|
||
public static void setValues(final OperationsHandler operationsHandler) { | ||
OperationApiFactory.operationsHandler = operationsHandler; | ||
} | ||
|
||
@Override | ||
public OperationApiController provide() { | ||
return new OperationApiController(OperationApiFactory.operationsHandler); | ||
} | ||
|
||
@Override | ||
public void dispose(final OperationApiController instance) { | ||
/* no op */ | ||
} | ||
|
||
} |