Skip to content

Extract source definition api #18977

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 16 commits into from
Nov 7, 2022
Merged
Show file tree
Hide file tree
Changes from 11 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
2 changes: 2 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
openApiConfigHandler,
operationsHandler,
schedulerHandler,
sourceHandler,
sourceDefinitionsHandler,
workspacesHandler);
}

Expand Down
20 changes: 20 additions & 0 deletions airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import io.airbyte.server.apis.OpenapiApiController;
import io.airbyte.server.apis.OperationApiController;
import io.airbyte.server.apis.SchedulerApiController;
import io.airbyte.server.apis.SourceApiController;
import io.airbyte.server.apis.SourceDefinitionApiController;
import io.airbyte.server.apis.binders.AttemptApiBinder;
import io.airbyte.server.apis.binders.ConnectionApiBinder;
import io.airbyte.server.apis.binders.DbMigrationBinder;
Expand All @@ -43,6 +45,8 @@
import io.airbyte.server.apis.binders.OpenapiApiBinder;
import io.airbyte.server.apis.binders.OperationApiBinder;
import io.airbyte.server.apis.binders.SchedulerApiBinder;
import io.airbyte.server.apis.binders.SourceApiBinder;
import io.airbyte.server.apis.binders.SourceDefinitionApiBinder;
import io.airbyte.server.apis.binders.SourceOauthApiBinder;
import io.airbyte.server.apis.factories.AttemptApiFactory;
import io.airbyte.server.apis.factories.ConnectionApiFactory;
Expand All @@ -58,6 +62,8 @@
import io.airbyte.server.apis.factories.OpenapiApiFactory;
import io.airbyte.server.apis.factories.OperationApiFactory;
import io.airbyte.server.apis.factories.SchedulerApiFactory;
import io.airbyte.server.apis.factories.SourceApiFactory;
import io.airbyte.server.apis.factories.SourceDefinitionApiFactory;
import io.airbyte.server.apis.factories.SourceOauthApiFactory;
import io.airbyte.server.handlers.AttemptHandler;
import io.airbyte.server.handlers.ConnectionsHandler;
Expand All @@ -71,6 +77,8 @@
import io.airbyte.server.handlers.OpenApiConfigHandler;
import io.airbyte.server.handlers.OperationsHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import io.airbyte.server.handlers.SourceDefinitionsHandler;
import io.airbyte.server.handlers.SourceHandler;
import io.airbyte.server.handlers.WorkspacesHandler;
import io.airbyte.server.scheduler.EventRunner;
import io.airbyte.server.scheduler.SynchronousSchedulerClient;
Expand Down Expand Up @@ -111,6 +119,8 @@ ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClien
final OpenApiConfigHandler openApiConfigHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler,
final SourceHandler sourceHandler,
final SourceDefinitionsHandler sourceDefinitionsHandler,
final WorkspacesHandler workspacesHandler);

