|
9 | 9 | import static io.airbyte.db.instance.configs.jooq.generated.Tables.ACTOR_DEFINITION_VERSION; |
10 | 10 | import static io.airbyte.db.instance.configs.jooq.generated.Tables.ACTOR_DEFINITION_WORKSPACE_GRANT; |
11 | 11 | import static io.airbyte.db.instance.configs.jooq.generated.Tables.CONNECTION; |
12 | | -import static io.airbyte.db.instance.configs.jooq.generated.Tables.DATAPLANE_GROUP; |
13 | 12 | import static io.airbyte.db.instance.configs.jooq.generated.Tables.WORKSPACE; |
14 | | -import static io.airbyte.db.instance.configs.jooq.generated.Tables.WORKSPACE_SERVICE_ACCOUNT; |
15 | 13 | import static io.airbyte.db.instance.jobs.jooq.generated.Tables.JOBS; |
16 | 14 | import static org.jooq.impl.DSL.asterisk; |
17 | 15 | import static org.jooq.impl.DSL.noCondition; |
|
28 | 26 | import io.airbyte.config.SourceConnection; |
29 | 27 | import io.airbyte.config.StandardSync; |
30 | 28 | import io.airbyte.config.StandardWorkspace; |
31 | | -import io.airbyte.config.WorkspaceServiceAccount; |
32 | 29 | import io.airbyte.config.secrets.SecretsRepositoryReader; |
33 | 30 | import io.airbyte.config.secrets.SecretsRepositoryWriter; |
34 | 31 | import io.airbyte.config.secrets.persistence.RuntimeSecretPersistence; |
|
53 | 50 | import java.io.IOException; |
54 | 51 | import java.lang.invoke.MethodHandles; |
55 | 52 | import java.time.OffsetDateTime; |
56 | | -import java.util.Collections; |
57 | 53 | import java.util.List; |
58 | 54 | import java.util.Optional; |
59 | 55 | import java.util.UUID; |
60 | 56 | import java.util.stream.Collectors; |
61 | 57 | import java.util.stream.Stream; |
62 | 58 | import org.jooq.Condition; |
63 | | -import org.jooq.DSLContext; |
64 | 59 | import org.jooq.JSONB; |
65 | 60 | import org.jooq.JoinType; |
66 | 61 | import org.jooq.Record; |
@@ -413,64 +408,6 @@ public int countDestinationsForWorkspace(final UUID workspaceId) throws IOExcept |
413 | 408 | .andNot(ACTOR.TOMBSTONE)).fetchOne().into(int.class); |
414 | 409 | } |
415 | 410 |
|
416 | | - /** |
417 | | - * Get workspace service account without secrets. |
418 | | - * |
419 | | - * @param workspaceId workspace id |
420 | | - * @return workspace service account |
421 | | - * @throws ConfigNotFoundException if the config does not exist |
422 | | - * @throws IOException if there is an issue while interacting with db. |
423 | | - */ |
424 | | - @Override |
425 | | - public WorkspaceServiceAccount getWorkspaceServiceAccountNoSecrets(final UUID workspaceId) throws IOException, ConfigNotFoundException { |
426 | | - // breaking the pattern of doing a list query, because we never want to list this resource without |
427 | | - // scoping by workspace id. |
428 | | - return database.query(ctx -> ctx.select(asterisk()).from(WORKSPACE_SERVICE_ACCOUNT) |
429 | | - .where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceId)) |
430 | | - .fetch()) |
431 | | - .map(DbConverter::buildWorkspaceServiceAccount) |
432 | | - .stream() |
433 | | - .findFirst() |
434 | | - .orElseThrow(() -> new ConfigNotFoundException(ConfigNotFoundType.WORKSPACE_SERVICE_ACCOUNT, workspaceId)); |
435 | | - } |
436 | | - |
437 | | - /** |
438 | | - * Write workspace service account with no secrets. |
439 | | - * |
440 | | - * @param workspaceServiceAccount workspace service account |
441 | | - * @throws IOException if there is an issue while interacting with db. |
442 | | - */ |
443 | | - @Override |
444 | | - public void writeWorkspaceServiceAccountNoSecrets(final WorkspaceServiceAccount workspaceServiceAccount) throws IOException { |
445 | | - database.transaction(ctx -> { |
446 | | - writeWorkspaceServiceAccount(Collections.singletonList(workspaceServiceAccount), ctx); |
447 | | - return null; |
448 | | - }); |
449 | | - } |
450 | | - |
451 | | - /** |
452 | | - * Get dataplane group name for the workspace. |
453 | | - * |
454 | | - * @param workspaceId workspace id |
455 | | - * @return dataplaneGroupName |
456 | | - * @throws IOException exception while interacting with the db |
457 | | - */ |
458 | | - @Override |
459 | | - public String getDataplaneGroupNameForWorkspace(final UUID workspaceId) throws IOException { |
460 | | - final List<String> dataplaneGroupName = database.query(ctx -> ctx.select(DATAPLANE_GROUP.NAME) |
461 | | - .from(WORKSPACE) |
462 | | - .join(DATAPLANE_GROUP) |
463 | | - .on(WORKSPACE.DATAPLANE_GROUP_ID.eq(DATAPLANE_GROUP.ID))) |
464 | | - .where(WORKSPACE.ID.eq(workspaceId)) |
465 | | - .fetchInto(String.class); |
466 | | - |
467 | | - if (dataplaneGroupName.isEmpty()) { |
468 | | - throw new RuntimeException(String.format("Dataplane group name wasn't resolved for workspaceId %s", |
469 | | - workspaceId)); |
470 | | - } |
471 | | - return dataplaneGroupName.getFirst(); |
472 | | - } |
473 | | - |
474 | 411 | /** |
475 | 412 | * Specialized query for efficiently determining eligibility for the Free Connector Program. If a |
476 | 413 | * workspace has at least one Alpha or Beta connector, users of that workspace will be prompted to |
@@ -540,43 +477,6 @@ public List<StandardWorkspace> listStandardWorkspacesWithIds(final List<UUID> wo |
540 | 477 | return listWorkspaceQuery(Optional.of(workspaceIds), includeTombstone).toList(); |
541 | 478 | } |
542 | 479 |
|
543 | | - /** |
544 | | - * Write workspace service account. |
545 | | - * |
546 | | - * @param configs list of workspace service account |
547 | | - * @param ctx database context |
548 | | - */ |
549 | | - private void writeWorkspaceServiceAccount(final List<WorkspaceServiceAccount> configs, final DSLContext ctx) { |
550 | | - final OffsetDateTime timestamp = OffsetDateTime.now(); |
551 | | - configs.forEach((workspaceServiceAccount) -> { |
552 | | - final boolean isExistingConfig = ctx.fetchExists(select() |
553 | | - .from(WORKSPACE_SERVICE_ACCOUNT) |
554 | | - .where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceServiceAccount.getWorkspaceId()))); |
555 | | - |
556 | | - if (isExistingConfig) { |
557 | | - ctx.update(WORKSPACE_SERVICE_ACCOUNT) |
558 | | - .set(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID, workspaceServiceAccount.getWorkspaceId()) |
559 | | - .set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_ID, workspaceServiceAccount.getServiceAccountId()) |
560 | | - .set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_EMAIL, workspaceServiceAccount.getServiceAccountEmail()) |
561 | | - .set(WORKSPACE_SERVICE_ACCOUNT.JSON_CREDENTIAL, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getJsonCredential()))) |
562 | | - .set(WORKSPACE_SERVICE_ACCOUNT.HMAC_KEY, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getHmacKey()))) |
563 | | - .set(WORKSPACE_SERVICE_ACCOUNT.UPDATED_AT, timestamp) |
564 | | - .where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceServiceAccount.getWorkspaceId())) |
565 | | - .execute(); |
566 | | - } else { |
567 | | - ctx.insertInto(WORKSPACE_SERVICE_ACCOUNT) |
568 | | - .set(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID, workspaceServiceAccount.getWorkspaceId()) |
569 | | - .set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_ID, workspaceServiceAccount.getServiceAccountId()) |
570 | | - .set(WORKSPACE_SERVICE_ACCOUNT.SERVICE_ACCOUNT_EMAIL, workspaceServiceAccount.getServiceAccountEmail()) |
571 | | - .set(WORKSPACE_SERVICE_ACCOUNT.JSON_CREDENTIAL, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getJsonCredential()))) |
572 | | - .set(WORKSPACE_SERVICE_ACCOUNT.HMAC_KEY, JSONB.valueOf(Jsons.serialize(workspaceServiceAccount.getHmacKey()))) |
573 | | - .set(WORKSPACE_SERVICE_ACCOUNT.CREATED_AT, timestamp) |
574 | | - .set(WORKSPACE_SERVICE_ACCOUNT.UPDATED_AT, timestamp) |
575 | | - .execute(); |
576 | | - } |
577 | | - }); |
578 | | - } |
579 | | - |
580 | 480 | /** |
581 | 481 | * Returns source with a given id. Does not contain secrets. To hydrate with secrets see { @link |
582 | 482 | * SourceService#getSourceConnectionWithSecrets(final UUID sourceId) }. |
|
0 commit comments