Skip to content

Commit 89b7740

Browse files
authored
Revert "Revert "Remove configuration API (#18998)" (#19440)" (#19443)
* Revert "Revert "Remove configuration API (#18998)" (#19440)" This reverts commit 3d0a9de. * Re add parameters needed by cloud
1 parent f59709e commit 89b7740

25 files changed

+138
-1278
lines changed

airbyte-server/src/main/java/io/airbyte/server/ConfigurationApiBinder.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

airbyte-server/src/main/java/io/airbyte/server/ConfigurationApiFactory.java

Lines changed: 0 additions & 33 deletions
This file was deleted.

airbyte-server/src/main/java/io/airbyte/server/ServerFactory.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import io.airbyte.db.Database;
1515
import io.airbyte.persistence.job.JobPersistence;
1616
import io.airbyte.server.apis.AttemptApiController;
17-
import io.airbyte.server.apis.ConfigurationApi;
1817
import io.airbyte.server.apis.ConnectionApiController;
1918
import io.airbyte.server.apis.DbMigrationApiController;
2019
import io.airbyte.server.apis.DestinationApiController;
@@ -180,9 +179,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
180179
final WebBackendGeographiesHandler webBackendGeographiesHandler) {
181180
final Map<String, String> mdc = MDC.getCopyOfContextMap();
182181

183-
// set static values for factory
184-
ConfigurationApiFactory.setValues(mdc);
185-
186182
AttemptApiFactory.setValues(attemptHandler, mdc);
187183

188184
ConnectionApiFactory.setValues(
@@ -231,7 +227,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
231227

232228
// server configurations
233229
final Set<Class<?>> componentClasses = Set.of(
234-
ConfigurationApi.class,
235230
AttemptApiController.class,
236231
ConnectionApiController.class,
237232
DbMigrationApiController.class,
@@ -256,7 +251,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
256251

257252
final Set<Object> components = Set.of(
258253
new CorsFilter(),
259-
new ConfigurationApiBinder(),
260254
new AttemptApiBinder(),
261255
new ConnectionApiBinder(),
262256
new DbMigrationBinder(),
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2022 Airbyte, Inc., all rights reserved.
3+
*/
4+
5+
package io.airbyte.server.apis;
6+
7+
import io.airbyte.config.persistence.ConfigNotFoundException;
8+
import io.airbyte.server.errors.BadObjectSchemaKnownException;
9+
import io.airbyte.server.errors.IdNotFoundKnownException;
10+
import io.airbyte.validation.json.JsonValidationException;
11+
import java.io.IOException;
12+
13+
public class ApiHelper {
14+
15+
static <T> T execute(final HandlerCall<T> call) {
16+
try {
17+
return call.call();
18+
} catch (final ConfigNotFoundException e) {
19+
throw new IdNotFoundKnownException(String.format("Could not find configuration for %s: %s.", e.getType(), e.getConfigId()),
20+
e.getConfigId(), e);
21+
} catch (final JsonValidationException e) {
22+
throw new BadObjectSchemaKnownException(
23+
String.format("The provided configuration does not fulfill the specification. Errors: %s", e.getMessage()), e);
24+
} catch (final IOException e) {
25+
throw new RuntimeException(e);
26+
}
27+
}
28+
29+
interface HandlerCall<T> {
30+
31+
T call() throws ConfigNotFoundException, IOException, JsonValidationException;
32+
33+
}
34+
35+
}

airbyte-server/src/main/java/io/airbyte/server/apis/AttemptApiController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public InternalOperationResult saveStats(final SaveStatsRequestBody saveStatsReq
2727

2828
@Override
2929
public InternalOperationResult setWorkflowInAttempt(final SetWorkflowInAttemptRequestBody requestBody) {
30-
return ConfigurationApi.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
30+
return ApiHelper.execute(() -> attemptHandler.setWorkflowInAttempt(requestBody));
3131
}
3232

3333
}

0 commit comments

Comments
 (0)