Skip to content

Commit

Permalink
Remove unused webbackend search code. (#17008)
Browse files Browse the repository at this point in the history
* Remove unused webbackend search code.

* Remove unused request body.

* Remove unused request body.

* Remove failing test.

* Remove failing test.

* Remove failing test.

Co-authored-by: Parker Mossman <parker@airbyte.io>
  • Loading branch information
davinchia and pmossman committed Sep 26, 2022
1 parent e07bd6b commit 517466e
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 504 deletions.
54 changes: 0 additions & 54 deletions airbyte-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1991,27 +1991,6 @@ paths:
$ref: "#/components/schemas/WebBackendConnectionRead"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/web_backend/connections/search:
post:
tags:
- web_backend
summary: Search connections
operationId: webBackendSearchConnections
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/WebBackendConnectionSearch"
required: true
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: "#/components/schemas/WebBackendConnectionReadList"
"422":
$ref: "#/components/responses/InvalidInputResponse"
/v1/web_backend/state/get_type:
post:
tags:
Expand Down Expand Up @@ -3395,39 +3374,6 @@ components:
$ref: "#/components/schemas/SourceSearch"
destination:
$ref: "#/components/schemas/DestinationSearch"
WebBackendConnectionSearch:
type: object
properties:
connectionId:
$ref: "#/components/schemas/ConnectionId"
name:
type: string
namespaceDefinition:
$ref: "#/components/schemas/NamespaceDefinitionType"
namespaceFormat:
type: string
description: Used when namespaceDefinition is 'customformat'. If blank then behaves like namespaceDefinition = 'destination'. If "${SOURCE_NAMESPACE}" then behaves like namespaceDefinition = 'source'.
default: null
example: "${SOURCE_NAMESPACE}"
prefix:
type: string
description: Prefix that will be prepended to the name of each stream when it is written to the destination.
sourceId:
$ref: "#/components/schemas/SourceId"
destinationId:
$ref: "#/components/schemas/DestinationId"
schedule:
$ref: "#/components/schemas/ConnectionSchedule"
scheduleType:
$ref: "#/components/schemas/ConnectionScheduleType"
scheduleData:
$ref: "#/components/schemas/ConnectionScheduleData"
status:
$ref: "#/components/schemas/ConnectionStatus"
source:
$ref: "#/components/schemas/SourceSearch"
destination:
$ref: "#/components/schemas/DestinationSearch"
ConnectionReadList:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
import io.airbyte.api.model.generated.WebBackendConnectionRead;
import io.airbyte.api.model.generated.WebBackendConnectionReadList;
import io.airbyte.api.model.generated.WebBackendConnectionRequestBody;
import io.airbyte.api.model.generated.WebBackendConnectionSearch;
import io.airbyte.api.model.generated.WebBackendConnectionUpdate;
import io.airbyte.api.model.generated.WebBackendWorkspaceState;
import io.airbyte.api.model.generated.WebBackendWorkspaceStateResult;
Expand Down Expand Up @@ -813,11 +812,6 @@ public WebBackendConnectionReadList webBackendListConnectionsForWorkspace(final
return execute(() -> webBackendConnectionsHandler.webBackendListConnectionsForWorkspace(workspaceIdRequestBody));
}

@Override
public WebBackendConnectionReadList webBackendSearchConnections(final WebBackendConnectionSearch webBackendConnectionSearch) {
return execute(() -> webBackendConnectionsHandler.webBackendSearchConnections(webBackendConnectionSearch));
}

@Override
public WebBackendConnectionRead webBackendGetConnection(final WebBackendConnectionRequestBody webBackendConnectionRequestBody) {
return execute(() -> webBackendConnectionsHandler.webBackendGetConnection(webBackendConnectionRequestBody));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import io.airbyte.api.model.generated.ConnectionCreate;
import io.airbyte.api.model.generated.ConnectionIdRequestBody;
import io.airbyte.api.model.generated.ConnectionRead;
import io.airbyte.api.model.generated.ConnectionSearch;
import io.airbyte.api.model.generated.ConnectionStateType;
import io.airbyte.api.model.generated.ConnectionUpdate;
import io.airbyte.api.model.generated.DestinationIdRequestBody;
Expand All @@ -35,7 +34,6 @@
import io.airbyte.api.model.generated.WebBackendConnectionRead;
import io.airbyte.api.model.generated.WebBackendConnectionReadList;
import io.airbyte.api.model.generated.WebBackendConnectionRequestBody;
import io.airbyte.api.model.generated.WebBackendConnectionSearch;
import io.airbyte.api.model.generated.WebBackendConnectionUpdate;
import io.airbyte.api.model.generated.WebBackendOperationCreateOrUpdate;
import io.airbyte.api.model.generated.WebBackendWorkspaceState;
Expand Down Expand Up @@ -167,19 +165,6 @@ private static WebBackendConnectionRead getWebBackendConnectionRead(final Connec
.resourceRequirements(connectionRead.getResourceRequirements());
}

public WebBackendConnectionReadList webBackendSearchConnections(final WebBackendConnectionSearch webBackendConnectionSearch)
throws ConfigNotFoundException, IOException, JsonValidationException {

final List<WebBackendConnectionRead> reads = Lists.newArrayList();
for (final ConnectionRead connectionRead : connectionsHandler.listConnections().getConnections()) {
if (connectionsHandler.matchSearch(toConnectionSearch(webBackendConnectionSearch), connectionRead)) {
reads.add(buildWebBackendConnectionRead(connectionRead));
}
}

return new WebBackendConnectionReadList().connections(reads);
}

// todo (cgardens) - This logic is a headache to follow it stems from the internal data model not
// tracking selected streams in any reasonable way. We should update that.
public WebBackendConnectionRead webBackendGetConnection(final WebBackendConnectionRequestBody webBackendConnectionRequestBody)
Expand Down Expand Up @@ -542,24 +527,6 @@ protected static ConnectionUpdate toConnectionPatch(final WebBackendConnectionUp
return connectionPatch;
}

@VisibleForTesting
protected static ConnectionSearch toConnectionSearch(final WebBackendConnectionSearch webBackendConnectionSearch) {
return new ConnectionSearch()
.name(webBackendConnectionSearch.getName())
.connectionId(webBackendConnectionSearch.getConnectionId())
.source(webBackendConnectionSearch.getSource())
.sourceId(webBackendConnectionSearch.getSourceId())
.destination(webBackendConnectionSearch.getDestination())
.destinationId(webBackendConnectionSearch.getDestinationId())
.namespaceDefinition(webBackendConnectionSearch.getNamespaceDefinition())
.namespaceFormat(webBackendConnectionSearch.getNamespaceFormat())
.prefix(webBackendConnectionSearch.getPrefix())
.schedule(webBackendConnectionSearch.getSchedule())
.scheduleType(webBackendConnectionSearch.getScheduleType())
.scheduleData(webBackendConnectionSearch.getScheduleData())
.status(webBackendConnectionSearch.getStatus());
}

@VisibleForTesting
static List<StreamDescriptor> getStreamsToReset(final CatalogDiff catalogDiff) {
return catalogDiff.getTransforms().stream().map(StreamTransform::getStreamDescriptor).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.airbyte.api.model.generated.ConnectionReadList;
import io.airbyte.api.model.generated.ConnectionSchedule;
import io.airbyte.api.model.generated.ConnectionSchedule.TimeUnitEnum;
import io.airbyte.api.model.generated.ConnectionSearch;
import io.airbyte.api.model.generated.ConnectionState;
import io.airbyte.api.model.generated.ConnectionStateType;
import io.airbyte.api.model.generated.ConnectionStatus;
Expand Down Expand Up @@ -60,7 +59,6 @@
import io.airbyte.api.model.generated.WebBackendConnectionRead;
import io.airbyte.api.model.generated.WebBackendConnectionReadList;
import io.airbyte.api.model.generated.WebBackendConnectionRequestBody;
import io.airbyte.api.model.generated.WebBackendConnectionSearch;
import io.airbyte.api.model.generated.WebBackendConnectionUpdate;
import io.airbyte.api.model.generated.WebBackendOperationCreateOrUpdate;
import io.airbyte.api.model.generated.WebBackendWorkspaceState;
Expand Down Expand Up @@ -299,27 +297,6 @@ void testWebBackendListConnectionsForWorkspace() throws ConfigNotFoundException,
assertEquals(expected, WebBackendConnectionReadList.getConnections().get(0));
}

@Test
void testWebBackendSearchConnections() throws ConfigNotFoundException, IOException, JsonValidationException {
final ConnectionReadList connectionReadList = new ConnectionReadList();
connectionReadList.setConnections(Collections.singletonList(connectionRead));
final ConnectionIdRequestBody connectionIdRequestBody = new ConnectionIdRequestBody();
connectionIdRequestBody.setConnectionId(connectionRead.getConnectionId());

when(operationsHandler.listOperationsForConnection(connectionIdRequestBody)).thenReturn(operationReadList);
when(connectionsHandler.listConnections()).thenReturn(connectionReadList);
when(connectionsHandler.matchSearch(new ConnectionSearch(), connectionRead)).thenReturn(true);

final WebBackendConnectionSearch webBackendConnectionSearch = new WebBackendConnectionSearch();
WebBackendConnectionReadList webBackendConnectionReadList = wbHandler.webBackendSearchConnections(webBackendConnectionSearch);
assertEquals(1, webBackendConnectionReadList.getConnections().size());
assertEquals(expected, webBackendConnectionReadList.getConnections().get(0));

when(connectionsHandler.matchSearch(new ConnectionSearch(), connectionRead)).thenReturn(false);
webBackendConnectionReadList = wbHandler.webBackendSearchConnections(webBackendConnectionSearch);
assertEquals(0, webBackendConnectionReadList.getConnections().size());
}

@Test
void testWebBackendGetConnection() throws ConfigNotFoundException, IOException, JsonValidationException {
final ConnectionIdRequestBody connectionIdRequestBody = new ConnectionIdRequestBody();
Expand Down

0 comments on commit 517466e

Please sign in to comment.