Skip to content
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

convert openapiapicontroller to micronaut #20258

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
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ http {
}
}

location /api/v1/health {
location ~ ^/api/v1/(health|openapi) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down Expand Up @@ -76,7 +76,7 @@ http {
}
}

location /api/v1/health {
location ~ ^/api/v1/(health|openapi) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
4 changes: 2 additions & 2 deletions airbyte-proxy/nginx-no-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ http {
proxy_pass "${PROXY_PASS_WEB}";
}

location /api/v1/health {
location ~ ^/api/v1/(health|openapi) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down Expand Up @@ -40,7 +40,7 @@ http {
proxy_pass "${PROXY_PASS_API}";
}

location /api/v1/health {
location ~ ^/api/v1/(health|openapi) {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ public class EventListener {
public void startEmitters(final ApplicationStartupEvent event) {
try {
/*
In order to have a smooth transition to micronaut for the server, we are starting 2 server. One managed by glassfish (legacy), one by
micronaut. Once all the controller are migrated, this will go away.
* In order to have a smooth transition to micronaut for the server, we are starting 2 server. One
* managed by glassfish (legacy), one by micronaut. Once all the controller are migrated, this will
* go away.
*/
final Configs configs = new EnvConfigs();

Expand Down
4 changes: 0 additions & 4 deletions airbyte-server/src/main/java/io/airbyte/server/ServerApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.LogsHandler;
import io.airbyte.server.handlers.OAuthHandler;
import io.airbyte.server.handlers.OpenApiConfigHandler;
import io.airbyte.server.handlers.OperationsHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import io.airbyte.server.handlers.SourceDefinitionsHandler;
Expand Down Expand Up @@ -322,8 +321,6 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
destinationHandler,
sourceHandler);

final OpenApiConfigHandler openApiConfigHandler = new OpenApiConfigHandler();

final StatePersistence statePersistence = new StatePersistence(configsDatabase);

final StateHandler stateHandler = new StateHandler(statePersistence);
Expand Down Expand Up @@ -369,7 +366,6 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
jobHistoryHandler,
logsHandler,
oAuthHandler,
openApiConfigHandler,
operationsHandler,
schedulerHandler,
sourceHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.airbyte.config.persistence.SecretsRepositoryWriter;
import io.airbyte.db.Database;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.server.apis.ConnectionApiController;
import io.airbyte.server.apis.DbMigrationApiController;
import io.airbyte.server.apis.DestinationApiController;
import io.airbyte.server.apis.DestinationDefinitionApiController;
Expand All @@ -40,7 +39,6 @@
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.OpenapiApiBinder;
import io.airbyte.server.apis.binders.OperationApiBinder;
import io.airbyte.server.apis.binders.SchedulerApiBinder;
import io.airbyte.server.apis.binders.SourceApiBinder;
Expand All @@ -58,7 +56,6 @@
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.OpenapiApiFactory;
import io.airbyte.server.apis.factories.OperationApiFactory;
import io.airbyte.server.apis.factories.SchedulerApiFactory;
import io.airbyte.server.apis.factories.SourceApiFactory;
Expand All @@ -77,7 +74,6 @@
import io.airbyte.server.handlers.JobHistoryHandler;
import io.airbyte.server.handlers.LogsHandler;
import io.airbyte.server.handlers.OAuthHandler;
import io.airbyte.server.handlers.OpenApiConfigHandler;
import io.airbyte.server.handlers.OperationsHandler;
import io.airbyte.server.handlers.SchedulerHandler;
import io.airbyte.server.handlers.SourceDefinitionsHandler;
Expand Down Expand Up @@ -122,7 +118,6 @@ ServerRunnable create(final SynchronousSchedulerClient synchronousSchedulerClien
final JobHistoryHandler jobHistoryHandler,
final LogsHandler logsHandler,
final OAuthHandler oAuthHandler,
final OpenApiConfigHandler openApiConfigHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler,
final SourceHandler sourceHandler,
Expand Down Expand Up @@ -160,7 +155,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
final JobHistoryHandler jobHistoryHandler,
final LogsHandler logsHandler,
final OAuthHandler oAuthHandler,
final OpenApiConfigHandler openApiConfigHandler,
final OperationsHandler operationsHandler,
final SchedulerHandler schedulerHandler,
final SourceHandler sourceHandler,
Expand Down Expand Up @@ -191,8 +185,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul

OperationApiFactory.setValues(operationsHandler);

OpenapiApiFactory.setValues(openApiConfigHandler);

SchedulerApiFactory.setValues(schedulerHandler);

SourceApiFactory.setValues(schedulerHandler, sourceHandler);
Expand Down Expand Up @@ -237,7 +229,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
new JobsApiBinder(),
new LogsApiBinder(),
new NotificationApiBinder(),
new OpenapiApiBinder(),
new OperationApiBinder(),
new SchedulerApiBinder(),
new SourceApiBinder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,49 +40,49 @@ public ConnectionApiController(final ConnectionsHandler connectionsHandler,

@Override
@Post(uri = "/create",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionRead createConnection(@Body final ConnectionCreate connectionCreate) {
return ApiHelper.execute(() -> connectionsHandler.createConnection(connectionCreate));
}

@Override
@Post(uri = "/update",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionRead updateConnection(@Body final ConnectionUpdate connectionUpdate) {
return ApiHelper.execute(() -> connectionsHandler.updateConnection(connectionUpdate));
}

@Override
@Post(uri = "/list",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionReadList listConnectionsForWorkspace(@Body final WorkspaceIdRequestBody workspaceIdRequestBody) {
return ApiHelper.execute(() -> connectionsHandler.listConnectionsForWorkspace(workspaceIdRequestBody));
}

@Override
@Post(uri = "/list_all",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionReadList listAllConnectionsForWorkspace(@Body final WorkspaceIdRequestBody workspaceIdRequestBody) {
return ApiHelper.execute(() -> connectionsHandler.listAllConnectionsForWorkspace(workspaceIdRequestBody));
}

@Override
@Post(uri = "/search",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionReadList searchConnections(@Body final ConnectionSearch connectionSearch) {
return ApiHelper.execute(() -> connectionsHandler.searchConnections(connectionSearch));
}

@Override
@Post(uri = "/get",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public ConnectionRead getConnection(@Body final ConnectionIdRequestBody connectionIdRequestBody) {
return ApiHelper.execute(() -> connectionsHandler.getConnection(connectionIdRequestBody.getConnectionId()));
}

@Override
@Post(uri = "/delete",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public void deleteConnection(@Body final ConnectionIdRequestBody connectionIdRequestBody) {
ApiHelper.execute(() -> {
operationsHandler.deleteOperationsForConnection(connectionIdRequestBody);
Expand All @@ -93,14 +93,14 @@ public void deleteConnection(@Body final ConnectionIdRequestBody connectionIdReq

@Override
@Post(uri = "/sync",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public JobInfoRead syncConnection(@Body final ConnectionIdRequestBody connectionIdRequestBody) {
return ApiHelper.execute(() -> schedulerHandler.syncConnection(connectionIdRequestBody));
}

@Override
@Post(uri = "/reset",
processes = MediaType.APPLICATION_JSON)
processes = MediaType.APPLICATION_JSON)
public JobInfoRead resetConnection(@Body final ConnectionIdRequestBody connectionIdRequestBody) {
return ApiHelper.execute(() -> schedulerHandler.resetConnection(connectionIdRequestBody));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

import io.airbyte.api.generated.OpenapiApi;
import io.airbyte.server.handlers.OpenApiConfigHandler;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
import java.io.File;
import javax.ws.rs.Path;
import lombok.AllArgsConstructor;

@Path("/v1/openapi")
@AllArgsConstructor
@Controller("/api/v1/openapi")
public class OpenapiApiController implements OpenapiApi {

private final OpenApiConfigHandler openApiConfigHandler;

public OpenapiApiController(final OpenApiConfigHandler openApiConfigHandler) {
this.openApiConfigHandler = openApiConfigHandler;
}

@Get(produces = "text/plain")
@Override
public File getOpenApiSpec() {
return ApiHelper.execute(openApiConfigHandler::getFile);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.config;

import io.airbyte.analytics.TrackingClient;
Expand All @@ -11,8 +15,6 @@
import io.airbyte.config.persistence.ConfigRepository;
import io.airbyte.persistence.job.JobPersistence;
import io.airbyte.persistence.job.WebUrlHelper;
import io.airbyte.persistence.job.errorreporter.JobErrorReporter;
import io.airbyte.persistence.job.errorreporter.JobErrorReportingClient;
import io.airbyte.persistence.job.tracker.JobTracker;
import io.airbyte.server.scheduler.EventRunner;
import io.airbyte.server.scheduler.TemporalEventRunner;
Expand Down Expand Up @@ -60,9 +62,9 @@ public DeploymentMode deploymentMode(@Value("${airbyte.deployment-mode}") final
@Singleton
@Requires(env = WorkerMode.CONTROL_PLANE)
public JobTracker jobTracker(
final ConfigRepository configRepository,
final JobPersistence jobPersistence,
final TrackingClient trackingClient) {
final ConfigRepository configRepository,
final JobPersistence jobPersistence,
final TrackingClient trackingClient) {
return new JobTracker(configRepository, jobPersistence, trackingClient);
}

Expand All @@ -86,4 +88,5 @@ public Path workspaceRoot(@Value("${airbyte.workspace.root}") final String works
private <T> T convertToEnum(final String value, final Function<String, T> creatorFunction, final T defaultValue) {
return StringUtils.isNotEmpty(value) ? creatorFunction.apply(value.toUpperCase(Locale.ROOT)) : defaultValue;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,5 @@ public JobsDatabaseAvailabilityCheck jobsDatabaseAvailabilityCheck(@Named("confi
public StreamResetPersistence streamResetPersistence(@Named("configDatabase") final Database configDatabase) {
return new StreamResetPersistence(configDatabase);
}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.server.config;

import io.airbyte.config.persistence.ConfigRepository;
Expand All @@ -13,4 +17,5 @@ public class HelperBeanFactory {
public WorkspaceHelper workspaceHelper(final ConfigRepository configRepository, final JobPersistence jobPersistence) {
return new WorkspaceHelper(configRepository, jobPersistence);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public SecretPersistence localTestingSecretPersistence(@Named("configDatabase")

@Singleton
@Requires(property = "airbyte.secret.persistence",
pattern = "(?i)^testing_config_db_table$")
pattern = "(?i)^testing_config_db_table$")
@Requires(env = WorkerMode.CONTROL_PLANE)
@Named("ephemeralSecretPersistence")
public SecretPersistence ephemeralLocalTestingSecretPersistence(@Named("configDatabase") final Database configDatabase) {
Expand All @@ -71,10 +71,10 @@ public SecretPersistence googleSecretPersistence(@Value("${airbyte.secret.store.

@Singleton
@Requires(property = "airbyte.secret.persistence",
pattern = "(?i)^google_secret_manager$")
pattern = "(?i)^google_secret_manager$")
@Named("ephemeralSecretPersistence")
public SecretPersistence ephemeralGoogleSecretPersistence(@Value("${airbyte.secret.store.gcp.credentials}") final String credentials,
@Value("${airbyte.secret.store.gcp.project-id}") final String projectId) {
@Value("${airbyte.secret.store.gcp.project-id}") final String projectId) {
return GoogleSecretManagerPersistence.getEphemeral(projectId, credentials);
}

Expand All @@ -91,16 +91,15 @@ public SecretPersistence vaultSecretPersistence(@Value("${airbyte.secret.store.v

@Singleton
@Requires(property = "airbyte.secret.persistence",
pattern = "(?i)^vault$")
pattern = "(?i)^vault$")
@Requires(env = WorkerMode.CONTROL_PLANE)
@Named("ephemeralSecretPersistence")
public SecretPersistence ephemeralVaultSecretPersistence(@Value("${airbyte.secret.store.vault.address}") final String address,
@Value("${airbyte.secret.store.vault.prefix}") final String prefix,
@Value("${airbyte.secret.store.vault.token}") final String token) {
@Value("${airbyte.secret.store.vault.prefix}") final String prefix,
@Value("${airbyte.secret.store.vault.token}") final String token) {
return new VaultSecretPersistence(address, prefix, token);
}


@Singleton
@Requires(env = WorkerMode.CONTROL_PLANE)
public SecretsHydrator secretsHydrator(@Named("secretPersistence") final SecretPersistence secretPersistence) {
Expand Down
Loading