Skip to content

Commit

Permalink
remove workspace service acount list endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
cgardens committed Nov 29, 2022
1 parent 09f8aae commit 95d881e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1402,24 +1402,17 @@ private Condition includeTombstones(final Field<Boolean> 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<WorkspaceServiceAccount> listWorkspaceServiceAccountQuery(final Optional<UUID> workspaceId)
throws IOException {
final Result<Record> result = database.query(ctx -> {
final SelectJoinStep<Record> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ void testListDestinationDefinitionsWithVersion() throws JsonValidationException,
final List<StandardDestinationDefinition> 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()));

Expand All @@ -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);
}

Expand All @@ -152,7 +151,6 @@ void testListSourceDefinitionsWithVersion() throws JsonValidationException, IOEx
final List<StandardSourceDefinition> 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()));

Expand All @@ -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);
}

Expand Down

0 comments on commit 95d881e

Please sign in to comment.