From 95d881ec92d06624da945b01e98e9beeb4b34d53 Mon Sep 17 00:00:00 2001 From: cgardens Date: Tue, 29 Nov 2022 08:24:01 -0800 Subject: [PATCH] remove workspace service acount list endpoint --- .../config/persistence/ConfigRepository.java | 21 +++++++------------ .../ActorDefinitionPersistenceTest.java | 14 ++++++------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index 1f72ac9285ca..760e15c634d7 100644 --- a/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/config-persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -1402,24 +1402,17 @@ private Condition includeTombstones(final Field tombstoneField, final b } public WorkspaceServiceAccount getWorkspaceServiceAccountNoSecrets(final UUID workspaceId) throws IOException, ConfigNotFoundException { - return listWorkspaceServiceAccountQuery(Optional.of(workspaceId)) + // breaking the pattern of doing a list query, because we never want to list this resource without + // scoping by workspace id. + return database.query(ctx -> ctx.select(asterisk()).from(WORKSPACE_SERVICE_ACCOUNT) + .where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceId)) + .fetch()) + .map(DbConverter::buildWorkspaceServiceAccount) + .stream() .findFirst() .orElseThrow(() -> new ConfigNotFoundException(ConfigSchema.WORKSPACE_SERVICE_ACCOUNT, workspaceId)); } - private Stream listWorkspaceServiceAccountQuery(final Optional workspaceId) - throws IOException { - final Result result = database.query(ctx -> { - final SelectJoinStep query = ctx.select(asterisk()).from(WORKSPACE_SERVICE_ACCOUNT); - if (workspaceId.isPresent()) { - return query.where(WORKSPACE_SERVICE_ACCOUNT.WORKSPACE_ID.eq(workspaceId.get())).fetch(); - } - return query.fetch(); - }); - - return result.map(DbConverter::buildWorkspaceServiceAccount).stream(); - } - public void writeWorkspaceServiceAccountNoSecrets(final WorkspaceServiceAccount workspaceServiceAccount) throws IOException { database.transaction(ctx -> { writeWorkspaceServiceAccount(Collections.singletonList(workspaceServiceAccount), ctx); diff --git a/airbyte-config/config-persistence/src/test/java/io/airbyte/config/persistence/ActorDefinitionPersistenceTest.java b/airbyte-config/config-persistence/src/test/java/io/airbyte/config/persistence/ActorDefinitionPersistenceTest.java index 832465257ba9..5a38216aca59 100644 --- a/airbyte-config/config-persistence/src/test/java/io/airbyte/config/persistence/ActorDefinitionPersistenceTest.java +++ b/airbyte-config/config-persistence/src/test/java/io/airbyte/config/persistence/ActorDefinitionPersistenceTest.java @@ -128,7 +128,6 @@ void testListDestinationDefinitionsWithVersion() throws JsonValidationException, final List allDestDefs = List.of( createBaseDestDef().withProtocolVersion(null), createBaseDestDef().withProtocolVersion(null).withSpec(new ConnectorSpecification().withProtocolVersion("0.3.1")), - // We expect the protocol version to be in the ConnectorSpec, so we'll override regardless. createBaseDestDef().withProtocolVersion("0.4.0").withSpec(new ConnectorSpecification().withProtocolVersion("0.4.1")), createBaseDestDef().withProtocolVersion("0.5.0").withSpec(new ConnectorSpecification())); @@ -141,9 +140,9 @@ void testListDestinationDefinitionsWithVersion() throws JsonValidationException, assertEquals( List.of( AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize(), - "0.3.1", - "0.4.1", - AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize()), + AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize(), + "0.4.0", + "0.5.0"), protocolVersions); } @@ -152,7 +151,6 @@ void testListSourceDefinitionsWithVersion() throws JsonValidationException, IOEx final List allSrcDefs = List.of( createBaseSourceDef().withProtocolVersion(null), createBaseSourceDef().withProtocolVersion(null).withSpec(new ConnectorSpecification().withProtocolVersion("0.6.0")), - // We expect the protocol version to be in the ConnectorSpec, so we'll override regardless. createBaseSourceDef().withProtocolVersion("0.7.0").withSpec(new ConnectorSpecification().withProtocolVersion("0.7.1")), createBaseSourceDef().withProtocolVersion("0.8.0").withSpec(new ConnectorSpecification())); @@ -165,9 +163,9 @@ void testListSourceDefinitionsWithVersion() throws JsonValidationException, IOEx assertEquals( List.of( AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize(), - "0.6.0", - "0.7.1", - AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize()), + AirbyteProtocolVersion.DEFAULT_AIRBYTE_PROTOCOL_VERSION.serialize(), + "0.7.0", + "0.8.0"), protocolVersions); }