From dca7b63b80bf77c7efebf8f80235c497ec274778 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 9 Mar 2022 10:53:29 -0300 Subject: [PATCH 1/9] create migration tables --- .../airbyte/bootloader/BootloaderAppTest.java | 2 +- .../V0_35_50_001__AddNotificationTable.java | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java diff --git a/airbyte-bootloader/src/test/java/io/airbyte/bootloader/BootloaderAppTest.java b/airbyte-bootloader/src/test/java/io/airbyte/bootloader/BootloaderAppTest.java index 588262aac8e465..5230bcebe050b8 100644 --- a/airbyte-bootloader/src/test/java/io/airbyte/bootloader/BootloaderAppTest.java +++ b/airbyte-bootloader/src/test/java/io/airbyte/bootloader/BootloaderAppTest.java @@ -80,7 +80,7 @@ void testBootloaderAppBlankDb() throws Exception { mockedConfigs.getConfigDatabaseUrl()) .getAndInitialize(); val configsMigrator = new ConfigsDatabaseMigrator(configDatabase, this.getClass().getName()); - assertEquals("0.35.46.001", configsMigrator.getLatestMigration().getVersion().getVersion()); + assertEquals("0.35.50.001", configsMigrator.getLatestMigration().getVersion().getVersion()); val jobsPersistence = new DefaultJobPersistence(jobDatabase); assertEquals(version, jobsPersistence.getVersion().get()); diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java new file mode 100644 index 00000000000000..ae1a9f4143673c --- /dev/null +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2021 Airbyte, Inc., all rights reserved. + */ + +package io.airbyte.db.instance.configs.migrations; + +import java.util.UUID; +import org.flywaydb.core.api.migration.BaseJavaMigration; +import org.flywaydb.core.api.migration.Context; +import org.jooq.DSLContext; +import org.jooq.Field; +import org.jooq.impl.DSL; +import org.jooq.impl.SQLDataType; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class V0_35_50_001__AddNotificationTable extends BaseJavaMigration { + + private static final Logger LOGGER = LoggerFactory.getLogger(V0_35_50_001__AddNotificationTable.class); + + @Override + public void migrate(final Context context) throws Exception { + LOGGER.info("Running migration: {}", this.getClass().getSimpleName()); + + final DSLContext ctx = DSL.using(context.getConnection()); + + final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); + final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); + + ctx.createTableIfNotExists("notification_config") + .columns(id, name); + } + +} From c857837da5651d66acdf234a54c9840e8707d88d Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 9 Mar 2022 11:15:48 -0300 Subject: [PATCH 2/9] add execute in migration --- .../migrations/V0_35_50_001__AddNotificationTable.java | 7 ++++--- .../src/main/resources/configs_database/schema_dump.txt | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java index ae1a9f4143673c..45bb294132baac 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -24,11 +24,12 @@ public void migrate(final Context context) throws Exception { final DSLContext ctx = DSL.using(context.getConnection()); - final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); - final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); + final Field id = DSL.field("id", SQLDataType.UUID.nullable(true)); + final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(true)); ctx.createTableIfNotExists("notification_config") - .columns(id, name); + .columns(id, name) + .execute(); } } diff --git a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt index fb0f668844f5d6..56cc79b55a3fec 100644 --- a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt +++ b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt @@ -111,6 +111,10 @@ create table "public"."connection_operation"( "operation_id" ) ); +create table "public"."notification_config"( + "id" uuid not null, + "name" varchar(256) not null +); create table "public"."operation"( "id" uuid not null, "workspace_id" uuid not null, From 94c142a3134b23a35f09c3f85d585b11e6d62b71 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 9 Mar 2022 18:55:10 -0300 Subject: [PATCH 3/9] add notification_connection table in migration file --- .../V0_35_50_001__AddNotificationTable.java | 40 ++++++++++++++++--- .../configs_database/schema_dump.txt | 4 +- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java index 45bb294132baac..8e5b3ff391c0f5 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -4,7 +4,13 @@ package io.airbyte.db.instance.configs.migrations; +import java.util.List; import java.util.UUID; + +import com.google.common.annotations.VisibleForTesting; +import io.airbyte.config.ConfigSchema; +import io.airbyte.config.ConfigWithMetadata; +import io.airbyte.config.StandardWorkspace; import org.flywaydb.core.api.migration.BaseJavaMigration; import org.flywaydb.core.api.migration.Context; import org.jooq.DSLContext; @@ -20,16 +26,40 @@ public class V0_35_50_001__AddNotificationTable extends BaseJavaMigration { @Override public void migrate(final Context context) throws Exception { - LOGGER.info("Running migration: {}", this.getClass().getSimpleName()); - final DSLContext ctx = DSL.using(context.getConnection()); + migrate(ctx); + } + + @VisibleForTesting + public static void migrate(final DSLContext ctx) { + createNotificationConfigTable(ctx); + createNotificationConnectionTable(ctx); + } + + public static void createNotificationConfigTable(final DSLContext ctx) { - final Field id = DSL.field("id", SQLDataType.UUID.nullable(true)); - final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(true)); + + final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); + final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); + final Field webhook = DSL.field("webhook", SQLDataType.VARCHAR(516).nullable(false)); ctx.createTableIfNotExists("notification_config") - .columns(id, name) + .columns(id, name, webhook) .execute(); + LOGGER.info("workspace table created"); + } + + public static void createNotificationConnectionTable(final DSLContext ctx) { + + final Field connectionId = DSL.field("connection_id", SQLDataType.UUID.nullable(true)); + final Field notificationId = DSL.field("notification_id", SQLDataType.UUID.nullable(true)); + final Field onSuccess = DSL.field("on_success", SQLDataType.BOOLEAN.nullable(false)); + final Field onFailure = DSL.field("on_failure", SQLDataType.BOOLEAN.nullable(false)); + + + ctx.createTableIfNotExists("notification_connection") + .columns(connectionId, notificationId, onSuccess, onFailure) + .execute(); } } diff --git a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt index 56cc79b55a3fec..bb0743d0b1b5dd 100644 --- a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt +++ b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt @@ -112,8 +112,8 @@ create table "public"."connection_operation"( ) ); create table "public"."notification_config"( - "id" uuid not null, - "name" varchar(256) not null + "id" uuid null, + "name" varchar(256) null ); create table "public"."operation"( "id" uuid not null, From bc56777cbeee0ece4247eefc6adb41c8a052c3a7 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Wed, 9 Mar 2022 20:48:07 -0300 Subject: [PATCH 4/9] add create endpoint --- airbyte-api/src/main/openapi/config.yaml | 32 +++++++ .../java/io/airbyte/config/ConfigSchema.java | 6 ++ .../resources/types/StandardNotification.yaml | 24 ++++++ .../config/persistence/ConfigRepository.java | 20 ++--- .../DatabaseConfigPersistence.java | 51 +++++------ airbyte-db/jooq/build.gradle | 4 +- .../V0_35_50_001__AddNotificationTable.java | 13 +-- .../configs_database/schema_dump.txt | 11 ++- .../airbyte/server/apis/ConfigurationApi.java | 85 ++----------------- .../server/handlers/WorkspacesHandler.java | 29 ++++--- .../api/generated-api-html/index.html | 66 ++++++++++++++ 11 files changed, 191 insertions(+), 150 deletions(-) create mode 100644 airbyte-config/models/src/main/resources/types/StandardNotification.yaml diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index 831a0f8ec395ec..828707605adbf1 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -248,6 +248,28 @@ paths: $ref: "#/components/responses/NotFoundResponse" "422": $ref: "#/components/responses/InvalidInputResponse" + /v1/notifications/create: + post: + tags: + - notifications + summary: > + Create a new Notification + operationId: createNotification + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationCreate" + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRead" + "404": + $ref: "#/components/responses/NotFoundResponse" /v1/source_definitions/create: post: tags: @@ -1987,6 +2009,16 @@ components: - failed message: type: string + NotificationCreate: + type: object + required: + - name + - webhook + properties: + name: + type: string + webhook: + type: string WorkspaceIdRequestBody: type: object required: diff --git a/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java b/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java index 4d2296a0cbde6b..fbcfbd7be41aa3 100644 --- a/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java +++ b/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java @@ -17,6 +17,12 @@ public enum ConfigSchema implements AirbyteConfig { standardWorkspace -> standardWorkspace.getWorkspaceId().toString(), "workspaceId"), + // notification + STANDARD_NOTIFICATION("StandardNotification.yaml", + StandardNotification.class, + standardNotification -> standardNotification.getNotificationId().toString(), + "notificationId"), + // source STANDARD_SOURCE_DEFINITION("StandardSourceDefinition.yaml", StandardSourceDefinition.class, diff --git a/airbyte-config/models/src/main/resources/types/StandardNotification.yaml b/airbyte-config/models/src/main/resources/types/StandardNotification.yaml new file mode 100644 index 00000000000000..d54d1c9735d0b8 --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/StandardNotification.yaml @@ -0,0 +1,24 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotificationConfiguration.yaml +title: StandardNotification +description: notification configuration +type: object +required: + - notificationId + - name + - webhook +additionalProperties: false +properties: + notificationId: + type: string + format: uuid + name: + type: string + webhook: + type: string +# tombstone: +# description: +# if not set or false, the configuration is active. if true, then this +# configuration is permanently off. +# type: boolean diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index a9428d84521bce..c2b79de76990ac 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -18,21 +18,7 @@ import io.airbyte.commons.json.Jsons; import io.airbyte.commons.lang.Exceptions; import io.airbyte.commons.lang.MoreBooleans; -import io.airbyte.config.ActorCatalog; -import io.airbyte.config.ActorCatalogFetchEvent; -import io.airbyte.config.AirbyteConfig; -import io.airbyte.config.ConfigSchema; -import io.airbyte.config.DestinationConnection; -import io.airbyte.config.DestinationOAuthParameter; -import io.airbyte.config.SourceConnection; -import io.airbyte.config.SourceOAuthParameter; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; -import io.airbyte.config.StandardSync; -import io.airbyte.config.StandardSyncOperation; -import io.airbyte.config.StandardSyncState; -import io.airbyte.config.StandardWorkspace; -import io.airbyte.config.State; +import io.airbyte.config.*; import io.airbyte.config.persistence.split_secrets.SecretPersistence; import io.airbyte.config.persistence.split_secrets.SecretsHelpers; import io.airbyte.config.persistence.split_secrets.SecretsHydrator; @@ -138,6 +124,10 @@ public void writeStandardWorkspace(final StandardWorkspace workspace) throws Jso persistence.writeConfig(ConfigSchema.STANDARD_WORKSPACE, workspace.getWorkspaceId().toString(), workspace); } + public void writeStandardNotification(final StandardNotification notification) throws JsonValidationException, IOException { + persistence.writeConfig(ConfigSchema.STANDARD_NOTIFICATION, notification.getNotificationId().toString(), notification); + } + public void setFeedback(final UUID workflowId) throws JsonValidationException, ConfigNotFoundException, IOException { final StandardWorkspace workspace = this.getStandardWorkspace(workflowId, false); diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java index 299c59b64eda3b..b988fa845b46a1 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java @@ -4,16 +4,7 @@ package io.airbyte.config.persistence; -import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR; -import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_CATALOG; -import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_CATALOG_FETCH_EVENT; -import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_DEFINITION; -import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_OAUTH_PARAMETER; -import static io.airbyte.db.instance.configs.jooq.Tables.CONNECTION; -import static io.airbyte.db.instance.configs.jooq.Tables.CONNECTION_OPERATION; -import static io.airbyte.db.instance.configs.jooq.Tables.OPERATION; -import static io.airbyte.db.instance.configs.jooq.Tables.STATE; -import static io.airbyte.db.instance.configs.jooq.Tables.WORKSPACE; +import static io.airbyte.db.instance.configs.jooq.Tables.*; import static org.jooq.impl.DSL.asterisk; import static org.jooq.impl.DSL.select; @@ -25,28 +16,9 @@ import io.airbyte.commons.json.Jsons; import io.airbyte.commons.util.MoreIterators; import io.airbyte.commons.version.AirbyteVersion; -import io.airbyte.config.ActorCatalog; -import io.airbyte.config.ActorCatalogFetchEvent; -import io.airbyte.config.ActorDefinitionResourceRequirements; -import io.airbyte.config.AirbyteConfig; -import io.airbyte.config.ConfigSchema; -import io.airbyte.config.ConfigWithMetadata; -import io.airbyte.config.DestinationConnection; -import io.airbyte.config.DestinationOAuthParameter; -import io.airbyte.config.Notification; -import io.airbyte.config.OperatorDbt; -import io.airbyte.config.OperatorNormalization; -import io.airbyte.config.SourceConnection; -import io.airbyte.config.SourceOAuthParameter; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; +import io.airbyte.config.*; import io.airbyte.config.StandardSourceDefinition.SourceType; -import io.airbyte.config.StandardSync; -import io.airbyte.config.StandardSyncOperation; import io.airbyte.config.StandardSyncOperation.OperatorType; -import io.airbyte.config.StandardSyncState; -import io.airbyte.config.StandardWorkspace; -import io.airbyte.config.State; import io.airbyte.db.Database; import io.airbyte.db.ExceptionWrappingDatabase; import io.airbyte.db.instance.configs.jooq.enums.ActorType; @@ -786,6 +758,23 @@ private void writeStandardWorkspace(final List configs) throw }); } + private void writeStandardNotification(final List configs) throws IOException { + database.transaction(ctx -> { + writeStandardNotification(configs, ctx); + return null; + }); + } + + private void writeStandardNotification(final List configs, final DSLContext ctx) { + configs.forEach((standardNotification) -> { + ctx.insertInto(NOTIFICATION_CONFIG) + .set(NOTIFICATION_CONFIG.ID, standardNotification.getNotificationId()) + .set(NOTIFICATION_CONFIG.NAME, standardNotification.getName()) + .set(NOTIFICATION_CONFIG.WEBHOOK, standardNotification.getWebhook()) + .execute(); + }); + } + private void writeStandardWorkspace(final List configs, final DSLContext ctx) { final OffsetDateTime timestamp = OffsetDateTime.now(); configs.forEach((standardWorkspace) -> { @@ -1388,6 +1377,8 @@ public void writeConfigs(final AirbyteConfig configType, final Map (ActorCatalog) c).collect(Collectors.toList())); } else if (configType == ConfigSchema.ACTOR_CATALOG_FETCH_EVENT) { writeActorCatalogFetchEvent(configs.values().stream().map(c -> (ActorCatalogFetchEvent) c).collect(Collectors.toList())); + } else if (configType == ConfigSchema.STANDARD_NOTIFICATION) { + writeStandardNotification(configs.values().stream().map(c -> (StandardNotification) c).collect(Collectors.toList())); } else { throw new IllegalArgumentException("Unknown Config Type " + configType); } diff --git a/airbyte-db/jooq/build.gradle b/airbyte-db/jooq/build.gradle index 48041d1b1acc7f..cdec00c0e9566a 100644 --- a/airbyte-db/jooq/build.gradle +++ b/airbyte-db/jooq/build.gradle @@ -82,10 +82,10 @@ sourceSets { tasks.named('generateConfigsDatabaseJooq').configure { allInputsDeclared = true - outputs.cacheIf { true } + outputs.cacheIf { false } } tasks.named('generateJobsDatabaseJooq').configure { allInputsDeclared = true - outputs.cacheIf { true } + outputs.cacheIf { false } } diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java index 8e5b3ff391c0f5..d4eeb8379f3c45 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -4,13 +4,8 @@ package io.airbyte.db.instance.configs.migrations; -import java.util.List; -import java.util.UUID; - import com.google.common.annotations.VisibleForTesting; -import io.airbyte.config.ConfigSchema; -import io.airbyte.config.ConfigWithMetadata; -import io.airbyte.config.StandardWorkspace; +import java.util.UUID; import org.flywaydb.core.api.migration.BaseJavaMigration; import org.flywaydb.core.api.migration.Context; import org.jooq.DSLContext; @@ -38,7 +33,6 @@ public static void migrate(final DSLContext ctx) { public static void createNotificationConfigTable(final DSLContext ctx) { - final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); final Field webhook = DSL.field("webhook", SQLDataType.VARCHAR(516).nullable(false)); @@ -56,10 +50,9 @@ public static void createNotificationConnectionTable(final DSLContext ctx) { final Field onSuccess = DSL.field("on_success", SQLDataType.BOOLEAN.nullable(false)); final Field onFailure = DSL.field("on_failure", SQLDataType.BOOLEAN.nullable(false)); - ctx.createTableIfNotExists("notification_connection") - .columns(connectionId, notificationId, onSuccess, onFailure) - .execute(); + .columns(connectionId, notificationId, onSuccess, onFailure) + .execute(); } } diff --git a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt index bb0743d0b1b5dd..fe239e7333ed53 100644 --- a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt +++ b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt @@ -112,8 +112,15 @@ create table "public"."connection_operation"( ) ); create table "public"."notification_config"( - "id" uuid null, - "name" varchar(256) null + "id" uuid not null, + "name" varchar(256) not null, + "webhook" varchar(516) not null +); +create table "public"."notification_connection"( + "connection_id" uuid null, + "notification_id" uuid null, + "on_success" bool not null, + "on_failure" bool not null ); create table "public"."operation"( "id" uuid not null, diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java index fceb234a81e4cb..570cd844179b1b 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java +++ b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java @@ -5,84 +5,7 @@ package io.airbyte.server.apis; import io.airbyte.analytics.TrackingClient; -import io.airbyte.api.model.CheckConnectionRead; -import io.airbyte.api.model.CheckOperationRead; -import io.airbyte.api.model.CompleteDestinationOAuthRequest; -import io.airbyte.api.model.CompleteSourceOauthRequest; -import io.airbyte.api.model.ConnectionCreate; -import io.airbyte.api.model.ConnectionIdRequestBody; -import io.airbyte.api.model.ConnectionRead; -import io.airbyte.api.model.ConnectionReadList; -import io.airbyte.api.model.ConnectionSearch; -import io.airbyte.api.model.ConnectionState; -import io.airbyte.api.model.ConnectionUpdate; -import io.airbyte.api.model.DbMigrationExecutionRead; -import io.airbyte.api.model.DbMigrationReadList; -import io.airbyte.api.model.DbMigrationRequestBody; -import io.airbyte.api.model.DestinationCoreConfig; -import io.airbyte.api.model.DestinationCreate; -import io.airbyte.api.model.DestinationDefinitionCreate; -import io.airbyte.api.model.DestinationDefinitionIdRequestBody; -import io.airbyte.api.model.DestinationDefinitionRead; -import io.airbyte.api.model.DestinationDefinitionReadList; -import io.airbyte.api.model.DestinationDefinitionSpecificationRead; -import io.airbyte.api.model.DestinationDefinitionUpdate; -import io.airbyte.api.model.DestinationIdRequestBody; -import io.airbyte.api.model.DestinationOauthConsentRequest; -import io.airbyte.api.model.DestinationRead; -import io.airbyte.api.model.DestinationReadList; -import io.airbyte.api.model.DestinationSearch; -import io.airbyte.api.model.DestinationUpdate; -import io.airbyte.api.model.HealthCheckRead; -import io.airbyte.api.model.ImportRead; -import io.airbyte.api.model.ImportRequestBody; -import io.airbyte.api.model.JobDebugInfoRead; -import io.airbyte.api.model.JobIdRequestBody; -import io.airbyte.api.model.JobInfoRead; -import io.airbyte.api.model.JobListRequestBody; -import io.airbyte.api.model.JobReadList; -import io.airbyte.api.model.LogsRequestBody; -import io.airbyte.api.model.Notification; -import io.airbyte.api.model.NotificationRead; -import io.airbyte.api.model.OAuthConsentRead; -import io.airbyte.api.model.OperationCreate; -import io.airbyte.api.model.OperationIdRequestBody; -import io.airbyte.api.model.OperationRead; -import io.airbyte.api.model.OperationReadList; -import io.airbyte.api.model.OperationUpdate; -import io.airbyte.api.model.OperatorConfiguration; -import io.airbyte.api.model.SetInstancewideDestinationOauthParamsRequestBody; -import io.airbyte.api.model.SetInstancewideSourceOauthParamsRequestBody; -import io.airbyte.api.model.SlugRequestBody; -import io.airbyte.api.model.SourceCoreConfig; -import io.airbyte.api.model.SourceCreate; -import io.airbyte.api.model.SourceDefinitionCreate; -import io.airbyte.api.model.SourceDefinitionIdRequestBody; -import io.airbyte.api.model.SourceDefinitionRead; -import io.airbyte.api.model.SourceDefinitionReadList; -import io.airbyte.api.model.SourceDefinitionSpecificationRead; -import io.airbyte.api.model.SourceDefinitionUpdate; -import io.airbyte.api.model.SourceDiscoverSchemaRead; -import io.airbyte.api.model.SourceIdRequestBody; -import io.airbyte.api.model.SourceOauthConsentRequest; -import io.airbyte.api.model.SourceRead; -import io.airbyte.api.model.SourceReadList; -import io.airbyte.api.model.SourceSearch; -import io.airbyte.api.model.SourceUpdate; -import io.airbyte.api.model.UploadRead; -import io.airbyte.api.model.WebBackendConnectionCreate; -import io.airbyte.api.model.WebBackendConnectionRead; -import io.airbyte.api.model.WebBackendConnectionReadList; -import io.airbyte.api.model.WebBackendConnectionRequestBody; -import io.airbyte.api.model.WebBackendConnectionSearch; -import io.airbyte.api.model.WebBackendConnectionUpdate; -import io.airbyte.api.model.WorkspaceCreate; -import io.airbyte.api.model.WorkspaceGiveFeedback; -import io.airbyte.api.model.WorkspaceIdRequestBody; -import io.airbyte.api.model.WorkspaceRead; -import io.airbyte.api.model.WorkspaceReadList; -import io.airbyte.api.model.WorkspaceUpdate; -import io.airbyte.api.model.WorkspaceUpdateName; +import io.airbyte.api.model.*; import io.airbyte.commons.features.FeatureFlags; import io.airbyte.commons.io.FileTtlManager; import io.airbyte.commons.version.AirbyteVersion; @@ -283,6 +206,12 @@ public NotificationRead tryNotificationConfig(final Notification notification) { return execute(() -> workspacesHandler.tryNotification(notification)); } + // NOTIFICATION + @Override + public NotificationRead createNotification(final NotificationCreate notification) { + return execute(() -> workspacesHandler.createNotification(notification)); + } + // SOURCE @Override diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java index d54f02856df080..045d9d322db3f0 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java @@ -7,20 +7,9 @@ import com.github.slugify.Slugify; import com.google.common.base.Strings; import io.airbyte.analytics.TrackingClientSingleton; -import io.airbyte.api.model.ConnectionRead; -import io.airbyte.api.model.DestinationRead; -import io.airbyte.api.model.Notification; -import io.airbyte.api.model.NotificationRead; +import io.airbyte.api.model.*; import io.airbyte.api.model.NotificationRead.StatusEnum; -import io.airbyte.api.model.SlugRequestBody; -import io.airbyte.api.model.SourceRead; -import io.airbyte.api.model.WorkspaceCreate; -import io.airbyte.api.model.WorkspaceGiveFeedback; -import io.airbyte.api.model.WorkspaceIdRequestBody; -import io.airbyte.api.model.WorkspaceRead; -import io.airbyte.api.model.WorkspaceReadList; -import io.airbyte.api.model.WorkspaceUpdate; -import io.airbyte.api.model.WorkspaceUpdateName; +import io.airbyte.config.StandardNotification; import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; import io.airbyte.config.persistence.ConfigRepository; @@ -183,6 +172,20 @@ public WorkspaceRead updateWorkspaceName(final WorkspaceUpdateName workspaceUpda return buildWorkspaceReadFromId(workspaceId); } + public NotificationRead createNotification(final NotificationCreate notification) throws JsonValidationException, IOException { + final String name = notification.getName(); + final String webhook = notification.getWebhook(); + + final StandardNotification newNotification = new StandardNotification() + .withNotificationId(uuidSupplier.get()) + .withName(name) + .withWebhook(webhook); + + configRepository.writeStandardNotification(newNotification); + + return new NotificationRead().status(StatusEnum.SUCCEEDED); + } + public NotificationRead tryNotification(final Notification notification) { try { final NotificationClient notificationClient = NotificationClient.createNotificationClient(NotificationConverter.toConfig(notification)); diff --git a/docs/reference/api/generated-api-html/index.html b/docs/reference/api/generated-api-html/index.html index ca62e003e7efb5..36c5bffc17e722 100644 --- a/docs/reference/api/generated-api-html/index.html +++ b/docs/reference/api/generated-api-html/index.html @@ -287,6 +287,7 @@

Logs

Notifications

Oauth

@@ -4069,6 +4070,62 @@

422


Notifications

+
+
+ Up +
post /v1/notifications/create
+
Create a new Notification (createNotification)
+
+ + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
NotificationCreate NotificationCreate (required)
+ +
Body Parameter
+ +
+ + + + +

Return type

+ + + + +

Example data

+
Content-Type: application/json
+
{
+  "message" : "message",
+  "status" : "succeeded"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ Successful operation + NotificationRead +

404

+ Object with given id was not found. + NotFoundKnownExceptionInfo +
+
+
+

NotificationCreate - Up

+
+
+
name
+
webhook
+
+

NotificationRead - Up

From 33da4b90a47c66c722a0edd2d7ac3b18c35c4929 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Tue, 15 Mar 2022 22:47:01 -0300 Subject: [PATCH 5/9] correct tables and add notification conn model --- airbyte-api/src/main/openapi/config.yaml | 11 +++++++ .../resources/types/StandardNotification.yaml | 19 ++++++++---- .../types/StandardNotificationConnection.yaml | 29 +++++++++++++++++++ .../V0_35_50_001__AddNotificationTable.java | 13 ++++++--- .../configs_database/schema_dump.txt | 10 +++++-- .../server/handlers/WorkspacesHandler.java | 23 ++++++++++++++- .../api/generated-api-html/index.html | 3 ++ 7 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index 828707605adbf1..6986dcb7ded6ec 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -2014,11 +2014,22 @@ components: required: - name - webhook + - notificationType + - defaultNotification + - tombstone properties: name: type: string webhook: type: string + defaultNotification: + type: boolean + default: false + notificationType: + $ref: "#/components/schemas/SlackNotificationConfiguration" + tombstone: + type: boolean + default: false WorkspaceIdRequestBody: type: object required: diff --git a/airbyte-config/models/src/main/resources/types/StandardNotification.yaml b/airbyte-config/models/src/main/resources/types/StandardNotification.yaml index d54d1c9735d0b8..9d7190aebae400 100644 --- a/airbyte-config/models/src/main/resources/types/StandardNotification.yaml +++ b/airbyte-config/models/src/main/resources/types/StandardNotification.yaml @@ -1,6 +1,6 @@ --- "$schema": http://json-schema.org/draft-07/schema# -"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotificationConfiguration.yaml +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotification.yaml title: StandardNotification description: notification configuration type: object @@ -8,6 +8,8 @@ required: - notificationId - name - webhook + - defaultNotification + - tombstone additionalProperties: false properties: notificationId: @@ -17,8 +19,13 @@ properties: type: string webhook: type: string -# tombstone: -# description: -# if not set or false, the configuration is active. if true, then this -# configuration is permanently off. -# type: boolean + notificationType: + type: string + defaultNotification: + type: boolean + description: if set true the webhook will be triggered to all connections + tombstone: + description: + if not set or false, the configuration is active. if true, then this + configuration is permanently off. + type: boolean diff --git a/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml b/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml new file mode 100644 index 00000000000000..5219154569b080 --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml @@ -0,0 +1,29 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml +title: StandardNotificationConnection +description: notification connection link +type: object +required: + - notificationId + - connectionId + - onSuccess + - onFailure + - tombstone +additionalProperties: false +properties: + notificationId: + type: string + format: uuid + connectionId: + type: string + format: uuid + onSuccess: + type: boolean + onFailure: + type: boolean + tombstone: + description: + if not set or false, the configuration is active. if true, then this + configuration is permanently off. + type: boolean diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java index d4eeb8379f3c45..1fe2fa4ee36506 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -36,23 +36,28 @@ public static void createNotificationConfigTable(final DSLContext ctx) { final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); final Field webhook = DSL.field("webhook", SQLDataType.VARCHAR(516).nullable(false)); + final Field defaultNotification = DSL.field("default_notification", SQLDataType.BOOLEAN.nullable(false)); + final Field notificationType = DSL.field("notification_type", SQLDataType.VARCHAR(256).nullable(false)); + final Field tombstone = DSL.field("tombstone", SQLDataType.BOOLEAN.nullable(false)); ctx.createTableIfNotExists("notification_config") - .columns(id, name, webhook) + .columns(id, name, webhook, defaultNotification, notificationType, tombstone) .execute(); - LOGGER.info("workspace table created"); + LOGGER.info("notification config table created"); } public static void createNotificationConnectionTable(final DSLContext ctx) { final Field connectionId = DSL.field("connection_id", SQLDataType.UUID.nullable(true)); - final Field notificationId = DSL.field("notification_id", SQLDataType.UUID.nullable(true)); + final Field notificationId = DSL.field("notification_id", SQLDataType.UUID.nullable(false)); final Field onSuccess = DSL.field("on_success", SQLDataType.BOOLEAN.nullable(false)); final Field onFailure = DSL.field("on_failure", SQLDataType.BOOLEAN.nullable(false)); + final Field tombstone = DSL.field("tombstone", SQLDataType.BOOLEAN.nullable(false)); ctx.createTableIfNotExists("notification_connection") - .columns(connectionId, notificationId, onSuccess, onFailure) + .columns(connectionId, notificationId, onSuccess, onFailure, tombstone) .execute(); + LOGGER.info("notification connection table created"); } } diff --git a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt index fe239e7333ed53..0628fcaab75f98 100644 --- a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt +++ b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt @@ -114,13 +114,17 @@ create table "public"."connection_operation"( create table "public"."notification_config"( "id" uuid not null, "name" varchar(256) not null, - "webhook" varchar(516) not null + "webhook" varchar(516) not null, + "default_notification" bool not null, + "notification_type" varchar(256) not null, + "tombstone" bool not null ); create table "public"."notification_connection"( "connection_id" uuid null, - "notification_id" uuid null, + "notification_id" uuid not null, "on_success" bool not null, - "on_failure" bool not null + "on_failure" bool not null, + "tombstone" bool not null ); create table "public"."operation"( "id" uuid not null, diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java index 045d9d322db3f0..3ec6e63f579186 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java @@ -175,17 +175,38 @@ public WorkspaceRead updateWorkspaceName(final WorkspaceUpdateName workspaceUpda public NotificationRead createNotification(final NotificationCreate notification) throws JsonValidationException, IOException { final String name = notification.getName(); final String webhook = notification.getWebhook(); + final Boolean defaultNotification = notification.getDefaultNotification(); final StandardNotification newNotification = new StandardNotification() .withNotificationId(uuidSupplier.get()) .withName(name) - .withWebhook(webhook); + .withWebhook(webhook) + .withDefaultNotification(defaultNotification); configRepository.writeStandardNotification(newNotification); + // if (defaultNotification) { + // final StandardNotificationConnection workspaceNotification = new + // StandardNotificationConnection(); + // configRepository.writeStandardNotificationConnection(workspaceNotification); + // } + return new NotificationRead().status(StatusEnum.SUCCEEDED); } + // public void deleteNotification(final NotificationIdRequestBody notificationIdRequestBody) + // throws JsonValidationException, IOException, ConfigNotFoundException { + // // get existing implementation + // final StandardNotification persistedNotification = + // configRepository.getStandardNotification(notificationIdRequestBody.getNotificationId(), false); + // + // // need to implement a list of all connections with that connection + // // tombstone them too + // + // persistedNotification.withTombstone(true); + // configRepository.writeStandardNotification(persistedNotification); + // } + public NotificationRead tryNotification(final Notification notification) { try { final NotificationClient notificationClient = NotificationClient.createNotificationClient(NotificationConverter.toConfig(notification)); diff --git a/docs/reference/api/generated-api-html/index.html b/docs/reference/api/generated-api-html/index.html index 36c5bffc17e722..4d8519ca7c502a 100644 --- a/docs/reference/api/generated-api-html/index.html +++ b/docs/reference/api/generated-api-html/index.html @@ -9161,6 +9161,9 @@

NotificationCreate -
name
webhook
+
defaultNotification
+
notificationType
+
tombstone

From a77622375ca0898bc1834770d0f63793f00c2364 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Fri, 18 Mar 2022 14:51:28 -0300 Subject: [PATCH 6/9] add notification connection --- airbyte-api/src/main/openapi/config.yaml | 104 +++++++++++++----- .../airbyte_cdk/models/airbyte_protocol.py | 2 +- .../java/io/airbyte/config/ConfigSchema.java | 12 +- .../main/resources/types/Notification.yaml | 31 ++++-- ...ction.yaml => NotificationConnection.yaml} | 20 ++-- .../resources/types/NotificationLegacy.yaml | 22 ++++ .../resources/types/StandardNotification.yaml | 31 ------ .../resources/types/StandardWorkspace.yaml | 2 +- .../config/persistence/ConfigRepository.java | 22 +++- .../DatabaseConfigPersistence.java | 51 +++++++-- .../airbyte/config/persistence/MockData.java | 23 +--- .../V0_35_50_001__AddNotificationTable.java | 13 ++- .../configs_database/schema_dump.txt | 9 +- .../SetupForNormalizedTablesTest.java | 22 +--- ...yteConfigDatabaseDenormalization_Test.java | 21 +--- .../notification/NotificationClient.java | 6 +- .../notification/SlackNotificationClient.java | 4 +- .../SlackNotificationClientTest.java | 14 +-- .../scheduler/persistence/JobNotifier.java | 9 +- .../persistence/JobNotifierTest.java | 11 +- .../airbyte/server/apis/ConfigurationApi.java | 8 +- .../converters/NotificationConverter.java | 12 +- .../server/handlers/WorkspacesHandler.java | 75 ++++++++++--- .../server/handlers/ArchiveHandlerTest.java | 4 +- .../handlers/WorkspacesHandlerTest.java | 48 +++++++- .../api/generated-api-html/index.html | 97 +++++++++++++--- .../octavia_cli/generate/yaml_dumpers.py | 1 + 27 files changed, 446 insertions(+), 228 deletions(-) rename airbyte-config/models/src/main/resources/types/{StandardNotificationConnection.yaml => NotificationConnection.yaml} (65%) create mode 100644 airbyte-config/models/src/main/resources/types/NotificationLegacy.yaml delete mode 100644 airbyte-config/models/src/main/resources/types/StandardNotification.yaml diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index 6986dcb7ded6ec..f34c8627999243 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -235,7 +235,7 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/Notification" + $ref: "#/components/schemas/NotificationLegacy" required: true responses: "200": @@ -270,6 +270,28 @@ paths: $ref: "#/components/schemas/NotificationRead" "404": $ref: "#/components/responses/NotFoundResponse" + /v1/notifications/add_connection: + post: + tags: + - notifications + summary: > + Create a link between a connection and a notification + operationId: createNotificationConnection + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationConnectionCreate" + required: true + responses: + "200": + description: Successful operation + content: + application/json: + schema: + $ref: "#/components/schemas/NotificationRead" + "404": + $ref: "#/components/responses/NotFoundResponse" /v1/source_definitions/create: post: tags: @@ -1962,10 +1984,61 @@ components: notifications: type: array items: - $ref: "#/components/schemas/Notification" + $ref: "#/components/schemas/NotificationLegacy" displaySetupWizard: type: boolean - Notification: + NotificationCreate: + type: object + required: + - workspaceId + - name + - webhookUrl + - notificationType + properties: + workspaceId: + type: string + format: uuid + name: + type: string + webhookUrl: + type: string + defaultNotification: + type: boolean + default: false + notificationType: + $ref: "#/components/schemas/NotificationType" + tombstone: + type: boolean + default: false + NotificationConnectionCreate: + type: object + required: + - workspaceId + - notificationId + - connectionId + - sendOnSuccess + - sendOnFailure + - tombstone + properties: + workspaceId: + type: string + format: uuid + notificationId: + type: string + format: uuid + connectionId: + type: string + format: uuid + sendOnSuccess: + type: boolean + default: false + sendOnFailure: + type: boolean + default: true + tombstone: + type: boolean + default: false + NotificationLegacy: type: object required: - notificationType @@ -2009,27 +2082,6 @@ components: - failed message: type: string - NotificationCreate: - type: object - required: - - name - - webhook - - notificationType - - defaultNotification - - tombstone - properties: - name: - type: string - webhook: - type: string - defaultNotification: - type: boolean - default: false - notificationType: - $ref: "#/components/schemas/SlackNotificationConfiguration" - tombstone: - type: boolean - default: false WorkspaceIdRequestBody: type: object required: @@ -2079,7 +2131,7 @@ components: notifications: type: array items: - $ref: "#/components/schemas/Notification" + $ref: "#/components/schemas/NotificationLegacy" firstCompletedSync: type: boolean feedbackDone: @@ -2121,7 +2173,7 @@ components: notifications: type: array items: - $ref: "#/components/schemas/Notification" + $ref: "#/components/schemas/NotificationLegacy" WorkspaceGiveFeedback: type: object required: diff --git a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py index 39680a330c04a4..f703cbd8080c7a 100644 --- a/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py +++ b/airbyte-cdk/python/airbyte_cdk/models/airbyte_protocol.py @@ -240,7 +240,7 @@ class Config: ) spec: Optional[ConnectorSpecification] = None connectionStatus: Optional[AirbyteConnectionStatus] = None - catalog: Optional[AirbyteCatalog] = Field(None, description="catalog message: the calalog") + catalog: Optional[AirbyteCatalog] = Field(None, description="catalog message: the catalog") record: Optional[AirbyteRecordMessage] = Field(None, description="record message: the record") state: Optional[AirbyteStateMessage] = Field( None, diff --git a/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java b/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java index fbcfbd7be41aa3..880df3a7211624 100644 --- a/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java +++ b/airbyte-config/models/src/main/java/io/airbyte/config/ConfigSchema.java @@ -18,11 +18,17 @@ public enum ConfigSchema implements AirbyteConfig { "workspaceId"), // notification - STANDARD_NOTIFICATION("StandardNotification.yaml", - StandardNotification.class, - standardNotification -> standardNotification.getNotificationId().toString(), + NOTIFICATION("Notification.yaml", + Notification.class, + Notification -> Notification.getNotificationId().toString(), "notificationId"), + // notification connection + NOTIFICATION_CONNECTION("NotificationConnection.yaml", + NotificationConnection.class, + NotificationConnection -> NotificationConnection.getNotificationConnectionId().toString(), + "notificationConnectionId"), + // source STANDARD_SOURCE_DEFINITION("StandardSourceDefinition.yaml", StandardSourceDefinition.class, diff --git a/airbyte-config/models/src/main/resources/types/Notification.yaml b/airbyte-config/models/src/main/resources/types/Notification.yaml index 3214c8cf4835a3..341fd62841bfdd 100644 --- a/airbyte-config/models/src/main/resources/types/Notification.yaml +++ b/airbyte-config/models/src/main/resources/types/Notification.yaml @@ -2,21 +2,32 @@ "$schema": http://json-schema.org/draft-07/schema# "$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/Notification.yaml title: Notification -description: Notification Settings +description: notification configuration type: object required: + - workspaceId + - name + - webhookUrl - notificationType -additionalProperties: true +additionalProperties: false properties: - # Instead of this type field, we would prefer a json schema "oneOf" but unfortunately, - # the jsonschema2pojo does not seem to support it yet: https://github.com/joelittlejohn/jsonschema2pojo/issues/392 + workspaceId: + type: string + format: uuid + notificationId: + type: string + format: uuid + name: + type: string + webhookUrl: + type: string notificationType: "$ref": NotificationType.yaml - sendOnSuccess: + defaultNotification: type: boolean - default: false - sendOnFailure: + description: if set true the webhook will be triggered to all connections + tombstone: + description: + if not set or false, the configuration is active. if true, then this + configuration is permanently off. type: boolean - default: true - slackConfiguration: - "$ref": SlackNotificationConfiguration.yaml diff --git a/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml b/airbyte-config/models/src/main/resources/types/NotificationConnection.yaml similarity index 65% rename from airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml rename to airbyte-config/models/src/main/resources/types/NotificationConnection.yaml index 5219154569b080..184bd6c63df112 100644 --- a/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml +++ b/airbyte-config/models/src/main/resources/types/NotificationConnection.yaml @@ -1,26 +1,32 @@ --- "$schema": http://json-schema.org/draft-07/schema# -"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotificationConnection.yaml -title: StandardNotificationConnection +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/NotificationConnection.yaml +title: NotificationConnection description: notification connection link type: object required: + - workspaceId - notificationId - - connectionId - - onSuccess - - onFailure + - sendOnSuccess + - sendOnFailure - tombstone additionalProperties: false properties: + notificationConnectionId: + type: string + format: uuid + workspaceId: + type: string + format: uuid notificationId: type: string format: uuid connectionId: type: string format: uuid - onSuccess: + sendOnSuccess: type: boolean - onFailure: + sendOnFailure: type: boolean tombstone: description: diff --git a/airbyte-config/models/src/main/resources/types/NotificationLegacy.yaml b/airbyte-config/models/src/main/resources/types/NotificationLegacy.yaml new file mode 100644 index 00000000000000..42a725739adccd --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/NotificationLegacy.yaml @@ -0,0 +1,22 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/NotificationLegacy.yaml +title: NotificationLegacy +description: Notification Settings +type: object +required: + - notificationType +additionalProperties: true +properties: + # Instead of this type field, we would prefer a json schema "oneOf" but unfortunately, + # the jsonschema2pojo does not seem to support it yet: https://github.com/joelittlejohn/jsonschema2pojo/issues/392 + notificationType: + "$ref": NotificationType.yaml + sendOnSuccess: + type: boolean + default: false + sendOnFailure: + type: boolean + default: true + slackConfiguration: + "$ref": SlackNotificationConfiguration.yaml diff --git a/airbyte-config/models/src/main/resources/types/StandardNotification.yaml b/airbyte-config/models/src/main/resources/types/StandardNotification.yaml deleted file mode 100644 index 9d7190aebae400..00000000000000 --- a/airbyte-config/models/src/main/resources/types/StandardNotification.yaml +++ /dev/null @@ -1,31 +0,0 @@ ---- -"$schema": http://json-schema.org/draft-07/schema# -"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardNotification.yaml -title: StandardNotification -description: notification configuration -type: object -required: - - notificationId - - name - - webhook - - defaultNotification - - tombstone -additionalProperties: false -properties: - notificationId: - type: string - format: uuid - name: - type: string - webhook: - type: string - notificationType: - type: string - defaultNotification: - type: boolean - description: if set true the webhook will be triggered to all connections - tombstone: - description: - if not set or false, the configuration is active. if true, then this - configuration is permanently off. - type: boolean diff --git a/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml b/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml index 44a44070ae6b70..8fa1305365492c 100644 --- a/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml +++ b/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml @@ -42,7 +42,7 @@ properties: notifications: type: array items: - "$ref": Notification.yaml + "$ref": NotificationLegacy.yaml firstCompletedSync: type: boolean feedbackDone: diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index c2b79de76990ac..78f6dab161a623 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -120,12 +120,30 @@ public List listStandardWorkspaces(final boolean includeTombs return workspaces; } + public List listNotifications(final boolean includeTombstone) throws JsonValidationException, IOException { + + final List notifications = new ArrayList<>(); + + for (final Notification notification : persistence.listConfigs(ConfigSchema.NOTIFICATION, Notification.class)) { + if (!MoreBooleans.isTruthy(notification.getTombstone()) || includeTombstone) { + notifications.add(notification); + } + } + + return notifications; + } + public void writeStandardWorkspace(final StandardWorkspace workspace) throws JsonValidationException, IOException { persistence.writeConfig(ConfigSchema.STANDARD_WORKSPACE, workspace.getWorkspaceId().toString(), workspace); } - public void writeStandardNotification(final StandardNotification notification) throws JsonValidationException, IOException { - persistence.writeConfig(ConfigSchema.STANDARD_NOTIFICATION, notification.getNotificationId().toString(), notification); + public void writeNotification(final Notification notification) throws JsonValidationException, IOException { + persistence.writeConfig(ConfigSchema.NOTIFICATION, notification.getNotificationId().toString(), notification); + } + + public void writeNotificationConnection(final NotificationConnection notificationConnection) throws JsonValidationException, IOException { + persistence.writeConfig(ConfigSchema.NOTIFICATION_CONNECTION, notificationConnection.getNotificationConnectionId().toString(), + notificationConnection); } public void setFeedback(final UUID workflowId) throws JsonValidationException, ConfigNotFoundException, IOException { diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java index b988fa845b46a1..6cedc5436a1bf7 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java @@ -289,10 +289,10 @@ private List> listStandardWorkspaceWithMet final List> standardWorkspaces = new ArrayList<>(); for (final Record record : result) { - final List notificationList = new ArrayList<>(); + final List notificationList = new ArrayList<>(); final List fetchedNotifications = Jsons.deserialize(record.get(WORKSPACE.NOTIFICATIONS).data(), List.class); for (final Object notification : fetchedNotifications) { - notificationList.add(Jsons.convertValue(notification, Notification.class)); + notificationList.add(Jsons.convertValue(notification, NotificationLegacy.class)); } final StandardWorkspace workspace = buildStandardWorkspace(record, notificationList); standardWorkspaces.add(new ConfigWithMetadata<>( @@ -305,7 +305,7 @@ private List> listStandardWorkspaceWithMet return standardWorkspaces; } - private StandardWorkspace buildStandardWorkspace(final Record record, final List notificationList) { + private StandardWorkspace buildStandardWorkspace(final Record record, final List notificationList) { return new StandardWorkspace() .withWorkspaceId(record.get(WORKSPACE.ID)) .withName(record.get(WORKSPACE.NAME)) @@ -758,19 +758,44 @@ private void writeStandardWorkspace(final List configs) throw }); } - private void writeStandardNotification(final List configs) throws IOException { + private void writeNotification(final List configs) throws IOException { database.transaction(ctx -> { - writeStandardNotification(configs, ctx); + writeNotification(configs, ctx); return null; }); } - private void writeStandardNotification(final List configs, final DSLContext ctx) { - configs.forEach((standardNotification) -> { + private void writeNotificationConnection(final List configs) throws IOException { + database.transaction(ctx -> { + writeNotificationConnection(configs, ctx); + return null; + }); + } + + private void writeNotification(final List configs, final DSLContext ctx) { + configs.forEach((Notification) -> { ctx.insertInto(NOTIFICATION_CONFIG) - .set(NOTIFICATION_CONFIG.ID, standardNotification.getNotificationId()) - .set(NOTIFICATION_CONFIG.NAME, standardNotification.getName()) - .set(NOTIFICATION_CONFIG.WEBHOOK, standardNotification.getWebhook()) + .set(NOTIFICATION_CONFIG.ID, Notification.getNotificationId()) + .set(NOTIFICATION_CONFIG.WORKSPACE_ID, Notification.getWorkspaceId()) + .set(NOTIFICATION_CONFIG.NAME, Notification.getName()) + .set(NOTIFICATION_CONFIG.WEBHOOK_URL, Notification.getWebhookUrl()) + .set(NOTIFICATION_CONFIG.DEFAULT_NOTIFICATION, Notification.getDefaultNotification()) + .set(NOTIFICATION_CONFIG.NOTIFICATION_TYPE, Notification.getNotificationType().value()) + .set(NOTIFICATION_CONFIG.TOMBSTONE, Notification.getTombstone()) + .execute(); + }); + } + + private void writeNotificationConnection(final List configs, final DSLContext ctx) { + configs.forEach((NotificationConnection) -> { + ctx.insertInto(NOTIFICATION_CONNECTION) + .set(NOTIFICATION_CONNECTION.NOTIFICATION_CONNECTION_ID, NotificationConnection.getNotificationConnectionId()) + .set(NOTIFICATION_CONNECTION.WORKSPACE_ID, NotificationConnection.getWorkspaceId()) + .set(NOTIFICATION_CONNECTION.NOTIFICATION_ID, NotificationConnection.getNotificationId()) + .set(NOTIFICATION_CONNECTION.CONNECTION_ID, NotificationConnection.getConnectionId()) + .set(NOTIFICATION_CONNECTION.SEND_ON_SUCCESS, NotificationConnection.getSendOnSuccess()) + .set(NOTIFICATION_CONNECTION.SEND_ON_FAILURE, NotificationConnection.getSendOnFailure()) + .set(NOTIFICATION_CONNECTION.TOMBSTONE, NotificationConnection.getTombstone()) .execute(); }); } @@ -1377,8 +1402,10 @@ public void writeConfigs(final AirbyteConfig configType, final Map (ActorCatalog) c).collect(Collectors.toList())); } else if (configType == ConfigSchema.ACTOR_CATALOG_FETCH_EVENT) { writeActorCatalogFetchEvent(configs.values().stream().map(c -> (ActorCatalogFetchEvent) c).collect(Collectors.toList())); - } else if (configType == ConfigSchema.STANDARD_NOTIFICATION) { - writeStandardNotification(configs.values().stream().map(c -> (StandardNotification) c).collect(Collectors.toList())); + } else if (configType == ConfigSchema.NOTIFICATION) { + writeNotification(configs.values().stream().map(c -> (Notification) c).collect(Collectors.toList())); + } else if (configType == ConfigSchema.NOTIFICATION_CONNECTION) { + writeNotificationConnection(configs.values().stream().map(c -> (NotificationConnection) c).collect(Collectors.toList())); } else { throw new IllegalArgumentException("Unknown Config Type " + configType); } diff --git a/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java b/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java index 3be5c1defa5aaa..3bc6f6951c3c3b 100644 --- a/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java +++ b/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java @@ -6,33 +6,14 @@ import com.google.common.collect.Lists; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.ActorCatalog; -import io.airbyte.config.ActorCatalogFetchEvent; -import io.airbyte.config.ActorDefinitionResourceRequirements; -import io.airbyte.config.DestinationConnection; -import io.airbyte.config.DestinationOAuthParameter; +import io.airbyte.config.*; import io.airbyte.config.JobSyncConfig.NamespaceDefinitionType; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; -import io.airbyte.config.OperatorDbt; -import io.airbyte.config.OperatorNormalization; import io.airbyte.config.OperatorNormalization.Option; -import io.airbyte.config.ResourceRequirements; -import io.airbyte.config.Schedule; import io.airbyte.config.Schedule.TimeUnit; -import io.airbyte.config.SlackNotificationConfiguration; -import io.airbyte.config.SourceConnection; -import io.airbyte.config.SourceOAuthParameter; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; import io.airbyte.config.StandardSourceDefinition.SourceType; -import io.airbyte.config.StandardSync; import io.airbyte.config.StandardSync.Status; -import io.airbyte.config.StandardSyncOperation; import io.airbyte.config.StandardSyncOperation.OperatorType; -import io.airbyte.config.StandardSyncState; -import io.airbyte.config.StandardWorkspace; -import io.airbyte.config.State; import io.airbyte.protocol.models.AirbyteCatalog; import io.airbyte.protocol.models.AuthSpecification; import io.airbyte.protocol.models.AuthSpecification.AuthType; @@ -85,7 +66,7 @@ public class MockData { private static final Instant NOW = Instant.parse("2021-12-15T20:30:40.00Z"); public static List standardWorkspaces() { - final Notification notification = new Notification() + final NotificationLegacy notification = new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSendOnFailure(true) .withSendOnSuccess(true) diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java index 1fe2fa4ee36506..005dabdc78a81e 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/instance/configs/migrations/V0_35_50_001__AddNotificationTable.java @@ -34,28 +34,31 @@ public static void migrate(final DSLContext ctx) { public static void createNotificationConfigTable(final DSLContext ctx) { final Field id = DSL.field("id", SQLDataType.UUID.nullable(false)); + final Field workspaceId = DSL.field("workspace_id", SQLDataType.UUID.nullable(false)); final Field name = DSL.field("name", SQLDataType.VARCHAR(256).nullable(false)); - final Field webhook = DSL.field("webhook", SQLDataType.VARCHAR(516).nullable(false)); + final Field webhookUrl = DSL.field("webhook_url", SQLDataType.VARCHAR(516).nullable(false)); final Field defaultNotification = DSL.field("default_notification", SQLDataType.BOOLEAN.nullable(false)); final Field notificationType = DSL.field("notification_type", SQLDataType.VARCHAR(256).nullable(false)); final Field tombstone = DSL.field("tombstone", SQLDataType.BOOLEAN.nullable(false)); ctx.createTableIfNotExists("notification_config") - .columns(id, name, webhook, defaultNotification, notificationType, tombstone) + .columns(id, workspaceId, name, webhookUrl, defaultNotification, notificationType, tombstone) .execute(); LOGGER.info("notification config table created"); } public static void createNotificationConnectionTable(final DSLContext ctx) { + final Field notificationConnectionId = DSL.field("notification_connection_id", SQLDataType.UUID.nullable(false)); + final Field workspaceId = DSL.field("workspace_id", SQLDataType.UUID.nullable(false)); final Field connectionId = DSL.field("connection_id", SQLDataType.UUID.nullable(true)); final Field notificationId = DSL.field("notification_id", SQLDataType.UUID.nullable(false)); - final Field onSuccess = DSL.field("on_success", SQLDataType.BOOLEAN.nullable(false)); - final Field onFailure = DSL.field("on_failure", SQLDataType.BOOLEAN.nullable(false)); + final Field sendOnSuccess = DSL.field("send_on_success", SQLDataType.BOOLEAN.nullable(false)); + final Field sendOnFailure = DSL.field("send_on_failure", SQLDataType.BOOLEAN.nullable(false)); final Field tombstone = DSL.field("tombstone", SQLDataType.BOOLEAN.nullable(false)); ctx.createTableIfNotExists("notification_connection") - .columns(connectionId, notificationId, onSuccess, onFailure, tombstone) + .columns(notificationConnectionId, workspaceId, connectionId, notificationId, sendOnSuccess, sendOnFailure, tombstone) .execute(); LOGGER.info("notification connection table created"); } diff --git a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt index 0628fcaab75f98..439e7b6f6bca11 100644 --- a/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt +++ b/airbyte-db/lib/src/main/resources/configs_database/schema_dump.txt @@ -113,17 +113,20 @@ create table "public"."connection_operation"( ); create table "public"."notification_config"( "id" uuid not null, + "workspace_id" uuid not null, "name" varchar(256) not null, - "webhook" varchar(516) not null, + "webhook_url" varchar(516) not null, "default_notification" bool not null, "notification_type" varchar(256) not null, "tombstone" bool not null ); create table "public"."notification_connection"( + "notification_connection_id" uuid not null, + "workspace_id" uuid not null, "connection_id" uuid null, "notification_id" uuid not null, - "on_success" bool not null, - "on_failure" bool not null, + "send_on_success" bool not null, + "send_on_failure" bool not null, "tombstone" bool not null ); create table "public"."operation"( diff --git a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java index 66198e9032f330..88a3c39b1a6fae 100644 --- a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java +++ b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java @@ -10,32 +10,14 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.Lists; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.AirbyteConfig; -import io.airbyte.config.ConfigSchema; -import io.airbyte.config.DestinationConnection; -import io.airbyte.config.DestinationOAuthParameter; +import io.airbyte.config.*; import io.airbyte.config.JobSyncConfig.NamespaceDefinitionType; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; -import io.airbyte.config.OperatorDbt; -import io.airbyte.config.OperatorNormalization; import io.airbyte.config.OperatorNormalization.Option; -import io.airbyte.config.ResourceRequirements; -import io.airbyte.config.Schedule; import io.airbyte.config.Schedule.TimeUnit; -import io.airbyte.config.SlackNotificationConfiguration; -import io.airbyte.config.SourceConnection; -import io.airbyte.config.SourceOAuthParameter; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; import io.airbyte.config.StandardSourceDefinition.SourceType; -import io.airbyte.config.StandardSync; import io.airbyte.config.StandardSync.Status; -import io.airbyte.config.StandardSyncOperation; import io.airbyte.config.StandardSyncOperation.OperatorType; -import io.airbyte.config.StandardSyncState; -import io.airbyte.config.StandardWorkspace; -import io.airbyte.config.State; import io.airbyte.protocol.models.AirbyteCatalog; import io.airbyte.protocol.models.AuthSpecification; import io.airbyte.protocol.models.AuthSpecification.AuthType; @@ -155,7 +137,7 @@ private static void insertConfigRecord( } public static StandardWorkspace standardWorkspace() { - final Notification notification = new Notification() + final NotificationLegacy notification = new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSendOnFailure(true) .withSendOnSuccess(true) diff --git a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java index d2020d279b1925..908983500bf665 100644 --- a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java +++ b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java @@ -15,22 +15,7 @@ import io.airbyte.commons.enums.Enums; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.DestinationConnection; -import io.airbyte.config.DestinationOAuthParameter; -import io.airbyte.config.Notification; -import io.airbyte.config.OperatorDbt; -import io.airbyte.config.OperatorNormalization; -import io.airbyte.config.ResourceRequirements; -import io.airbyte.config.Schedule; -import io.airbyte.config.SourceConnection; -import io.airbyte.config.SourceOAuthParameter; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; -import io.airbyte.config.StandardSync; -import io.airbyte.config.StandardSyncOperation; -import io.airbyte.config.StandardSyncState; -import io.airbyte.config.StandardWorkspace; -import io.airbyte.config.State; +import io.airbyte.config.*; import io.airbyte.db.Database; import io.airbyte.db.instance.configs.AbstractConfigsDatabaseTest; import io.airbyte.db.instance.configs.migrations.V0_32_8_001__AirbyteConfigDatabaseDenormalization.ActorType; @@ -103,10 +88,10 @@ private void assertDataForWorkspace(final DSLContext context) { final Record workspace = workspaces.get(0); - final List notificationList = new ArrayList<>(); + final List notificationList = new ArrayList<>(); final List fetchedNotifications = Jsons.deserialize(workspace.get(notifications).data(), List.class); for (Object notification : fetchedNotifications) { - notificationList.add(Jsons.convertValue(notification, Notification.class)); + notificationList.add(Jsons.convertValue(notification, NotificationLegacy.class)); } final StandardWorkspace workspaceFromNewTable = new StandardWorkspace() .withWorkspaceId(workspace.get(id)) diff --git a/airbyte-notification/src/main/java/io/airbyte/notification/NotificationClient.java b/airbyte-notification/src/main/java/io/airbyte/notification/NotificationClient.java index 7de40e659fea8c..871507ba9394a0 100644 --- a/airbyte-notification/src/main/java/io/airbyte/notification/NotificationClient.java +++ b/airbyte-notification/src/main/java/io/airbyte/notification/NotificationClient.java @@ -4,8 +4,8 @@ package io.airbyte.notification; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; import java.io.IOException; public abstract class NotificationClient { @@ -13,7 +13,7 @@ public abstract class NotificationClient { protected boolean sendOnSuccess; protected boolean sendOnFailure; - public NotificationClient(final Notification notification) { + public NotificationClient(final NotificationLegacy notification) { this.sendOnSuccess = notification.getSendOnSuccess(); this.sendOnFailure = notification.getSendOnFailure(); } @@ -36,7 +36,7 @@ public abstract boolean notifyJobSuccess( public abstract boolean notifyFailure(String message) throws IOException, InterruptedException; - public static NotificationClient createNotificationClient(final Notification notification) { + public static NotificationClient createNotificationClient(final NotificationLegacy notification) { if (notification.getNotificationType() == NotificationType.SLACK) { return new SlackNotificationClient(notification); } else { diff --git a/airbyte-notification/src/main/java/io/airbyte/notification/SlackNotificationClient.java b/airbyte-notification/src/main/java/io/airbyte/notification/SlackNotificationClient.java index 533781fb033b80..acb577234f75cf 100644 --- a/airbyte-notification/src/main/java/io/airbyte/notification/SlackNotificationClient.java +++ b/airbyte-notification/src/main/java/io/airbyte/notification/SlackNotificationClient.java @@ -8,7 +8,7 @@ import com.google.common.collect.ImmutableMap.Builder; import io.airbyte.commons.json.Jsons; import io.airbyte.commons.resources.MoreResources; -import io.airbyte.config.Notification; +import io.airbyte.config.NotificationLegacy; import io.airbyte.config.SlackNotificationConfiguration; import java.io.IOException; import java.net.URI; @@ -38,7 +38,7 @@ public class SlackNotificationClient extends NotificationClient { .build(); private final SlackNotificationConfiguration config; - public SlackNotificationClient(final Notification notification) { + public SlackNotificationClient(final NotificationLegacy notification) { super(notification); this.config = notification.getSlackConfiguration(); } diff --git a/airbyte-notification/src/test/java/io/airbyte/notification/SlackNotificationClientTest.java b/airbyte-notification/src/test/java/io/airbyte/notification/SlackNotificationClientTest.java index f7ba698d7900de..580052429b7751 100644 --- a/airbyte-notification/src/test/java/io/airbyte/notification/SlackNotificationClientTest.java +++ b/airbyte-notification/src/test/java/io/airbyte/notification/SlackNotificationClientTest.java @@ -13,8 +13,8 @@ import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; import io.airbyte.config.SlackNotificationConfiguration; import java.io.IOException; import java.io.InputStream; @@ -61,7 +61,7 @@ void testBadResponseWrongNotificationMessage() throws IOException, InterruptedEx final String message = UUID.randomUUID().toString(); server.createContext("/test", new ServerHandler("Message mismatched")); final SlackNotificationClient client = - new SlackNotificationClient(new Notification() + new SlackNotificationClient(new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration().withWebhook(WEBHOOK_URL + server.getAddress().getPort() + "/test"))); assertThrows(IOException.class, () -> client.notifyFailure(message)); @@ -70,7 +70,7 @@ void testBadResponseWrongNotificationMessage() throws IOException, InterruptedEx @Test void testBadWebhookUrl() { final SlackNotificationClient client = - new SlackNotificationClient(new Notification() + new SlackNotificationClient(new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration().withWebhook(WEBHOOK_URL + server.getAddress().getPort() + "/bad"))); assertThrows(IOException.class, () -> client.notifyJobFailure("source-test", "destination-test", "job description", "logUrl")); @@ -80,7 +80,7 @@ void testBadWebhookUrl() { void testEmptyWebhookUrl() throws IOException, InterruptedException { final SlackNotificationClient client = new SlackNotificationClient( - new Notification().withNotificationType(NotificationType.SLACK).withSlackConfiguration(new SlackNotificationConfiguration())); + new NotificationLegacy().withNotificationType(NotificationType.SLACK).withSlackConfiguration(new SlackNotificationConfiguration())); assertFalse(client.notifyJobFailure("source-test", "destination-test", "job description", "logUrl")); } @@ -89,7 +89,7 @@ void testNotify() throws IOException, InterruptedException { final String message = UUID.randomUUID().toString(); server.createContext("/test", new ServerHandler(message)); final SlackNotificationClient client = - new SlackNotificationClient(new Notification() + new SlackNotificationClient(new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration().withWebhook(WEBHOOK_URL + server.getAddress().getPort() + "/test"))); assertTrue(client.notifyFailure(message)); @@ -100,7 +100,7 @@ void testNotify() throws IOException, InterruptedException { void testNotifyJobFailure() throws IOException, InterruptedException { server.createContext("/test", new ServerHandler(EXPECTED_FAIL_MESSAGE)); final SlackNotificationClient client = - new SlackNotificationClient(new Notification() + new SlackNotificationClient(new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration().withWebhook(WEBHOOK_URL + server.getAddress().getPort() + "/test"))); assertTrue(client.notifyJobFailure("source-test", "destination-test", "job description", "logUrl")); @@ -110,7 +110,7 @@ void testNotifyJobFailure() throws IOException, InterruptedException { void testNotifyJobSuccess() throws IOException, InterruptedException { server.createContext("/test", new ServerHandler(EXPECTED_SUCCESS_MESSAGE)); final SlackNotificationClient client = - new SlackNotificationClient(new Notification() + new SlackNotificationClient(new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSendOnSuccess(true) .withSlackConfiguration(new SlackNotificationConfiguration().withWebhook(WEBHOOK_URL + server.getAddress().getPort() + "/test"))); diff --git a/airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/JobNotifier.java b/airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/JobNotifier.java index 4733d0f6524203..551323ce56f44e 100644 --- a/airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/JobNotifier.java +++ b/airbyte-scheduler/persistence/src/main/java/io/airbyte/scheduler/persistence/JobNotifier.java @@ -9,11 +9,8 @@ import com.google.common.collect.ImmutableMap.Builder; import io.airbyte.analytics.TrackingClient; import io.airbyte.commons.map.MoreMaps; -import io.airbyte.config.Notification; +import io.airbyte.config.*; import io.airbyte.config.Notification.NotificationType; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; -import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigRepository; import io.airbyte.notification.NotificationClient; import io.airbyte.scheduler.models.Job; @@ -78,7 +75,7 @@ private void notifyJob(final String reason, final String action, final Job job) final ImmutableMap jobMetadata = TrackingMetadata.generateJobAttemptMetadata(job); final ImmutableMap sourceMetadata = TrackingMetadata.generateSourceDefinitionMetadata(sourceDefinition); final ImmutableMap destinationMetadata = TrackingMetadata.generateDestinationDefinitionMetadata(destinationDefinition); - for (final Notification notification : workspace.getNotifications()) { + for (final NotificationLegacy notification : workspace.getNotifications()) { final NotificationClient notificationClient = getNotificationClient(notification); try { final Builder notificationMetadata = ImmutableMap.builder(); @@ -121,7 +118,7 @@ public void successJob(final Job job) { notifyJob(null, SUCCESS_NOTIFICATION, job); } - protected NotificationClient getNotificationClient(final Notification notification) { + protected NotificationClient getNotificationClient(final NotificationLegacy notification) { return NotificationClient.createNotificationClient(notification); } diff --git a/airbyte-scheduler/persistence/src/test/java/io/airbyte/scheduler/persistence/JobNotifierTest.java b/airbyte-scheduler/persistence/src/test/java/io/airbyte/scheduler/persistence/JobNotifierTest.java index 83385d404ffbe7..5fb9c97c2c69fc 100644 --- a/airbyte-scheduler/persistence/src/test/java/io/airbyte/scheduler/persistence/JobNotifierTest.java +++ b/airbyte-scheduler/persistence/src/test/java/io/airbyte/scheduler/persistence/JobNotifierTest.java @@ -14,14 +14,9 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap.Builder; import io.airbyte.analytics.TrackingClient; -import io.airbyte.config.JobConfig; +import io.airbyte.config.*; import io.airbyte.config.JobConfig.ConfigType; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; -import io.airbyte.config.SlackNotificationConfiguration; -import io.airbyte.config.StandardDestinationDefinition; -import io.airbyte.config.StandardSourceDefinition; -import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; import io.airbyte.config.persistence.ConfigRepository; import io.airbyte.notification.NotificationClient; @@ -127,8 +122,8 @@ private static Job createJob() { NOW.getEpochSecond() + 123456L); } - private static Notification getSlackNotification() { - return new Notification() + private static NotificationLegacy getSlackNotification() { + return new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration() .withWebhook("http://random.webhook.url/hooks.slack.com/")); diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java index 570cd844179b1b..4a0f74fd4b0cdb 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java +++ b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java @@ -202,7 +202,7 @@ public void updateWorkspaceFeedback(final WorkspaceGiveFeedback workspaceGiveFee } @Override - public NotificationRead tryNotificationConfig(final Notification notification) { + public NotificationRead tryNotificationConfig(final NotificationLegacy notification) { return execute(() -> workspacesHandler.tryNotification(notification)); } @@ -212,6 +212,12 @@ public NotificationRead createNotification(final NotificationCreate notification return execute(() -> workspacesHandler.createNotification(notification)); } + // NOTIFICATION + @Override + public NotificationRead createNotificationConnection(final NotificationConnectionCreate notificationConnection) { + return execute(() -> workspacesHandler.createNotificationConnection(notificationConnection)); + } + // SOURCE @Override diff --git a/airbyte-server/src/main/java/io/airbyte/server/converters/NotificationConverter.java b/airbyte-server/src/main/java/io/airbyte/server/converters/NotificationConverter.java index 17292b10cf17e5..7340b1174fe83f 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/converters/NotificationConverter.java +++ b/airbyte-server/src/main/java/io/airbyte/server/converters/NotificationConverter.java @@ -10,12 +10,12 @@ public class NotificationConverter { - public static List toConfigList(final List notifications) { + public static List toConfigList(final List notifications) { return notifications.stream().map(NotificationConverter::toConfig).collect(Collectors.toList()); } - public static io.airbyte.config.Notification toConfig(final io.airbyte.api.model.Notification notification) { - return new io.airbyte.config.Notification() + public static io.airbyte.config.NotificationLegacy toConfig(final io.airbyte.api.model.NotificationLegacy notification) { + return new io.airbyte.config.NotificationLegacy() .withNotificationType(Enums.convertTo(notification.getNotificationType(), io.airbyte.config.Notification.NotificationType.class)) .withSendOnSuccess(notification.getSendOnSuccess()) .withSendOnFailure(notification.getSendOnFailure()) @@ -27,12 +27,12 @@ private static io.airbyte.config.SlackNotificationConfiguration toConfig(final i .withWebhook(notification.getWebhook()); } - public static List toApiList(final List notifications) { + public static List toApiList(final List notifications) { return notifications.stream().map(NotificationConverter::toApi).collect(Collectors.toList()); } - public static io.airbyte.api.model.Notification toApi(final io.airbyte.config.Notification notification) { - return new io.airbyte.api.model.Notification() + public static io.airbyte.api.model.NotificationLegacy toApi(final io.airbyte.config.NotificationLegacy notification) { + return new io.airbyte.api.model.NotificationLegacy() .notificationType(Enums.convertTo(notification.getNotificationType(), io.airbyte.api.model.NotificationType.class)) .sendOnSuccess(notification.getSendOnSuccess()) .sendOnFailure(notification.getSendOnFailure()) diff --git a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java index 3ec6e63f579186..22d08e949d4c0d 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java +++ b/airbyte-server/src/main/java/io/airbyte/server/handlers/WorkspacesHandler.java @@ -7,9 +7,26 @@ import com.github.slugify.Slugify; import com.google.common.base.Strings; import io.airbyte.analytics.TrackingClientSingleton; -import io.airbyte.api.model.*; +import io.airbyte.api.model.ConnectionRead; +import io.airbyte.api.model.DestinationRead; +import io.airbyte.api.model.NotificationConnectionCreate; +import io.airbyte.api.model.NotificationCreate; +import io.airbyte.api.model.NotificationLegacy; +import io.airbyte.api.model.NotificationRead; import io.airbyte.api.model.NotificationRead.StatusEnum; -import io.airbyte.config.StandardNotification; +import io.airbyte.api.model.SlugRequestBody; +import io.airbyte.api.model.SourceRead; +import io.airbyte.api.model.WorkspaceCreate; +import io.airbyte.api.model.WorkspaceGiveFeedback; +import io.airbyte.api.model.WorkspaceIdRequestBody; +import io.airbyte.api.model.WorkspaceRead; +import io.airbyte.api.model.WorkspaceReadList; +import io.airbyte.api.model.WorkspaceUpdate; +import io.airbyte.api.model.WorkspaceUpdateName; +import io.airbyte.commons.enums.Enums; +import io.airbyte.config.Notification; +import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationConnection; import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; import io.airbyte.config.persistence.ConfigRepository; @@ -174,40 +191,70 @@ public WorkspaceRead updateWorkspaceName(final WorkspaceUpdateName workspaceUpda public NotificationRead createNotification(final NotificationCreate notification) throws JsonValidationException, IOException { final String name = notification.getName(); - final String webhook = notification.getWebhook(); + final String webhookUrl = notification.getWebhookUrl(); + final UUID workspaceId = notification.getWorkspaceId(); final Boolean defaultNotification = notification.getDefaultNotification(); + final Boolean tombstone = notification.getTombstone(); + final NotificationType notificationType = + Enums.convertTo(notification.getNotificationType(), io.airbyte.config.Notification.NotificationType.class); - final StandardNotification newNotification = new StandardNotification() + final Notification newNotification = new Notification() .withNotificationId(uuidSupplier.get()) + .withWorkspaceId(workspaceId) .withName(name) - .withWebhook(webhook) - .withDefaultNotification(defaultNotification); + .withWebhookUrl(webhookUrl) + .withDefaultNotification(defaultNotification) + .withNotificationType(notificationType) + .withTombstone(tombstone); - configRepository.writeStandardNotification(newNotification); + configRepository.writeNotification(newNotification); // if (defaultNotification) { - // final StandardNotificationConnection workspaceNotification = new - // StandardNotificationConnection(); - // configRepository.writeStandardNotificationConnection(workspaceNotification); + // final NotificationConnection workspaceNotification = new + // NotificationConnection(); + // configRepository.writeNotificationConnection(workspaceNotification); // } return new NotificationRead().status(StatusEnum.SUCCEEDED); } + public NotificationRead createNotificationConnection(final NotificationConnectionCreate notificationConnection) + throws JsonValidationException, IOException { + final UUID workspaceId = notificationConnection.getWorkspaceId(); + final UUID connectionId = notificationConnection.getConnectionId(); + final UUID notificationId = notificationConnection.getNotificationId(); + final Boolean sendOnSuccess = notificationConnection.getSendOnSuccess(); + final Boolean sendOnFailure = notificationConnection.getSendOnFailure(); + final Boolean tombstone = notificationConnection.getTombstone(); + + final NotificationConnection newNotificationConnection = new NotificationConnection() + .withNotificationConnectionId(uuidSupplier.get()) + .withWorkspaceId(workspaceId) + .withConnectionId(connectionId) + .withNotificationId(notificationId) + .withSendOnSuccess(sendOnSuccess) + .withSendOnFailure(sendOnFailure) + .withTombstone(tombstone); + + configRepository.writeNotificationConnection(newNotificationConnection); + + return new NotificationRead().status(StatusEnum.SUCCEEDED); + } + // public void deleteNotification(final NotificationIdRequestBody notificationIdRequestBody) // throws JsonValidationException, IOException, ConfigNotFoundException { // // get existing implementation - // final StandardNotification persistedNotification = - // configRepository.getStandardNotification(notificationIdRequestBody.getNotificationId(), false); + // final Notification persistedNotification = + // configRepository.getNotification(notificationIdRequestBody.getNotificationId(), false); // // // need to implement a list of all connections with that connection // // tombstone them too // // persistedNotification.withTombstone(true); - // configRepository.writeStandardNotification(persistedNotification); + // configRepository.writeNotification(persistedNotification); // } - public NotificationRead tryNotification(final Notification notification) { + public NotificationRead tryNotification(final NotificationLegacy notification) { try { final NotificationClient notificationClient = NotificationClient.createNotificationClient(NotificationConverter.toConfig(notification)); final String messageFormat = "Hello World! This is a test from Airbyte to try %s notification settings for sync %s"; diff --git a/airbyte-server/src/test/java/io/airbyte/server/handlers/ArchiveHandlerTest.java b/airbyte-server/src/test/java/io/airbyte/server/handlers/ArchiveHandlerTest.java index 7a7222d714122b..ea9f2be2c85b39 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/handlers/ArchiveHandlerTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/handlers/ArchiveHandlerTest.java @@ -22,8 +22,8 @@ import io.airbyte.commons.version.AirbyteVersion; import io.airbyte.config.ConfigSchema; import io.airbyte.config.DestinationConnection; -import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; import io.airbyte.config.SlackNotificationConfiguration; import io.airbyte.config.SourceConnection; import io.airbyte.config.StandardSourceDefinition; @@ -165,7 +165,7 @@ void testFullExportImportRoundTrip() throws Exception { // This source definition is on an old version .withDockerImageTag(sourceS3DefinitionVersion) .withTombstone(false); - final Notification notification = new Notification() + final NotificationLegacy notification = new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSendOnFailure(true) .withSendOnSuccess(true) diff --git a/airbyte-server/src/test/java/io/airbyte/server/handlers/WorkspacesHandlerTest.java b/airbyte-server/src/test/java/io/airbyte/server/handlers/WorkspacesHandlerTest.java index e3bb01da05249f..8b27790681df58 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/handlers/WorkspacesHandlerTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/handlers/WorkspacesHandlerTest.java @@ -19,6 +19,8 @@ import io.airbyte.api.model.ConnectionReadList; import io.airbyte.api.model.DestinationRead; import io.airbyte.api.model.DestinationReadList; +import io.airbyte.api.model.NotificationCreate; +import io.airbyte.api.model.NotificationRead; import io.airbyte.api.model.SlugRequestBody; import io.airbyte.api.model.SourceRead; import io.airbyte.api.model.SourceReadList; @@ -32,6 +34,7 @@ import io.airbyte.commons.json.Jsons; import io.airbyte.config.Notification; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; import io.airbyte.config.SlackNotificationConfiguration; import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; @@ -59,6 +62,7 @@ class WorkspacesHandlerTest { private Supplier uuidSupplier; private StandardWorkspace workspace; private WorkspacesHandler workspacesHandler; + private Notification notification; @SuppressWarnings("unchecked") @BeforeEach @@ -70,6 +74,7 @@ void setUp() { uuidSupplier = mock(Supplier.class); workspace = generateWorkspace(); workspacesHandler = new WorkspacesHandler(configRepository, connectionsHandler, destinationHandler, sourceHandler, uuidSupplier); + notification = generateNotificationNew(); } private StandardWorkspace generateWorkspace() { @@ -88,20 +93,51 @@ private StandardWorkspace generateWorkspace() { .withNotifications(List.of(generateNotification())); } - private Notification generateNotification() { + private Notification generateNotificationNew() { return new Notification() + .withNotificationId(UUID.randomUUID()) + .withWorkspaceId(UUID.randomUUID()) + .withName("test notification") + .withWebhookUrl("webhook-test") + .withDefaultNotification(false) + .withTombstone(false); + } + + private NotificationLegacy generateNotification() { + return new NotificationLegacy() .withNotificationType(NotificationType.SLACK) .withSlackConfiguration(new SlackNotificationConfiguration() .withWebhook(FAILURE_NOTIFICATION_WEBHOOK)); } - private io.airbyte.api.model.Notification generateApiNotification() { - return new io.airbyte.api.model.Notification() + private io.airbyte.api.model.NotificationLegacy generateApiNotification() { + return new io.airbyte.api.model.NotificationLegacy() .notificationType(io.airbyte.api.model.NotificationType.SLACK) .slackConfiguration(new io.airbyte.api.model.SlackNotificationConfiguration() .webhook(FAILURE_NOTIFICATION_WEBHOOK)); } + @Test + void testCreateNotification() throws JsonValidationException, IOException { + + final UUID uuid = UUID.randomUUID(); + when(uuidSupplier.get()).thenReturn(uuid); + + configRepository.writeNotification(notification); + + final NotificationCreate notificationCreate = new NotificationCreate() + .name("new notification") + .webhookUrl("webhook test") + .defaultNotification(false) + .tombstone(false); + + final NotificationRead actualRead = workspacesHandler.createNotification(notificationCreate); + final NotificationRead expectedRead = new NotificationRead() + .status(NotificationRead.StatusEnum.SUCCEEDED); + + assertEquals(expectedRead, actualRead); + } + @Test void testCreateWorkspace() throws JsonValidationException, IOException { when(configRepository.listStandardWorkspaces(false)).thenReturn(Collections.singletonList(workspace)); @@ -293,7 +329,7 @@ void testGetWorkspaceBySlug() throws JsonValidationException, ConfigNotFoundExce @Test void testUpdateWorkspace() throws JsonValidationException, ConfigNotFoundException, IOException { - final io.airbyte.api.model.Notification apiNotification = generateApiNotification(); + final io.airbyte.api.model.NotificationLegacy apiNotification = generateApiNotification(); apiNotification.getSlackConfiguration().webhook("updated"); final WorkspaceUpdate workspaceUpdate = new WorkspaceUpdate() .workspaceId(workspace.getWorkspaceId()) @@ -304,7 +340,7 @@ void testUpdateWorkspace() throws JsonValidationException, ConfigNotFoundExcepti .displaySetupWizard(false) .notifications(List.of(apiNotification)); - final Notification expectedNotification = generateNotification(); + final NotificationLegacy expectedNotification = generateNotification(); expectedNotification.getSlackConfiguration().withWebhook("updated"); final StandardWorkspace expectedWorkspace = new StandardWorkspace() .withWorkspaceId(workspace.getWorkspaceId()) @@ -326,7 +362,7 @@ void testUpdateWorkspace() throws JsonValidationException, ConfigNotFoundExcepti final WorkspaceRead actualWorkspaceRead = workspacesHandler.updateWorkspace(workspaceUpdate); - final io.airbyte.api.model.Notification expectedNotificationRead = generateApiNotification(); + final io.airbyte.api.model.NotificationLegacy expectedNotificationRead = generateApiNotification(); expectedNotificationRead.getSlackConfiguration().webhook("updated"); final WorkspaceRead expectedWorkspaceRead = new WorkspaceRead() .workspaceId(workspace.getWorkspaceId()) diff --git a/docs/reference/api/generated-api-html/index.html b/docs/reference/api/generated-api-html/index.html index 4d8519ca7c502a..25cf5d45a15172 100644 --- a/docs/reference/api/generated-api-html/index.html +++ b/docs/reference/api/generated-api-html/index.html @@ -288,6 +288,7 @@

Logs

Notifications

Oauth

@@ -4095,6 +4096,62 @@

Request body

+

Return type

+ + + + +

Example data

+
Content-Type: application/json
+
{
+  "message" : "message",
+  "status" : "succeeded"
+}
+ +

Produces

+ This API call produces the following media types according to the Accept request header; + the media type will be conveyed by the Content-Type response header. +
    +
  • application/json
  • +
+ +

Responses

+

200

+ Successful operation + NotificationRead +

404

+ Object with given id was not found. + NotFoundKnownExceptionInfo +
+
+
+
+ Up +
post /v1/notifications/add_connection
+
Create a link between a connection and a notification (createNotificationConnection)
+
+ + +

Consumes

+ This API call consumes the following media types via the Content-Type request header: +
    +
  • application/json
  • +
+ +

Request body

+
+
NotificationConnectionCreate NotificationConnectionCreate (required)
+ +
Body Parameter
+ +
+ + + +

Return type

-

Notification - Up

+

NotificationConnectionCreate - Up

-
notificationType
+
workspaceId
UUID format: uuid
+
notificationId
UUID format: uuid
+
connectionId
UUID format: uuid
sendOnSuccess
sendOnFailure
-
slackConfiguration (optional)
+
tombstone

NotificationCreate - Up

-
name
-
webhook
-
defaultNotification
-
notificationType
-
tombstone
+
workspaceId
UUID format: uuid
+
name
+
webhookUrl
+
defaultNotification (optional)
+
notificationType
+
tombstone (optional)
+
+
+
+

NotificationLegacy - Up

+
+
+
notificationType
+
sendOnSuccess
+
sendOnFailure
+
slackConfiguration (optional)
@@ -9624,7 +9695,7 @@

WorkspaceCreate - name

news (optional)
securityUpdates (optional)
-
notifications (optional)
+
notifications (optional)
displaySetupWizard (optional)
@@ -9656,7 +9727,7 @@

WorkspaceRead - anonymousDataCollection (optional)
news (optional)
securityUpdates (optional)
-
notifications (optional)
+
notifications (optional)
firstCompletedSync (optional)
feedbackDone (optional)
@@ -9679,7 +9750,7 @@

WorkspaceUpdate - anonymousDataCollection
news
securityUpdates
-
notifications (optional)
+
notifications (optional)
diff --git a/octavia-cli/octavia_cli/generate/yaml_dumpers.py b/octavia-cli/octavia_cli/generate/yaml_dumpers.py index bee9fdef2f62dd..a20e6ce3398292 100644 --- a/octavia-cli/octavia_cli/generate/yaml_dumpers.py +++ b/octavia-cli/octavia_cli/generate/yaml_dumpers.py @@ -1,6 +1,7 @@ # # Copyright (c) 2021 Airbyte, Inc., all rights reserved. # + import yaml From 8caf1fef332787558d49b5c770760b2c3de5b4a6 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Fri, 18 Mar 2022 17:06:32 -0300 Subject: [PATCH 7/9] run format --- .../io/airbyte/bootloader/BootloaderApp.java | 2 +- .../config/persistence/ConfigRepository.java | 32 +++++++------- .../DatabaseConfigPersistence.java | 28 ++++++------- .../config/persistence/DbConverter.java | 1 - .../airbyte/config/persistence/MockData.java | 21 +++++++++- .../SetupForNormalizedTablesTest.java | 20 ++++++++- .../SnowflakeS3StreamCopierTest.java | 2 +- .../airbyte/server/apis/ConfigurationApi.java | 42 +++++++++---------- 8 files changed, 92 insertions(+), 56 deletions(-) diff --git a/airbyte-bootloader/src/main/java/io/airbyte/bootloader/BootloaderApp.java b/airbyte-bootloader/src/main/java/io/airbyte/bootloader/BootloaderApp.java index 5fad728da285db..3e38348c29319b 100644 --- a/airbyte-bootloader/src/main/java/io/airbyte/bootloader/BootloaderApp.java +++ b/airbyte-bootloader/src/main/java/io/airbyte/bootloader/BootloaderApp.java @@ -232,4 +232,4 @@ private static void cleanupZombies(final JobPersistence jobPersistence) throws I } } -} \ No newline at end of file +} diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java index ca94b5ad26df7b..3a631ba08263ec 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/ConfigRepository.java @@ -307,12 +307,12 @@ public void deleteDestinationDefinitionAndAssociations(final UUID destinationDef } private void deleteConnectorDefinitionAndAssociations( - final ConfigSchema definitionType, - final ConfigSchema connectorType, - final Class connectorClass, - final Function connectorIdGetter, - final Function connectorDefinitionIdGetter, - final UUID definitionId) + final ConfigSchema definitionType, + final ConfigSchema connectorType, + final Class connectorClass, + final Function connectorIdGetter, + final Function connectorDefinitionIdGetter, + final UUID definitionId) throws JsonValidationException, IOException, ConfigNotFoundException { final Set connectors = persistence.listConfigs(connectorType, connectorClass) .stream() @@ -490,7 +490,7 @@ public DestinationOAuthParameter getDestinationOAuthParams(final UUID destinatio } public Optional getDestinationOAuthParamByDefinitionIdOptional(final UUID workspaceId, - final UUID destinationDefinitionId) + final UUID destinationDefinitionId) throws JsonValidationException, IOException { for (final DestinationOAuthParameter oAuthParameter : listDestinationOAuthParam()) { if (destinationDefinitionId.equals(oAuthParameter.getDestinationDefinitionId()) && @@ -535,8 +535,8 @@ public void updateConnectionState(final UUID connectionId, final State state) th } public Optional getSourceCatalog(final UUID sourceId, - final String configurationHash, - final String connectorVersion) + final String configurationHash, + final String connectorVersion) throws JsonValidationException, IOException { for (final ActorCatalogFetchEvent event : listActorCatalogFetchEvents()) { if (event.getConnectorVersion().equals(connectorVersion) @@ -617,7 +617,7 @@ private Map findCatalogByHash(final String catalogHash, fi * @return the db identifier for the cached catalog. */ private UUID getOrInsertActorCatalog(final AirbyteCatalog airbyteCatalog, - final DSLContext context) { + final DSLContext context) { final OffsetDateTime timestamp = OffsetDateTime.now(); final HashFunction hashFunction = Hashing.murmur3_32_fixed(); final String catalogHash = hashFunction.hashBytes(Jsons.serialize(airbyteCatalog).getBytes( @@ -641,8 +641,8 @@ private UUID getOrInsertActorCatalog(final AirbyteCatalog airbyteCatalog, } public Optional getActorCatalog(final UUID actorId, - final String actorVersion, - final String configHash) + final String actorVersion, + final String configHash) throws IOException { final Result> records = database.transaction(ctx -> ctx.select(ACTOR_CATALOG.CATALOG) .from(ACTOR_CATALOG).join(ACTOR_CATALOG_FETCH_EVENT) @@ -678,9 +678,9 @@ public Optional getActorCatalog(final UUID actorId, * @throws IOException */ public UUID writeActorCatalogFetchEvent(final AirbyteCatalog catalog, - final UUID actorId, - final String connectorVersion, - final String configurationHash) + final UUID actorId, + final String connectorVersion, + final String configurationHash) throws IOException { final OffsetDateTime timestamp = OffsetDateTime.now(); final UUID fetchEventID = UUID.randomUUID(); @@ -763,4 +763,4 @@ public void loadDataNoSecrets(final ConfigPersistence seedPersistenceWithoutSecr persistence.loadData(seedPersistenceWithoutSecrets); } -} \ No newline at end of file +} diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java index b4629144a3f1ab..36e5dc7da8390e 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DatabaseConfigPersistence.java @@ -11,11 +11,11 @@ import static io.airbyte.db.instance.configs.jooq.Tables.ACTOR_OAUTH_PARAMETER; import static io.airbyte.db.instance.configs.jooq.Tables.CONNECTION; import static io.airbyte.db.instance.configs.jooq.Tables.CONNECTION_OPERATION; +import static io.airbyte.db.instance.configs.jooq.Tables.NOTIFICATION_CONFIG; +import static io.airbyte.db.instance.configs.jooq.Tables.NOTIFICATION_CONNECTION; import static io.airbyte.db.instance.configs.jooq.Tables.OPERATION; import static io.airbyte.db.instance.configs.jooq.Tables.STATE; import static io.airbyte.db.instance.configs.jooq.Tables.WORKSPACE; -import static io.airbyte.db.instance.configs.jooq.Tables.NOTIFICATION_CONFIG; -import static io.airbyte.db.instance.configs.jooq.Tables.NOTIFICATION_CONNECTION; import static org.jooq.impl.DSL.asterisk; import static org.jooq.impl.DSL.select; @@ -224,8 +224,8 @@ private void validate(final String configId, final List ConfigWithMetadata validateAndReturn(final String configId, - final List> result, - final AirbyteConfig airbyteConfig) + final List> result, + final AirbyteConfig airbyteConfig) throws ConfigNotFoundException { validate(configId, result, airbyteConfig); return result.get(0); @@ -1455,9 +1455,9 @@ private void deleteConfig(final TableImpl table, final Tab } private void deleteConfig(final TableImpl table, - final TableField keyColumn, - final UUID configId, - final DSLContext ctx) { + final TableField keyColumn, + final UUID configId, + final DSLContext ctx) { final boolean isExistingConfig = ctx.fetchExists(select() .from(table) .where(keyColumn.eq(configId))); @@ -1836,10 +1836,10 @@ Map getConnectorRepositoryToInfoMap(final DSLContext ctx) */ @VisibleForTesting ConnectorCounter updateConnectorDefinitions(final DSLContext ctx, - final AirbyteConfig configType, - final List latestDefinitions, - final Set connectorRepositoriesInUse, - final Map connectorRepositoryToIdVersionMap) + final AirbyteConfig configType, + final List latestDefinitions, + final Set connectorRepositoriesInUse, + final Map connectorRepositoryToIdVersionMap) throws IOException { int newCount = 0; int updatedCount = 0; @@ -1909,8 +1909,8 @@ ConnectorCounter updateConnectorDefinitions(final DSLContext ctx, } private void writeOrUpdateStandardDefinition(final DSLContext ctx, - final AirbyteConfig configType, - final JsonNode definition) { + final AirbyteConfig configType, + final JsonNode definition) { if (configType == ConfigSchema.STANDARD_SOURCE_DEFINITION) { writeStandardSourceDefinition(Collections.singletonList(Jsons.object(definition, StandardSourceDefinition.class)), ctx); } else if (configType == ConfigSchema.STANDARD_DESTINATION_DEFINITION) { @@ -1985,4 +1985,4 @@ private ConnectorCounter(final int newCount, final int updateCount) { } -} \ No newline at end of file +} diff --git a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DbConverter.java b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DbConverter.java index 20a367bd83df04..0ea69cd669491e 100644 --- a/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DbConverter.java +++ b/airbyte-config/persistence/src/main/java/io/airbyte/config/persistence/DbConverter.java @@ -10,7 +10,6 @@ import io.airbyte.commons.enums.Enums; import io.airbyte.commons.json.Jsons; import io.airbyte.config.JobSyncConfig.NamespaceDefinitionType; -import io.airbyte.config.Notification; import io.airbyte.config.NotificationLegacy; import io.airbyte.config.ResourceRequirements; import io.airbyte.config.Schedule; diff --git a/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java b/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java index 94cf20225333d7..139c4add9fc702 100644 --- a/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java +++ b/airbyte-config/persistence/src/test/java/io/airbyte/config/persistence/MockData.java @@ -6,14 +6,33 @@ import com.google.common.collect.Lists; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.*; +import io.airbyte.config.ActorCatalog; +import io.airbyte.config.ActorCatalogFetchEvent; +import io.airbyte.config.ActorDefinitionResourceRequirements; +import io.airbyte.config.DestinationConnection; +import io.airbyte.config.DestinationOAuthParameter; import io.airbyte.config.JobSyncConfig.NamespaceDefinitionType; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; +import io.airbyte.config.OperatorDbt; +import io.airbyte.config.OperatorNormalization; import io.airbyte.config.OperatorNormalization.Option; +import io.airbyte.config.ResourceRequirements; +import io.airbyte.config.Schedule; import io.airbyte.config.Schedule.TimeUnit; +import io.airbyte.config.SlackNotificationConfiguration; +import io.airbyte.config.SourceConnection; +import io.airbyte.config.SourceOAuthParameter; +import io.airbyte.config.StandardDestinationDefinition; +import io.airbyte.config.StandardSourceDefinition; import io.airbyte.config.StandardSourceDefinition.SourceType; +import io.airbyte.config.StandardSync; import io.airbyte.config.StandardSync.Status; +import io.airbyte.config.StandardSyncOperation; import io.airbyte.config.StandardSyncOperation.OperatorType; +import io.airbyte.config.StandardSyncState; +import io.airbyte.config.StandardWorkspace; +import io.airbyte.config.State; import io.airbyte.protocol.models.AirbyteCatalog; import io.airbyte.protocol.models.AuthSpecification; import io.airbyte.protocol.models.AuthSpecification.AuthType; diff --git a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java index 88a3c39b1a6fae..9e2b01b590a631 100644 --- a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java +++ b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/SetupForNormalizedTablesTest.java @@ -10,14 +10,32 @@ import com.fasterxml.jackson.databind.JsonNode; import com.google.common.collect.Lists; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.*; +import io.airbyte.config.AirbyteConfig; +import io.airbyte.config.ConfigSchema; +import io.airbyte.config.DestinationConnection; +import io.airbyte.config.DestinationOAuthParameter; import io.airbyte.config.JobSyncConfig.NamespaceDefinitionType; import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.NotificationLegacy; +import io.airbyte.config.OperatorDbt; +import io.airbyte.config.OperatorNormalization; import io.airbyte.config.OperatorNormalization.Option; +import io.airbyte.config.ResourceRequirements; +import io.airbyte.config.Schedule; import io.airbyte.config.Schedule.TimeUnit; +import io.airbyte.config.SlackNotificationConfiguration; +import io.airbyte.config.SourceConnection; +import io.airbyte.config.SourceOAuthParameter; +import io.airbyte.config.StandardDestinationDefinition; +import io.airbyte.config.StandardSourceDefinition; import io.airbyte.config.StandardSourceDefinition.SourceType; +import io.airbyte.config.StandardSync; import io.airbyte.config.StandardSync.Status; +import io.airbyte.config.StandardSyncOperation; import io.airbyte.config.StandardSyncOperation.OperatorType; +import io.airbyte.config.StandardSyncState; +import io.airbyte.config.StandardWorkspace; +import io.airbyte.config.State; import io.airbyte.protocol.models.AirbyteCatalog; import io.airbyte.protocol.models.AuthSpecification; import io.airbyte.protocol.models.AuthSpecification.AuthType; diff --git a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java index c67620e287473e..d8043bf8ab83b9 100644 --- a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java +++ b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java @@ -82,7 +82,7 @@ public void copiesCorrectFilesToTable() throws Exception { copier.copyStagingFileToTemporaryTable(); Set stagingFiles = copier.getStagingFiles(); // check the use of all files for staging - Assertions.assertTrue(stagingFiles.size()>1); + Assertions.assertTrue(stagingFiles.size() > 1); final List> partition = Lists.partition(new ArrayList<>(stagingFiles), 1000); for (final List files : partition) { diff --git a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java index 3ca956344c0bb5..39089fc3c90097 100644 --- a/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java +++ b/airbyte-server/src/main/java/io/airbyte/server/apis/ConfigurationApi.java @@ -156,26 +156,26 @@ public class ConfigurationApi implements io.airbyte.api.V1Api { private final Path workspaceRoot; public ConfigurationApi(final ConfigRepository configRepository, - final JobPersistence jobPersistence, - final ConfigPersistence seed, - final SecretsRepositoryReader secretsRepositoryReader, - final SecretsRepositoryWriter secretsRepositoryWriter, - final SchedulerJobClient schedulerJobClient, - final SynchronousSchedulerClient synchronousSchedulerClient, - final FileTtlManager archiveTtlManager, - final WorkflowServiceStubs temporalService, - final Database configsDatabase, - final Database jobsDatabase, - final TrackingClient trackingClient, - final WorkerEnvironment workerEnvironment, - final LogConfigs logConfigs, - final WorkerConfigs workerConfigs, - final String webappUrl, - final AirbyteVersion airbyteVersion, - final Path workspaceRoot, - final HttpClient httpClient, - final FeatureFlags featureFlags, - final EventRunner eventRunner) { + final JobPersistence jobPersistence, + final ConfigPersistence seed, + final SecretsRepositoryReader secretsRepositoryReader, + final SecretsRepositoryWriter secretsRepositoryWriter, + final SchedulerJobClient schedulerJobClient, + final SynchronousSchedulerClient synchronousSchedulerClient, + final FileTtlManager archiveTtlManager, + final WorkflowServiceStubs temporalService, + final Database configsDatabase, + final Database jobsDatabase, + final TrackingClient trackingClient, + final WorkerEnvironment workerEnvironment, + final LogConfigs logConfigs, + final WorkerConfigs workerConfigs, + final String webappUrl, + final AirbyteVersion airbyteVersion, + final Path workspaceRoot, + final HttpClient httpClient, + final FeatureFlags featureFlags, + final EventRunner eventRunner) { this.workerEnvironment = workerEnvironment; this.logConfigs = logConfigs; this.workspaceRoot = workspaceRoot; @@ -784,4 +784,4 @@ private interface HandlerCall { } -} \ No newline at end of file +} From c43464dd6f5b03b32b8d3c10e5fcdc8ae6608fb7 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Fri, 18 Mar 2022 17:08:29 -0300 Subject: [PATCH 8/9] revert jooq gradle config --- airbyte-db/jooq/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/airbyte-db/jooq/build.gradle b/airbyte-db/jooq/build.gradle index cdec00c0e9566a..48041d1b1acc7f 100644 --- a/airbyte-db/jooq/build.gradle +++ b/airbyte-db/jooq/build.gradle @@ -82,10 +82,10 @@ sourceSets { tasks.named('generateConfigsDatabaseJooq').configure { allInputsDeclared = true - outputs.cacheIf { false } + outputs.cacheIf { true } } tasks.named('generateJobsDatabaseJooq').configure { allInputsDeclared = true - outputs.cacheIf { false } + outputs.cacheIf { true } } From 994379b6480bef797a5bc13eb9f90d7c38c6c3c3 Mon Sep 17 00:00:00 2001 From: marcosmarxm Date: Fri, 18 Mar 2022 17:17:55 -0300 Subject: [PATCH 9/9] correct imports and format --- ...rbyteConfigDatabaseDenormalization_Test.java | 17 ++++++++++++++++- .../snowflake/SnowflakeS3StreamCopierTest.java | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java index 908983500bf665..0d05d932c79bb2 100644 --- a/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java +++ b/airbyte-db/lib/src/test/java/io/airbyte/db/instance/configs/migrations/V0_32_8_001__AirbyteConfigDatabaseDenormalization_Test.java @@ -15,7 +15,22 @@ import io.airbyte.commons.enums.Enums; import io.airbyte.commons.json.Jsons; -import io.airbyte.config.*; +import io.airbyte.config.DestinationConnection; +import io.airbyte.config.DestinationOAuthParameter; +import io.airbyte.config.NotificationLegacy; +import io.airbyte.config.OperatorDbt; +import io.airbyte.config.OperatorNormalization; +import io.airbyte.config.ResourceRequirements; +import io.airbyte.config.Schedule; +import io.airbyte.config.SourceConnection; +import io.airbyte.config.SourceOAuthParameter; +import io.airbyte.config.StandardDestinationDefinition; +import io.airbyte.config.StandardSourceDefinition; +import io.airbyte.config.StandardSync; +import io.airbyte.config.StandardSyncOperation; +import io.airbyte.config.StandardSyncState; +import io.airbyte.config.StandardWorkspace; +import io.airbyte.config.State; import io.airbyte.db.Database; import io.airbyte.db.instance.configs.AbstractConfigsDatabaseTest; import io.airbyte.db.instance.configs.migrations.V0_32_8_001__AirbyteConfigDatabaseDenormalization.ActorType; diff --git a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java index d8043bf8ab83b9..c67620e287473e 100644 --- a/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java +++ b/airbyte-integrations/connectors/destination-snowflake/src/test/java/io/airbyte/integrations/destination/snowflake/SnowflakeS3StreamCopierTest.java @@ -82,7 +82,7 @@ public void copiesCorrectFilesToTable() throws Exception { copier.copyStagingFileToTemporaryTable(); Set stagingFiles = copier.getStagingFiles(); // check the use of all files for staging - Assertions.assertTrue(stagingFiles.size() > 1); + Assertions.assertTrue(stagingFiles.size()>1); final List> partition = Lists.partition(new ArrayList<>(stagingFiles), 1000); for (final List files : partition) {