Skip to content

Commit

Permalink
Remove default value from namespaceDefinitionType (airbytehq#17177)
Browse files Browse the repository at this point in the history
* remove default value from namespaceDefinitionType

* fix test

* switch some tests to use PATCH-style connection update

* add default logic to connection creation

Co-authored-by: Michael Siega <michael@airbyte.io>
  • Loading branch information
2 people authored and jhammarstedt committed Oct 31, 2022
1 parent b9b620b commit a289761
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 26 deletions.
1 change: 0 additions & 1 deletion airbyte-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3453,7 +3453,6 @@ components:
NamespaceDefinitionType:
type: string
description: Method used for computing final namespace in destination
default: source
enum:
- source
- destination
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,17 @@ public ConnectionRead createConnection(final ConnectionCreate connectionCreate)

final UUID connectionId = uuidGenerator.get();

// If not specified, default the NamespaceDefinition to 'source'
final NamespaceDefinitionType namespaceDefinitionType =
connectionCreate.getNamespaceDefinition() == null
? NamespaceDefinitionType.SOURCE
: Enums.convertTo(connectionCreate.getNamespaceDefinition(), NamespaceDefinitionType.class);

// persist sync
final StandardSync standardSync = new StandardSync()
.withConnectionId(connectionId)
.withName(connectionCreate.getName() != null ? connectionCreate.getName() : defaultName)
.withNamespaceDefinition(Enums.convertTo(connectionCreate.getNamespaceDefinition(), NamespaceDefinitionType.class))
.withNamespaceDefinition(namespaceDefinitionType)
.withNamespaceFormat(connectionCreate.getNamespaceFormat())
.withPrefix(connectionCreate.getPrefix())
.withSourceId(connectionCreate.getSourceId())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ void testSearchConnections() throws JsonValidationException, ConfigNotFoundExcep
.thenReturn(destinationDefinition);

final ConnectionSearch connectionSearch = new ConnectionSearch();
connectionSearch.namespaceDefinition(NamespaceDefinitionType.SOURCE);
ConnectionReadList actualConnectionReadList = connectionsHandler.searchConnections(connectionSearch);
assertEquals(1, actualConnectionReadList.getConnections().size());
assertEquals(connectionRead1, actualConnectionReadList.getConnections().get(0));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -725,15 +725,8 @@ private void clearDestinationDbData() throws SQLException {
}

private void disableConnection(final UUID connectionId) throws ApiException {
final ConnectionRead connection = apiClient.getConnectionApi().getConnection(new ConnectionIdRequestBody().connectionId(connectionId));
final ConnectionUpdate connectionUpdate =
new ConnectionUpdate()
.prefix(connection.getPrefix())
.connectionId(connectionId)
.operationIds(connection.getOperationIds())
.status(ConnectionStatus.DEPRECATED)
.schedule(connection.getSchedule())
.syncCatalog(connection.getSyncCatalog());
new ConnectionUpdate().connectionId(connectionId).status(ConnectionStatus.DEPRECATED);
apiClient.getConnectionApi().updateConnection(connectionUpdate);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
import io.airbyte.api.client.model.generated.StreamState;
import io.airbyte.api.client.model.generated.SyncMode;
import io.airbyte.api.client.model.generated.WebBackendConnectionUpdate;
import io.airbyte.api.client.model.generated.WebBackendOperationCreateOrUpdate;
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.temporal.scheduling.state.WorkflowState;
import io.airbyte.db.Database;
Expand Down Expand Up @@ -1095,22 +1094,8 @@ void testResetAllWhenSchemaIsModifiedForLegacySource() throws Exception {
// Update with refreshed catalog
LOGGER.info("Submit the update request");
final WebBackendConnectionUpdate update = new WebBackendConnectionUpdate()
.name(connection.getName())
.connectionId(connection.getConnectionId())
.namespaceDefinition(connection.getNamespaceDefinition())
.namespaceFormat(connection.getNamespaceFormat())
.prefix(connection.getPrefix())
.operations(List.of(
new WebBackendOperationCreateOrUpdate()
.name(operation.getName())
.operationId(operation.getOperationId())
.workspaceId(operation.getWorkspaceId())
.operatorConfiguration(operation.getOperatorConfiguration())))
.syncCatalog(updatedCatalog)
.schedule(connection.getSchedule())
.sourceCatalogId(connection.getSourceCatalogId())
.status(connection.getStatus())
.resourceRequirements(connection.getResourceRequirements());
.syncCatalog(updatedCatalog);
webBackendApi.webBackendUpdateConnection(update);

LOGGER.info("Inspecting Destination DB after the update request, tables should be empty");
Expand Down

0 comments on commit a289761

Please sign in to comment.