class Api implements ServerFactory {
Expand Down Expand Up @@ -144,6 +154,8 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
final OpenApiConfigHandler openApiConfigHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler,
final SourceHandler sourceHandler,
final SourceDefinitionsHandler sourceDefinitionsHandler,
final WorkspacesHandler workspacesHandler) {
final Map<String, String> mdc = MDC.getCopyOfContextMap();

Expand Down Expand Up @@ -202,6 +214,10 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

SchedulerApiFactory.setValues(schedulerHandler);

SourceApiFactory.setValues(schedulerHandler, sourceHandler);

SourceDefinitionApiFactory.setValues(sourceDefinitionsHandler);

// server configurations
final Set<Class<?>> componentClasses = Set.of(
ConfigurationApi.class,
Expand All @@ -219,6 +235,8 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
OpenapiApiController.class,
OperationApiController.class,
SchedulerApiController.class,
SourceApiController.class,
SourceDefinitionApiController.class,
SourceOauthApiFactory.class);

final Set<Object> components = Set.of(
Expand All @@ -238,6 +256,8 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new OpenapiApiBinder(),
new OperationApiBinder(),
new SchedulerApiBinder(),
new SourceApiBinder(),
new SourceDefinitionApiBinder(),
new SourceOauthApiBinder());

// construct server
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,85 +281,132 @@ public NotificationRead tryNotificationConfig(final Notification notification) {

// SOURCE

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionReadList listSourceDefinitions() {
return execute(sourceDefinitionsHandler::listSourceDefinitions);
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionReadList listSourceDefinitionsForWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) {
return execute(() -> sourceDefinitionsHandler.listSourceDefinitionsForWorkspace(workspaceIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionReadList listLatestSourceDefinitions() {
return execute(sourceDefinitionsHandler::listLatestSourceDefinitions);
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public PrivateSourceDefinitionReadList listPrivateSourceDefinitions(final WorkspaceIdRequestBody workspaceIdRequestBody) {
return execute(() -> sourceDefinitionsHandler.listPrivateSourceDefinitions(workspaceIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead getSourceDefinition(final SourceDefinitionIdRequestBody sourceDefinitionIdRequestBody) {
return execute(() -> sourceDefinitionsHandler.getSourceDefinition(sourceDefinitionIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead getSourceDefinitionForWorkspace(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) {
return execute(() -> sourceDefinitionsHandler.getSourceDefinitionForWorkspace(sourceDefinitionIdWithWorkspaceId));
throw new NotImplementedException();
}

// TODO: Deprecate this route in favor of createCustomSourceDefinition
// since all connector definitions created through the API are custom
/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead createSourceDefinition(final SourceDefinitionCreate sourceDefinitionCreate) {
return execute(() -> sourceDefinitionsHandler.createPrivateSourceDefinition(sourceDefinitionCreate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead createCustomSourceDefinition(final CustomSourceDefinitionCreate customSourceDefinitionCreate) {
return execute(() -> sourceDefinitionsHandler.createCustomSourceDefinition(customSourceDefinitionCreate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead updateSourceDefinition(final SourceDefinitionUpdate sourceDefinitionUpdate) {
return execute(() -> sourceDefinitionsHandler.updateSourceDefinition(sourceDefinitionUpdate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public SourceDefinitionRead updateCustomSourceDefinition(final CustomSourceDefinitionUpdate customSourceDefinitionUpdate) {
return execute(() -> sourceDefinitionsHandler.updateCustomSourceDefinition(customSourceDefinitionUpdate));
throw new NotImplementedException();
}

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

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

/**
* This implementation has been moved to {@link SourceDefinitionApiController}. Since the path of
* {@link SourceDefinitionApiController} is more granular, it will override this implementation
*/
@Override
public PrivateSourceDefinitionRead grantSourceDefinitionToWorkspace(final SourceDefinitionIdWithWorkspaceId sourceDefinitionIdWithWorkspaceId) {
return execute(() -> sourceDefinitionsHandler.grantSourceDefinitionToWorkspace(sourceDefinitionIdWithWorkspaceId));
throw new NotImplementedException();
}

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

// SOURCE SPECIFICATION
Expand Down Expand Up @@ -436,57 +483,94 @@ public InternalOperationResult setWorkflowInAttempt(final SetWorkflowInAttemptRe

// SOURCE IMPLEMENTATION

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceRead createSource(final SourceCreate sourceCreate) {
return execute(() -> sourceHandler.createSource(sourceCreate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceRead updateSource(final SourceUpdate sourceUpdate) {
return execute(() -> sourceHandler.updateSource(sourceUpdate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceReadList listSourcesForWorkspace(final WorkspaceIdRequestBody workspaceIdRequestBody) {
return execute(() -> sourceHandler.listSourcesForWorkspace(workspaceIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceReadList searchSources(final SourceSearch sourceSearch) {
return execute(() -> sourceHandler.searchSources(sourceSearch));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceRead getSource(final SourceIdRequestBody sourceIdRequestBody) {
return execute(() -> sourceHandler.getSource(sourceIdRequestBody));
throw new NotImplementedException();
}

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

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceRead cloneSource(final SourceCloneRequestBody sourceCloneRequestBody) {
return execute(() -> sourceHandler.cloneSource(sourceCloneRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public CheckConnectionRead checkConnectionToSource(final SourceIdRequestBody sourceIdRequestBody) {
return execute(() -> schedulerHandler.checkSourceConnectionFromSourceId(sourceIdRequestBody));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public CheckConnectionRead checkConnectionToSourceForUpdate(final SourceUpdate sourceUpdate) {
return execute(() -> schedulerHandler.checkSourceConnectionFromSourceIdForUpdate(sourceUpdate));
throw new NotImplementedException();
}

/**
* This implementation has been moved to {@link SourceApiController}. Since the path of
* {@link SourceApiController} is more granular, it will override this implementation
*/
@Override
public SourceDiscoverSchemaRead discoverSchemaForSource(final SourceDiscoverSchemaRequestBody discoverSchemaRequestBody) {
return execute(() -> schedulerHandler.discoverSchemaForSourceFromSourceId(discoverSchemaRequestBody));
throw new NotImplementedException();
}

// DB MIGRATION
Expand Down
Loading