Skip to content

Extract Operation API #18928

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 4 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import io.airbyte.server.apis.LogsApiController;
import io.airbyte.server.apis.NotificationsApiController;
import io.airbyte.server.apis.OpenapiApiController;
import io.airbyte.server.apis.OperationApiController;
import io.airbyte.server.apis.binders.AttemptApiBinder;
import io.airbyte.server.apis.binders.ConnectionApiBinder;
import io.airbyte.server.apis.binders.DbMigrationBinder;
Expand All @@ -39,6 +40,7 @@
import io.airbyte.server.apis.binders.LogsApiBinder;
import io.airbyte.server.apis.binders.NotificationApiBinder;
import io.airbyte.server.apis.binders.OpenapiApiBinder;
import io.airbyte.server.apis.binders.OperationApiBinder;
import io.airbyte.server.apis.binders.SourceOauthApiBinder;
import io.airbyte.server.apis.factories.AttemptApiFactory;
import io.airbyte.server.apis.factories.ConnectionApiFactory;
Expand All @@ -52,6 +54,7 @@
import io.airbyte.server.apis.factories.LogsApiFactory;
import io.airbyte.server.apis.factories.NotificationsApiFactory;
import io.airbyte.server.apis.factories.OpenapiApiFactory;
import io.airbyte.server.apis.factories.OperationApiFactory;
import io.airbyte.server.apis.factories.SourceOauthApiFactory;
import io.airbyte.server.handlers.AttemptHandler;
import io.airbyte.server.handlers.ConnectionsHandler;
Expand Down Expand Up @@ -190,6 +193,8 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

NotificationsApiFactory.setValues(workspacesHandler);

OperationApiFactory.setValues(operationsHandler);

OpenapiApiFactory.setValues(openApiConfigHandler);

// server configurations
Expand All @@ -207,6 +212,7 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
LogsApiController.class,
NotificationsApiController.class,
OpenapiApiController.class,
OperationApiController.class,
SourceOauthApiFactory.class);

final Set<Object> components = Set.of(
Expand All @@ -224,6 +230,7 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new LogsApiBinder(),
new NotificationApiBinder(),
new OpenapiApiBinder(),
new OperationApiBinder(),
new SourceOauthApiBinder());

// construct server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -835,42 +835,63 @@ public JobInfoRead resetConnection(final ConnectionIdRequestBody connectionIdReq

// Operations

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public CheckOperationRead checkOperation(final OperatorConfiguration operatorConfiguration) {
return execute(() -> operationsHandler.checkOperation(operatorConfiguration));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public OperationRead createOperation(final OperationCreate operationCreate) {
return execute(() -> operationsHandler.createOperation(operationCreate));
throw new NotImplementedException();
}

@Override
public ConnectionState createOrUpdateState(final ConnectionStateCreateOrUpdate connectionStateCreateOrUpdate) {
return ConfigurationApi.execute(() -> stateHandler.createOrUpdateState(connectionStateCreateOrUpdate));
}

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public void deleteOperation(final OperationIdRequestBody operationIdRequestBody) {
execute(() -> {
operationsHandler.deleteOperation(operationIdRequestBody);
return null;
});
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public OperationReadList listOperationsForConnection(final ConnectionIdRequestBody connectionIdRequestBody) {
return execute(() -> operationsHandler.listOperationsForConnection(connectionIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public OperationRead getOperation(final OperationIdRequestBody operationIdRequestBody) {
return execute(() -> operationsHandler.getOperation(operationIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link OperationApiController}. Since the path of
* {@link OperationApiController} is more granular, it will override this implementation
*/
@Override
public OperationRead updateOperation(final OperationUpdate operationUpdate) {
return execute(() -> operationsHandler.updateOperation(operationUpdate));
throw new NotImplementedException();
}

@Override
Expand Down
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));
}

}
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);
}

}
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 */
}

}