Extract OAuth API (#18818)
* 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. * tmp * Fix PMD errors * Extract DB migrator * Add something that I forgot * extract destination definition api * restore destination factory initialization * extract destination definition specification api * format * format * format * extract health check api * extract jobs api * fix test * format * Extract logs api * Add missing declaration * Fix build * Tmp * format and PR comments * Extract notification API * re-organize tags * Extract all Oauth * Fix PMD
This commit is contained in:
@@ -37,7 +37,6 @@ public class ConfigurationApiFactory implements Factory<ConfigurationApi> {
|
||||
private static WorkerEnvironment workerEnvironment;
|
||||
private static LogConfigs logConfigs;
|
||||
private static AirbyteVersion airbyteVersion;
|
||||
private static HttpClient httpClient;
|
||||
private static EventRunner eventRunner;
|
||||
|
||||
public static void setValues(
|
||||
@@ -69,7 +68,6 @@ public class ConfigurationApiFactory implements Factory<ConfigurationApi> {
|
||||
ConfigurationApiFactory.workerEnvironment = workerEnvironment;
|
||||
ConfigurationApiFactory.logConfigs = logConfigs;
|
||||
ConfigurationApiFactory.airbyteVersion = airbyteVersion;
|
||||
ConfigurationApiFactory.httpClient = httpClient;
|
||||
ConfigurationApiFactory.eventRunner = eventRunner;
|
||||
ConfigurationApiFactory.statePersistence = statePersistence;
|
||||
}
|
||||
@@ -89,7 +87,6 @@ public class ConfigurationApiFactory implements Factory<ConfigurationApi> {
|
||||
ConfigurationApiFactory.workerEnvironment,
|
||||
ConfigurationApiFactory.logConfigs,
|
||||
ConfigurationApiFactory.airbyteVersion,
|
||||
ConfigurationApiFactory.httpClient,
|
||||
ConfigurationApiFactory.eventRunner);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,7 @@ import io.airbyte.server.handlers.DestinationHandler;
|
||||
import io.airbyte.server.handlers.HealthCheckHandler;
|
||||
import io.airbyte.server.handlers.JobHistoryHandler;
|
||||
import io.airbyte.server.handlers.LogsHandler;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import io.airbyte.server.handlers.OperationsHandler;
|
||||
import io.airbyte.server.handlers.SchedulerHandler;
|
||||
import io.airbyte.server.handlers.SourceDefinitionsHandler;
|
||||
@@ -301,6 +302,8 @@ public class ServerApp implements ServerRunnable {
|
||||
|
||||
final HealthCheckHandler healthCheckHandler = new HealthCheckHandler(configRepository);
|
||||
|
||||
final OAuthHandler oAuthHandler = new OAuthHandler(configRepository, httpClient, trackingClient);
|
||||
|
||||
final SourceHandler sourceHandler = new SourceHandler(
|
||||
configRepository,
|
||||
secretsRepositoryReader,
|
||||
@@ -357,6 +360,7 @@ public class ServerApp implements ServerRunnable {
|
||||
healthCheckHandler,
|
||||
jobHistoryHandler,
|
||||
logsHandler,
|
||||
oAuthHandler,
|
||||
operationsHandler,
|
||||
schedulerHandler,
|
||||
workspacesHandler);
|
||||
|
||||
@@ -21,6 +21,7 @@ import io.airbyte.server.apis.DbMigrationApiController;
|
||||
import io.airbyte.server.apis.DestinationApiController;
|
||||
import io.airbyte.server.apis.DestinationDefinitionApiController;
|
||||
import io.airbyte.server.apis.DestinationDefinitionSpecificationApiController;
|
||||
import io.airbyte.server.apis.DestinationOauthApiController;
|
||||
import io.airbyte.server.apis.HealthApiController;
|
||||
import io.airbyte.server.apis.JobsApiController;
|
||||
import io.airbyte.server.apis.LogsApiController;
|
||||
@@ -31,20 +32,24 @@ import io.airbyte.server.apis.binders.DbMigrationBinder;
|
||||
import io.airbyte.server.apis.binders.DestinationApiBinder;
|
||||
import io.airbyte.server.apis.binders.DestinationDefinitionApiBinder;
|
||||
import io.airbyte.server.apis.binders.DestinationDefinitionSpecificationApiBinder;
|
||||
import io.airbyte.server.apis.binders.DestinationOauthApiBinder;
|
||||
import io.airbyte.server.apis.binders.HealthApiBinder;
|
||||
import io.airbyte.server.apis.binders.JobsApiBinder;
|
||||
import io.airbyte.server.apis.binders.LogsApiBinder;
|
||||
import io.airbyte.server.apis.binders.NotificationApiBinder;
|
||||
import io.airbyte.server.apis.binders.SourceOauthApiBinder;
|
||||
import io.airbyte.server.apis.factories.AttemptApiFactory;
|
||||
import io.airbyte.server.apis.factories.ConnectionApiFactory;
|
||||
import io.airbyte.server.apis.factories.DbMigrationApiFactory;
|
||||
import io.airbyte.server.apis.factories.DestinationApiFactory;
|
||||
import io.airbyte.server.apis.factories.DestinationDefinitionApiFactory;
|
||||
import io.airbyte.server.apis.factories.DestinationDefinitionSpecificationApiFactory;
|
||||
import io.airbyte.server.apis.factories.DestinationOauthApiFactory;
|
||||
import io.airbyte.server.apis.factories.HealthApiFactory;
|
||||
import io.airbyte.server.apis.factories.JobsApiFactory;
|
||||
import io.airbyte.server.apis.factories.LogsApiFactory;
|
||||
import io.airbyte.server.apis.factories.NotificationsApiFactory;
|
||||
import io.airbyte.server.apis.factories.SourceOauthApiFactory;
|
||||
import io.airbyte.server.handlers.AttemptHandler;
|
||||
import io.airbyte.server.handlers.ConnectionsHandler;
|
||||
import io.airbyte.server.handlers.DbMigrationHandler;
|
||||
@@ -53,6 +58,7 @@ import io.airbyte.server.handlers.DestinationHandler;
|
||||
import io.airbyte.server.handlers.HealthCheckHandler;
|
||||
import io.airbyte.server.handlers.JobHistoryHandler;
|
||||
import io.airbyte.server.handlers.LogsHandler;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import io.airbyte.server.handlers.OperationsHandler;
|
||||
import io.airbyte.server.handlers.SchedulerHandler;
|
||||
import io.airbyte.server.handlers.WorkspacesHandler;
|
||||
@@ -91,6 +97,7 @@ public interface ServerFactory {
|
||||
final HealthCheckHandler healthCheckHandler,
|
||||
final JobHistoryHandler jobHistoryHandler,
|
||||
final LogsHandler logsHandler,
|
||||
final OAuthHandler oAuthHandler,
|
||||
final OperationsHandler operationsHandler,
|
||||
final SchedulerHandler schedulerHandler,
|
||||
final WorkspacesHandler workspacesHandler);
|
||||
@@ -122,6 +129,7 @@ public interface ServerFactory {
|
||||
final HealthCheckHandler healthCheckHandler,
|
||||
final JobHistoryHandler jobHistoryHandler,
|
||||
final LogsHandler logsHandler,
|
||||
final OAuthHandler oAuthHandler,
|
||||
final OperationsHandler operationsHandler,
|
||||
final SchedulerHandler schedulerHandler,
|
||||
final WorkspacesHandler workspacesHandler) {
|
||||
@@ -166,6 +174,10 @@ public interface ServerFactory {
|
||||
|
||||
HealthApiFactory.setValues(healthCheckHandler);
|
||||
|
||||
DestinationOauthApiFactory.setValues(oAuthHandler);
|
||||
|
||||
SourceOauthApiFactory.setValues(oAuthHandler);
|
||||
|
||||
JobsApiFactory.setValues(jobHistoryHandler, schedulerHandler);
|
||||
|
||||
LogsApiFactory.setValues(logsHandler);
|
||||
@@ -181,10 +193,12 @@ public interface ServerFactory {
|
||||
DestinationApiController.class,
|
||||
DestinationDefinitionApiController.class,
|
||||
DestinationDefinitionSpecificationApiController.class,
|
||||
DestinationOauthApiController.class,
|
||||
HealthApiController.class,
|
||||
JobsApiController.class,
|
||||
LogsApiController.class,
|
||||
NotificationsApiController.class);
|
||||
NotificationsApiController.class,
|
||||
SourceOauthApiFactory.class);
|
||||
|
||||
final Set<Object> components = Set.of(
|
||||
new CorsFilter(),
|
||||
@@ -195,10 +209,12 @@ public interface ServerFactory {
|
||||
new DestinationApiBinder(),
|
||||
new DestinationDefinitionApiBinder(),
|
||||
new DestinationDefinitionSpecificationApiBinder(),
|
||||
new DestinationOauthApiBinder(),
|
||||
new HealthApiBinder(),
|
||||
new JobsApiBinder(),
|
||||
new LogsApiBinder(),
|
||||
new NotificationApiBinder());
|
||||
new NotificationApiBinder(),
|
||||
new SourceOauthApiBinder());
|
||||
|
||||
// construct server
|
||||
return new ServerApp(airbyteVersion, componentClasses, components);
|
||||
|
||||
@@ -117,7 +117,6 @@ import io.airbyte.server.handlers.ConnectionsHandler;
|
||||
import io.airbyte.server.handlers.DestinationDefinitionsHandler;
|
||||
import io.airbyte.server.handlers.DestinationHandler;
|
||||
import io.airbyte.server.handlers.JobHistoryHandler;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import io.airbyte.server.handlers.OpenApiConfigHandler;
|
||||
import io.airbyte.server.handlers.OperationsHandler;
|
||||
import io.airbyte.server.handlers.SchedulerHandler;
|
||||
@@ -133,7 +132,6 @@ import io.airbyte.validation.json.JsonSchemaValidator;
|
||||
import io.airbyte.validation.json.JsonValidationException;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.http.HttpClient;
|
||||
import java.util.Map;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
@@ -155,7 +153,6 @@ public class ConfigurationApi implements io.airbyte.api.generated.V1Api {
|
||||
private final WebBackendConnectionsHandler webBackendConnectionsHandler;
|
||||
private final WebBackendGeographiesHandler webBackendGeographiesHandler;
|
||||
private final OpenApiConfigHandler openApiConfigHandler;
|
||||
private final OAuthHandler oAuthHandler;
|
||||
|
||||
public ConfigurationApi(final ConfigRepository configRepository,
|
||||
final JobPersistence jobPersistence,
|
||||
@@ -167,7 +164,6 @@ public class ConfigurationApi implements io.airbyte.api.generated.V1Api {
|
||||
final WorkerEnvironment workerEnvironment,
|
||||
final LogConfigs logConfigs,
|
||||
final AirbyteVersion airbyteVersion,
|
||||
final HttpClient httpClient,
|
||||
final EventRunner eventRunner) {
|
||||
|
||||
final JsonSchemaValidator schemaValidator = new JsonSchemaValidator();
|
||||
@@ -215,7 +211,6 @@ public class ConfigurationApi implements io.airbyte.api.generated.V1Api {
|
||||
sourceHandler);
|
||||
jobHistoryHandler = new JobHistoryHandler(jobPersistence, workerEnvironment, logConfigs, connectionsHandler, sourceHandler,
|
||||
sourceDefinitionsHandler, destinationHandler, destinationDefinitionsHandler, airbyteVersion);
|
||||
oAuthHandler = new OAuthHandler(configRepository, httpClient, trackingClient);
|
||||
webBackendConnectionsHandler = new WebBackendConnectionsHandler(
|
||||
connectionsHandler,
|
||||
stateHandler,
|
||||
@@ -379,40 +374,58 @@ public class ConfigurationApi implements io.airbyte.api.generated.V1Api {
|
||||
|
||||
// OAUTH
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link SourceOauthApiController}. Since the path of
|
||||
* {@link SourceOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public OAuthConsentRead getSourceOAuthConsent(final SourceOauthConsentRequest sourceOauthConsentRequest) {
|
||||
return execute(() -> oAuthHandler.getSourceOAuthConsent(sourceOauthConsentRequest));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link SourceOauthApiController}. Since the path of
|
||||
* {@link SourceOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> completeSourceOAuth(final CompleteSourceOauthRequest completeSourceOauthRequest) {
|
||||
return execute(() -> oAuthHandler.completeSourceOAuth(completeSourceOauthRequest));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link DestinationOauthApiController}. Since the path of
|
||||
* {@link DestinationOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public OAuthConsentRead getDestinationOAuthConsent(final DestinationOauthConsentRequest destinationOauthConsentRequest) {
|
||||
return execute(() -> oAuthHandler.getDestinationOAuthConsent(destinationOauthConsentRequest));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link DestinationOauthApiController}. Since the path of
|
||||
* {@link DestinationOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Object> completeDestinationOAuth(final CompleteDestinationOAuthRequest requestBody) {
|
||||
return execute(() -> oAuthHandler.completeDestinationOAuth(requestBody));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link DestinationOauthApiController}. Since the path of
|
||||
* {@link DestinationOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public void setInstancewideDestinationOauthParams(final SetInstancewideDestinationOauthParamsRequestBody requestBody) {
|
||||
execute(() -> {
|
||||
oAuthHandler.setDestinationInstancewideOauthParams(requestBody);
|
||||
return null;
|
||||
});
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
* This implementation has been moved to {@link SourceOauthApiController}. Since the path of
|
||||
* {@link SourceOauthApiController} is more granular, it will override this implementation
|
||||
*/
|
||||
@Override
|
||||
public void setInstancewideSourceOauthParams(final SetInstancewideSourceOauthParamsRequestBody requestBody) {
|
||||
execute(() -> {
|
||||
oAuthHandler.setSourceInstancewideOauthParams(requestBody);
|
||||
return null;
|
||||
});
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis;
|
||||
|
||||
import io.airbyte.api.generated.DestinationOauthApi;
|
||||
import io.airbyte.api.model.generated.CompleteDestinationOAuthRequest;
|
||||
import io.airbyte.api.model.generated.DestinationOauthConsentRequest;
|
||||
import io.airbyte.api.model.generated.OAuthConsentRead;
|
||||
import io.airbyte.api.model.generated.SetInstancewideDestinationOauthParamsRequestBody;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.Path;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Path("/v1/destination_oauths")
|
||||
@AllArgsConstructor
|
||||
public class DestinationOauthApiController implements DestinationOauthApi {
|
||||
|
||||
private final OAuthHandler oAuthHandler;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> completeDestinationOAuth(final CompleteDestinationOAuthRequest completeDestinationOAuthRequest) {
|
||||
return ConfigurationApi.execute(() -> oAuthHandler.completeDestinationOAuth(completeDestinationOAuthRequest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuthConsentRead getDestinationOAuthConsent(final DestinationOauthConsentRequest destinationOauthConsentRequest) {
|
||||
return ConfigurationApi.execute(() -> oAuthHandler.getDestinationOAuthConsent(destinationOauthConsentRequest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstancewideDestinationOauthParams(final SetInstancewideDestinationOauthParamsRequestBody setInstancewideDestinationOauthParamsRequestBody) {
|
||||
ConfigurationApi.execute(() -> {
|
||||
oAuthHandler.setDestinationInstancewideOauthParams(setInstancewideDestinationOauthParamsRequestBody);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis;
|
||||
|
||||
import io.airbyte.api.generated.SourceOauthApi;
|
||||
import io.airbyte.api.model.generated.CompleteSourceOauthRequest;
|
||||
import io.airbyte.api.model.generated.OAuthConsentRead;
|
||||
import io.airbyte.api.model.generated.SetInstancewideSourceOauthParamsRequestBody;
|
||||
import io.airbyte.api.model.generated.SourceOauthConsentRequest;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import java.util.Map;
|
||||
import javax.ws.rs.Path;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@Path("/v1/source_oauths")
|
||||
@AllArgsConstructor
|
||||
public class SourceOauthApiController implements SourceOauthApi {
|
||||
|
||||
private final OAuthHandler oAuthHandler;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> completeSourceOAuth(final CompleteSourceOauthRequest completeSourceOauthRequest) {
|
||||
return ConfigurationApi.execute(() -> oAuthHandler.completeSourceOAuth(completeSourceOauthRequest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuthConsentRead getSourceOAuthConsent(final SourceOauthConsentRequest sourceOauthConsentRequest) {
|
||||
return ConfigurationApi.execute(() -> oAuthHandler.getSourceOAuthConsent(sourceOauthConsentRequest));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInstancewideSourceOauthParams(final SetInstancewideSourceOauthParamsRequestBody setInstancewideSourceOauthParamsRequestBody) {
|
||||
ConfigurationApi.execute(() -> {
|
||||
oAuthHandler.setSourceInstancewideOauthParams(setInstancewideSourceOauthParamsRequestBody);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis.binders;
|
||||
|
||||
import io.airbyte.server.apis.DestinationOauthApiController;
|
||||
import io.airbyte.server.apis.factories.DestinationOauthApiFactory;
|
||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
||||
import org.glassfish.jersey.process.internal.RequestScoped;
|
||||
|
||||
public class DestinationOauthApiBinder extends AbstractBinder {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindFactory(DestinationOauthApiFactory.class)
|
||||
.to(DestinationOauthApiController.class)
|
||||
.in(RequestScoped.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis.binders;
|
||||
|
||||
import io.airbyte.server.apis.SourceOauthApiController;
|
||||
import io.airbyte.server.apis.factories.SourceOauthApiFactory;
|
||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
||||
import org.glassfish.jersey.process.internal.RequestScoped;
|
||||
|
||||
public class SourceOauthApiBinder extends AbstractBinder {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindFactory(SourceOauthApiFactory.class)
|
||||
.to(SourceOauthApiController.class)
|
||||
.in(RequestScoped.class);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis.factories;
|
||||
|
||||
import io.airbyte.server.apis.DestinationOauthApiController;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class DestinationOauthApiFactory implements Factory<DestinationOauthApiController> {
|
||||
|
||||
private static OAuthHandler oAuthHandler;
|
||||
|
||||
public static void setValues(final OAuthHandler oAuthHandler) {
|
||||
DestinationOauthApiFactory.oAuthHandler = oAuthHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationOauthApiController provide() {
|
||||
return new DestinationOauthApiController(oAuthHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(final DestinationOauthApiController instance) {
|
||||
/* no op */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
|
||||
*/
|
||||
|
||||
package io.airbyte.server.apis.factories;
|
||||
|
||||
import io.airbyte.server.apis.SourceOauthApiController;
|
||||
import io.airbyte.server.handlers.OAuthHandler;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
public class SourceOauthApiFactory implements Factory<SourceOauthApiController> {
|
||||
|
||||
private static OAuthHandler oAuthHandler;
|
||||
|
||||
public static void setValues(final OAuthHandler oAuthHandler) {
|
||||
SourceOauthApiFactory.oAuthHandler = oAuthHandler;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SourceOauthApiController provide() {
|
||||
return new SourceOauthApiController(SourceOauthApiFactory.oAuthHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(final SourceOauthApiController instance) {
|
||||
/* no op */
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user