Skip to content

Commit

Permalink
feat: add file transfer metadata (#14307)
Browse files Browse the repository at this point in the history
  • Loading branch information
benmoriceau committed Oct 14, 2024
1 parent 5c88d58 commit b53258d
Show file tree
Hide file tree
Showing 18 changed files with 80 additions and 12 deletions.
6 changes: 6 additions & 0 deletions airbyte-api/server-api/src/main/openapi/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9620,6 +9620,7 @@ components:
- supportsRefreshes
- supportState
- isVersionOverrideApplied
- supportsFileTransfer
properties:
dockerRepository:
type: string
Expand All @@ -9641,13 +9642,16 @@ components:
cdkVersion:
description: "The version of the CDK that the connector was built with. e.g. python:0.1.0, java:0.1.0"
type: string
supportsFileTransfer:
type: boolean
ResolveActorDefinitionVersionResponse:
type: object
required:
- versionId
- dockerRepository
- dockerImageTag
- supportRefreshes
- supportFileTransfer
properties:
versionId:
$ref: "#/components/schemas/ActorDefinitionVersionId"
Expand All @@ -9657,6 +9661,8 @@ components:
type: string
supportRefreshes:
type: boolean
supportFileTransfers:
type: boolean
ActorDefinitionBreakingChange:
type: object
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class BootloaderTest {

// ⚠️ This line should change with every new migration to show that you meant to make a new
// migration to the prod database
private static final String CURRENT_CONFIGS_MIGRATION_VERSION = "0.64.4.002";
private static final String CURRENT_CONFIGS_MIGRATION_VERSION = "1.1.0.000";
private static final String CURRENT_JOBS_MIGRATION_VERSION = "0.64.7.002";

@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ ActorDefinitionVersionRead createActorDefinitionVersionRead(final ActorDefinitio
.supportLevel(toApiSupportLevel(actorDefinitionVersion.getSupportLevel()))
.cdkVersion(actorDefinitionVersion.getCdkVersion())
.lastPublished(ApiPojoConverters.toOffsetDateTime(actorDefinitionVersion.getLastPublished()))
.isVersionOverrideApplied(versionWithOverrideStatus.isOverrideApplied());
.isVersionOverrideApplied(versionWithOverrideStatus.isOverrideApplied())
.supportsFileTransfer(actorDefinitionVersion.getSupportsFileTransfer());

final Optional<ActorDefinitionVersionBreakingChanges> breakingChanges =
actorDefinitionHandlerHelper.getVersionBreakingChanges(actorDefinitionVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ void testGetActorDefinitionVersionForSource(final boolean isVersionOverrideAppli
.supportState(io.airbyte.api.model.generated.SupportState.SUPPORTED)
.dockerRepository(actorDefinitionVersion.getDockerRepository())
.dockerImageTag(actorDefinitionVersion.getDockerImageTag())
.supportsRefreshes(false);
.supportsRefreshes(false)
.supportsFileTransfer(false);

assertEquals(expectedRead, actorDefinitionVersionRead);
verify(mSourceService).getSourceConnection(sourceId);
Expand Down Expand Up @@ -163,7 +164,8 @@ void testGetActorDefinitionVersionForDestination(final boolean isVersionOverride
.supportState(io.airbyte.api.model.generated.SupportState.SUPPORTED)
.dockerRepository(actorDefinitionVersion.getDockerRepository())
.dockerImageTag(actorDefinitionVersion.getDockerImageTag())
.supportsRefreshes(false);
.supportsRefreshes(false)
.supportsFileTransfer(false);

assertEquals(expectedRead, actorDefinitionVersionRead);
verify(mDestinationService).getDestinationConnection(destinationId);
Expand Down Expand Up @@ -201,7 +203,8 @@ void testGetActorDefinitionVersionForDestinationWithNormalization(final boolean
.supportState(io.airbyte.api.model.generated.SupportState.SUPPORTED)
.dockerRepository(actorDefinitionVersion.getDockerRepository())
.dockerImageTag(actorDefinitionVersion.getDockerImageTag())
.supportsRefreshes(actorDefinitionVersion.getSupportsRefreshes());
.supportsRefreshes(actorDefinitionVersion.getSupportsRefreshes())
.supportsFileTransfer(false);

assertEquals(expectedRead, actorDefinitionVersionRead);
verify(mDestinationService).getDestinationConnection(destinationId);
Expand Down Expand Up @@ -233,7 +236,8 @@ void testCreateActorDefinitionVersionReadWithBreakingChange() throws IOException
.dockerRepository(actorDefinitionVersion.getDockerRepository())
.dockerImageTag(actorDefinitionVersion.getDockerImageTag())
.supportsRefreshes(false)
.breakingChanges(breakingChanges);
.breakingChanges(breakingChanges)
.supportsFileTransfer(false);

assertEquals(expectedRead, actorDefinitionVersionRead);
verify(mActorDefinitionHandlerHelper).getVersionBreakingChanges(actorDefinitionVersion);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,8 @@ private void mockRefresh() throws IOException {
UUID.randomUUID(),
"dockerRepo",
"dockerTag",
true));
true,
false));
}

private void mockNonRefresh() throws IOException {
Expand All @@ -447,6 +448,7 @@ private void mockNonRefresh() throws IOException {
UUID.randomUUID(),
"dockerRepo",
"dockerTag",
false,
false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ private void mockSupportRefreshes(final boolean supportsRefreshes) throws IOExce
UUID.randomUUID(),
"dockerRepository",
"dockerImageTag",
supportsRefreshes));
supportsRefreshes,
false));
}

private ConfiguredAirbyteCatalog buildConfiguredAirbyteCatalog() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void setup() throws Exception {
var resolveActorDefinitionVersionResponse = new ResolveActorDefinitionVersionResponse(UUID.randomUUID(),
"dockerRepository",
"dockerImageTag",
false,
false);
when(actorDefinitionVersionApi.resolveActorDefinitionVersionByTag(any())).thenReturn(resolveActorDefinitionVersionResponse);
when(airbyteApiClient.getActorDefinitionVersionApi()).thenReturn(actorDefinitionVersionApi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ public static ActorDefinitionVersion toActorDefinitionVersion(@Nullable final Co
.withLastPublished(lastModified)
.withCdkVersion(cdkVersion)
.withSupportsRefreshes(def.getSupportsRefreshes() != null && def.getSupportsRefreshes())
.withLanguage(def.getLanguage());
.withLanguage(def.getLanguage())
.withSupportsFileTransfer(def.getSupportsFileTransfer());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,7 @@ properties:
language:
description: The language that the connector is written in.
type: string
supportsFileTransfer:
description: an optional flag indicating whether a destination connector supports file transfer.
type: boolean
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,7 @@ properties:
language:
description: The language that the connector is written in.
type: string
supportsFileTransfer:
type: boolean
description: flag indicating whether the file transfer mode is available for this destination.
default: false
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ void testConvertRegistryDestinationToInternalTypes() {
.withAllowedHosts(ALLOWED_HOSTS)
.withResourceRequirements(RESOURCE_REQUIREMENTS)
.withReleases(new ConnectorReleasesDestination().withBreakingChanges(destinationBreakingChanges))
.withLanguage(LANGUAGE);
.withLanguage(LANGUAGE)
.withSupportsFileTransfer(true);

final StandardDestinationDefinition stdDestinationDef = new StandardDestinationDefinition()
.withDestinationDefinitionId(DEF_ID)
Expand All @@ -213,7 +214,8 @@ void testConvertRegistryDestinationToInternalTypes() {
.withReleaseDate(RELEASE_DATE)
.withProtocolVersion(PROTOCOL_VERSION)
.withAllowedHosts(ALLOWED_HOSTS)
.withLanguage(LANGUAGE);
.withLanguage(LANGUAGE)
.withSupportsFileTransfer(true);

assertEquals(stdDestinationDef, ConnectorRegistryConverters.toStandardDestinationDefinition(registryDestinationDef));
assertEquals(actorDefinitionVersion, ConnectorRegistryConverters.toActorDefinitionVersion(registryDestinationDef));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class VerifyDefaultVersionActivityImplTest {
isVersionOverrideApplied = true,
supportState = SupportState.SUPPORTED,
supportsRefreshes = true,
supportsFileTransfer = false,
)

// Test without "-rc" suffix in the input dockerImageTag
Expand Down Expand Up @@ -85,6 +86,7 @@ class VerifyDefaultVersionActivityImplTest {
isVersionOverrideApplied = true,
supportState = SupportState.SUPPORTED,
supportsRefreshes = true,
supportsFileTransfer = false,
)

val input =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public static ActorDefinitionVersion writeActorDefinitionVersion(final ActorDefi
.set(ACTOR_DEFINITION_VERSION.CDK_VERSION, actorDefinitionVersion.getCdkVersion())
.set(ACTOR_DEFINITION_VERSION.INTERNAL_SUPPORT_LEVEL, actorDefinitionVersion.getInternalSupportLevel())
.set(ACTOR_DEFINITION_VERSION.LANGUAGE, actorDefinitionVersion.getLanguage())
.set(ACTOR_DEFINITION_VERSION.SUPPORTS_FILE_TRANSFER, actorDefinitionVersion.getSupportsFileTransfer())
.where(ACTOR_DEFINITION_VERSION.ID.eq(versionId))
.execute();
} else {
Expand Down Expand Up @@ -127,6 +128,7 @@ public static ActorDefinitionVersion writeActorDefinitionVersion(final ActorDefi
.orElseThrow())
.set(ACTOR_DEFINITION_VERSION.INTERNAL_SUPPORT_LEVEL, actorDefinitionVersion.getInternalSupportLevel())
.set(ACTOR_DEFINITION_VERSION.LANGUAGE, actorDefinitionVersion.getLanguage())
.set(ACTOR_DEFINITION_VERSION.SUPPORTS_FILE_TRANSFER, actorDefinitionVersion.getSupportsFileTransfer())
.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,8 @@ public static ActorDefinitionVersion buildActorDefinitionVersion(final Record re
.withSupportsRefreshes(record.get(ACTOR_DEFINITION_VERSION.SUPPORTS_REFRESHES))
.withSupportState(Enums.toEnum(record.get(ACTOR_DEFINITION_VERSION.SUPPORT_STATE, String.class), SupportState.class).orElseThrow())
.withInternalSupportLevel(record.get(ACTOR_DEFINITION_VERSION.INTERNAL_SUPPORT_LEVEL, Long.class))
.withLanguage(record.get(ACTOR_DEFINITION_VERSION.LANGUAGE));
.withLanguage(record.get(ACTOR_DEFINITION_VERSION.LANGUAGE))
.withSupportsFileTransfer(record.get(ACTOR_DEFINITION_VERSION.SUPPORTS_FILE_TRANSFER));
}

public static SecretPersistenceCoordinate buildSecretPersistenceCoordinate(final Record record) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2020-2024 Airbyte, Inc., all rights reserved.
*/

package io.airbyte.db.instance.configs.migrations;

import org.flywaydb.core.api.migration.BaseJavaMigration;
import org.flywaydb.core.api.migration.Context;
import org.jooq.DSLContext;
import org.jooq.impl.DSL;
import org.jooq.impl.SQLDataType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

// TODO: update migration description in the class name
public class V1_1_0_000__AddSupportFileTransferToActorDefVersion extends BaseJavaMigration {

private static final Logger LOGGER = LoggerFactory.getLogger(V1_1_0_000__AddSupportFileTransferToActorDefVersion.class);

@Override
public void migrate(final Context context) throws Exception {
LOGGER.info("Running migration: {}", this.getClass().getSimpleName());

// Warning: please do not use any jOOQ generated code to write a migration.
// As database schema changes, the generated jOOQ code can be deprecated. So
// old migration may not compile if there is any generated code.
final DSLContext ctx = DSL.using(context.getConnection());

ctx.alterTable("actor_definition_version")
.addColumn("supports_file_transfer", SQLDataType.BOOLEAN.nullable(false).defaultValue(false))
.execute();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ create table "public"."actor_definition_version" (
"last_published" timestamp(6) with time zone,
"internal_support_level" bigint not null,
"language" varchar(256),
"supports_file_transfer" boolean not null default false,
constraint "actor_definition_version_pkey" primary key ("id"),
constraint "actor_definition_version_actor_definition_id_version_key" unique ("actor_definition_id", "docker_image_tag")
);
Expand Down
1 change: 1 addition & 0 deletions airbyte-webapp/src/test-utils/mock-data/mockDestination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const mockDestinationDefinitionVersion: ActorDefinitionVersionRead = {
isVersionOverrideApplied: false,
supportState: SupportState.supported,
supportLevel: "certified",
supportsFileTransfer: false,
};

export const mockDestinationDefinitionSpecification: DestinationDefinitionSpecificationRead = {
Expand Down
1 change: 1 addition & 0 deletions airbyte-webapp/src/test-utils/mock-data/mockSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const mockSourceDefinitionVersion: ActorDefinitionVersionRead = {
isVersionOverrideApplied: false,
supportState: SupportState.supported,
supportLevel: "certified",
supportsFileTransfer: false,
};

export const mockSourceDefinitionSpecification: SourceDefinitionSpecificationRead = {
Expand Down

0 comments on commit b53258d

Please sign in to comment.