diff --git a/airbyte-api/src/main/openapi/config.yaml b/airbyte-api/src/main/openapi/config.yaml index 12fdadd91d5..134d5dbd911 100644 --- a/airbyte-api/src/main/openapi/config.yaml +++ b/airbyte-api/src/main/openapi/config.yaml @@ -1237,6 +1237,34 @@ components: type: boolean securityUpdates: type: boolean + notifications: + type: array + items: + $ref: "#/components/schemas/Notification" + Notification: + type: object + required: + - notificationType + 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: "#/components/schemas/NotificationType" + slackConfiguration: + $ref: "#/components/schemas/SlackNotificationConfiguration" + SlackNotificationConfiguration: + type: object + required: + - webhook + properties: + webhook: + type: string + NotificationType: + type: string + enum: + - slack + # - email + # - webhook WorkspaceIdRequestBody: type: object required: @@ -1274,6 +1302,10 @@ components: type: boolean securityUpdates: type: boolean + notifications: + type: array + items: + $ref: "#/components/schemas/Notification" WorkspaceUpdate: type: object required: @@ -1298,6 +1330,10 @@ components: type: boolean securityUpdates: type: boolean + notifications: + type: array + items: + $ref: "#/components/schemas/Notification" # SLUG SlugRequestBody: type: object diff --git a/airbyte-config/models/src/main/resources/types/Notification.yaml b/airbyte-config/models/src/main/resources/types/Notification.yaml new file mode 100644 index 00000000000..fa37b3858a0 --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/Notification.yaml @@ -0,0 +1,16 @@ +--- +"$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 +type: object +required: + - notificationType +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 + notificationType: + "$ref": NotificationType.yaml + slackConfiguration: + "$ref": SlackNotificationConfiguration.yaml diff --git a/airbyte-config/models/src/main/resources/types/NotificationType.yaml b/airbyte-config/models/src/main/resources/types/NotificationType.yaml new file mode 100644 index 00000000000..d291f007917 --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/NotificationType.yaml @@ -0,0 +1,8 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/NotificationType.yaml +title: NotificationType +description: Type of notification +type: string +enum: + - slack diff --git a/airbyte-config/models/src/main/resources/types/SlackNotificationConfiguration.yaml b/airbyte-config/models/src/main/resources/types/SlackNotificationConfiguration.yaml new file mode 100644 index 00000000000..90546b93aee --- /dev/null +++ b/airbyte-config/models/src/main/resources/types/SlackNotificationConfiguration.yaml @@ -0,0 +1,12 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/SlackNotificationConfiguration.yaml +title: SlackNotificationConfiguration +description: Slack Notification Settings +type: object +required: + - webhook +additionalProperties: false +properties: + webhook: + type: string diff --git a/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml b/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml index 1ba5e15ce7c..160aec4799a 100644 --- a/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml +++ b/airbyte-config/models/src/main/resources/types/StandardWorkspace.yaml @@ -39,3 +39,7 @@ properties: if not set or false, the configuration is active. if true, then this configuration is permanently off. type: boolean + notifications: + type: array + items: + "$ref": Notification.yaml diff --git a/airbyte-migration/src/main/java/io/airbyte/migrate/Migrations.java b/airbyte-migration/src/main/java/io/airbyte/migrate/Migrations.java index 1ef0e57bffa..3624bf74e4b 100644 --- a/airbyte-migration/src/main/java/io/airbyte/migrate/Migrations.java +++ b/airbyte-migration/src/main/java/io/airbyte/migrate/Migrations.java @@ -29,6 +29,7 @@ import io.airbyte.migrate.migrations.MigrationV0_14_0; import io.airbyte.migrate.migrations.MigrationV0_14_3; import io.airbyte.migrate.migrations.MigrationV0_17_0; import io.airbyte.migrate.migrations.MigrationV0_18_0; +import io.airbyte.migrate.migrations.MigrationV0_20_0; import io.airbyte.migrate.migrations.NoOpMigration; import java.util.List; @@ -41,6 +42,7 @@ public class Migrations { private static final Migration MIGRATION_V_0_17_0 = new MigrationV0_17_0(MIGRATION_V_0_16_0); private static final Migration MIGRATION_V_0_18_0 = new MigrationV0_18_0(MIGRATION_V_0_17_0); private static final Migration MIGRATION_V_0_19_0 = new NoOpMigration(MIGRATION_V_0_18_0, "0.19.0-alpha"); + private static final Migration MIGRATION_V_0_20_0 = new MigrationV0_20_0(MIGRATION_V_0_19_0); // all migrations must be added to the list in the order that they should be applied. public static final List MIGRATIONS = ImmutableList.of( @@ -50,6 +52,8 @@ public class Migrations { MIGRATION_V_0_16_0, MIGRATION_V_0_17_0, MIGRATION_V_0_18_0, - MIGRATION_V_0_19_0); + MIGRATION_V_0_19_0 + // , MIGRATION_V_0_20_0 + ); } diff --git a/airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_20_0.java b/airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_20_0.java new file mode 100644 index 00000000000..1d0dc8c660d --- /dev/null +++ b/airbyte-migration/src/main/java/io/airbyte/migrate/migrations/MigrationV0_20_0.java @@ -0,0 +1,96 @@ +/* + * MIT License + * + * Copyright (c) 2020 Airbyte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.airbyte.migrate.migrations; + +import com.fasterxml.jackson.databind.JsonNode; +import io.airbyte.commons.json.Jsons; +import io.airbyte.commons.resources.MoreResources; +import io.airbyte.migrate.Migration; +import io.airbyte.migrate.ResourceId; +import io.airbyte.migrate.ResourceType; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; +import java.util.stream.Stream; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This migration is currently empty and is a placeholder for migrations for the next 0.19.0 release + * + * Additionally, this migration updates the JSON Schema for StandardWorkspace with a new optional + * field 'failureNotificationsWebhook' introduced in issue #1689 + */ +public class MigrationV0_20_0 extends BaseMigration implements Migration { + + private static final Logger LOGGER = LoggerFactory.getLogger(MigrationV0_20_0.class); + + private static final ResourceId STANDARD_WORKSPACE_RESOURCE_ID = ResourceId.fromConstantCase(ResourceType.CONFIG, "STANDARD_WORKSPACE"); + + private static final String MIGRATION_VERSION = "0.20.0-alpha"; + + private final Migration previousMigration; + + public MigrationV0_20_0(Migration previousMigration) { + super(previousMigration); + this.previousMigration = previousMigration; + } + + @Override + public String getVersion() { + return MIGRATION_VERSION; + } + + @Override + public Map getInputSchema() { + final Map outputSchema = new HashMap<>(previousMigration.getOutputSchema()); + try { + outputSchema.put(STANDARD_WORKSPACE_RESOURCE_ID, + Jsons.jsonNode(MoreResources.readResource("migrations/migrationV0_20_0/StandardWorkspace.yaml"))); + } catch (IOException e) { + throw new RuntimeException(e); + } + return outputSchema; + } + + @Override + public Map getOutputSchema() { + return getInputSchema(); + } + + @Override + public void migrate(Map> inputData, Map> outputData) { + for (final Map.Entry> entry : inputData.entrySet()) { + final Consumer recordConsumer = outputData.get(entry.getKey()); + + entry.getValue().forEach(r -> { + // empty migration + recordConsumer.accept(r); + }); + } + } + +} diff --git a/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/Notification.yaml b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/Notification.yaml new file mode 100644 index 00000000000..fa37b3858a0 --- /dev/null +++ b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/Notification.yaml @@ -0,0 +1,16 @@ +--- +"$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 +type: object +required: + - notificationType +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 + notificationType: + "$ref": NotificationType.yaml + slackConfiguration: + "$ref": SlackNotificationConfiguration.yaml diff --git a/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/NotificationType.yaml b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/NotificationType.yaml new file mode 100644 index 00000000000..d291f007917 --- /dev/null +++ b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/NotificationType.yaml @@ -0,0 +1,8 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/NotificationType.yaml +title: NotificationType +description: Type of notification +type: string +enum: + - slack diff --git a/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/SlackNotificationConfiguration.yaml b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/SlackNotificationConfiguration.yaml new file mode 100644 index 00000000000..90546b93aee --- /dev/null +++ b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/SlackNotificationConfiguration.yaml @@ -0,0 +1,12 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/SlackNotificationConfiguration.yaml +title: SlackNotificationConfiguration +description: Slack Notification Settings +type: object +required: + - webhook +additionalProperties: false +properties: + webhook: + type: string diff --git a/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/StandardWorkspace.yaml b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/StandardWorkspace.yaml new file mode 100644 index 00000000000..160aec4799a --- /dev/null +++ b/airbyte-migration/src/main/resources/migrations/migrationV0_20_0/StandardWorkspace.yaml @@ -0,0 +1,45 @@ +--- +"$schema": http://json-schema.org/draft-07/schema# +"$id": https://github.com/airbytehq/airbyte/blob/master/airbyte-config/models/src/main/resources/types/StandardWorkspaceConfiguration.yaml +title: StandardWorkspace +description: workspace configuration +type: object +required: + - workspaceId + - name + - slug + - initialSetupComplete +additionalProperties: false +properties: + workspaceId: + type: string + format: uuid + customerId: + type: string + format: uuid + name: + type: string + slug: + type: string + email: + type: string + format: email + initialSetupComplete: + type: boolean + anonymousDataCollection: + type: boolean + news: + type: boolean + securityUpdates: + type: boolean + displaySetupWizard: + type: boolean + tombstone: + description: + if not set or false, the configuration is active. if true, then this + configuration is permanently off. + type: boolean + notifications: + type: array + items: + "$ref": Notification.yaml 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 new file mode 100644 index 00000000000..9a14beb71ba --- /dev/null +++ b/airbyte-server/src/main/java/io/airbyte/server/converters/NotificationConverter.java @@ -0,0 +1,63 @@ +/* + * MIT License + * + * Copyright (c) 2020 Airbyte + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package io.airbyte.server.converters; + +import io.airbyte.commons.enums.Enums; +import java.util.List; +import java.util.stream.Collectors; + +public class NotificationConverter { + + public static List toConfig(final List notifications) { + return notifications.stream().map(NotificationConverter::toConfig).collect(Collectors.toList()); + } + + private static io.airbyte.config.Notification toConfig(final io.airbyte.api.model.Notification notification) { + return new io.airbyte.config.Notification() + .withNotificationType(Enums.convertTo(notification.getNotificationType(), io.airbyte.config.Notification.NotificationType.class)) + .withSlackConfiguration(toConfig(notification.getSlackConfiguration())); + } + + private static io.airbyte.config.SlackNotificationConfiguration toConfig(final io.airbyte.api.model.SlackNotificationConfiguration notification) { + return new io.airbyte.config.SlackNotificationConfiguration() + .withWebhook(notification.getWebhook()); + } + + public static List toApi(final List notifications) { + return notifications.stream().map(NotificationConverter::toApi).collect(Collectors.toList()); + } + + private static io.airbyte.api.model.Notification toApi(final io.airbyte.config.Notification notification) { + return new io.airbyte.api.model.Notification() + .notificationType(Enums.convertTo(notification.getNotificationType(), io.airbyte.api.model.NotificationType.class)) + .slackConfiguration(toApi(notification.getSlackConfiguration())); + } + + private static io.airbyte.api.model.SlackNotificationConfiguration toApi(final io.airbyte.config.SlackNotificationConfiguration notification) { + return new io.airbyte.api.model.SlackNotificationConfiguration() + .webhook(notification.getWebhook()); + } + +} 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 7768af408dc..d5b05f06c0e 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 @@ -38,6 +38,7 @@ import io.airbyte.api.model.WorkspaceUpdate; import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; import io.airbyte.config.persistence.ConfigRepository; +import io.airbyte.server.converters.NotificationConverter; import io.airbyte.server.errors.KnownException; import io.airbyte.validation.json.JsonValidationException; import java.io.IOException; @@ -92,7 +93,8 @@ public class WorkspacesHandler { .withNews(news != null ? news : false) .withSecurityUpdates(securityUpdates != null ? securityUpdates : false) .withDisplaySetupWizard(false) - .withTombstone(false); + .withTombstone(false) + .withNotifications(NotificationConverter.toConfig(workspaceCreate.getNotifications())); if (!Strings.isNullOrEmpty(email)) { workspace.withEmail(email); @@ -163,7 +165,8 @@ public class WorkspacesHandler { .withDisplaySetupWizard(workspaceUpdate.getDisplaySetupWizard()) .withAnonymousDataCollection(workspaceUpdate.getAnonymousDataCollection()) .withNews(workspaceUpdate.getNews()) - .withSecurityUpdates(workspaceUpdate.getSecurityUpdates()); + .withSecurityUpdates(workspaceUpdate.getSecurityUpdates()) + .withNotifications(NotificationConverter.toConfig(workspaceUpdate.getNotifications())); configRepository.writeStandardWorkspace(persistedWorkspace); @@ -189,7 +192,8 @@ public class WorkspacesHandler { .displaySetupWizard(workspace.getDisplaySetupWizard()) .anonymousDataCollection(workspace.getAnonymousDataCollection()) .news(workspace.getNews()) - .securityUpdates(workspace.getSecurityUpdates()); + .securityUpdates(workspace.getSecurityUpdates()) + .notifications(NotificationConverter.toApi(workspace.getNotifications())); } } diff --git a/airbyte-server/src/test/java/io/airbyte/server/converters/ConfigFileArchiverTest.java b/airbyte-server/src/test/java/io/airbyte/server/converters/ConfigFileArchiverTest.java index 1bd07ddee02..fb51378fc29 100644 --- a/airbyte-server/src/test/java/io/airbyte/server/converters/ConfigFileArchiverTest.java +++ b/airbyte-server/src/test/java/io/airbyte/server/converters/ConfigFileArchiverTest.java @@ -31,6 +31,9 @@ import static org.mockito.Mockito.when; 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.SlackNotificationConfiguration; import io.airbyte.config.SourceConnection; import io.airbyte.config.StandardDestinationDefinition; import io.airbyte.config.StandardSourceDefinition; @@ -75,7 +78,11 @@ public class ConfigFileArchiverTest { .withName("test workspace") .withSlug("default") .withInitialSetupComplete(false) - .withTombstone(false); + .withTombstone(false) + .withNotifications(List.of(new Notification() + .withNotificationType(NotificationType.SLACK) + .withSlackConfiguration(new SlackNotificationConfiguration() + .withWebhook("http://airbyte.notifications")))); } @Test 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 d96bb509b7d..34cf6294804 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 @@ -40,13 +40,18 @@ import io.airbyte.api.model.WorkspaceCreate; import io.airbyte.api.model.WorkspaceIdRequestBody; import io.airbyte.api.model.WorkspaceRead; import io.airbyte.api.model.WorkspaceUpdate; +import io.airbyte.config.Notification; +import io.airbyte.config.Notification.NotificationType; +import io.airbyte.config.SlackNotificationConfiguration; import io.airbyte.config.StandardWorkspace; import io.airbyte.config.persistence.ConfigNotFoundException; import io.airbyte.config.persistence.ConfigRepository; import io.airbyte.config.persistence.PersistenceConstants; +import io.airbyte.server.converters.NotificationConverter; import io.airbyte.validation.json.JsonValidationException; import java.io.IOException; import java.util.Collections; +import java.util.List; import java.util.UUID; import java.util.function.Supplier; import org.junit.jupiter.api.BeforeEach; @@ -54,6 +59,7 @@ import org.junit.jupiter.api.Test; class WorkspacesHandlerTest { + public static final String FAILURE_NOTIFICATION_WEBHOOK = "http://airbyte.notifications/failure"; private ConfigRepository configRepository; private ConnectionsHandler connectionsHandler; private DestinationHandler destinationHandler; @@ -88,7 +94,22 @@ class WorkspacesHandlerTest { .withNews(false) .withAnonymousDataCollection(false) .withSecurityUpdates(false) - .withTombstone(false); + .withTombstone(false) + .withNotifications(List.of(generateNotification())); + } + + private Notification generateNotification() { + return new Notification() + .withNotificationType(NotificationType.SLACK) + .withSlackConfiguration(new SlackNotificationConfiguration() + .withWebhook(FAILURE_NOTIFICATION_WEBHOOK)); + } + + private io.airbyte.api.model.Notification generateApiNotification() { + return new io.airbyte.api.model.Notification() + .notificationType(io.airbyte.api.model.NotificationType.SLACK) + .slackConfiguration(new io.airbyte.api.model.SlackNotificationConfiguration() + .webhook(FAILURE_NOTIFICATION_WEBHOOK)); } @Test @@ -106,7 +127,8 @@ class WorkspacesHandlerTest { .email("test@airbyte.io") .news(false) .anonymousDataCollection(false) - .securityUpdates(false); + .securityUpdates(false) + .notifications(List.of(generateApiNotification())); final WorkspaceRead actualRead = workspacesHandler.createWorkspace(workspaceCreate); final WorkspaceRead expectedRead = new WorkspaceRead() @@ -119,7 +141,8 @@ class WorkspacesHandlerTest { .displaySetupWizard(false) .news(false) .anonymousDataCollection(false) - .securityUpdates(false); + .securityUpdates(false) + .notifications(List.of(generateApiNotification())); assertEquals(expectedRead, actualRead); } @@ -171,7 +194,8 @@ class WorkspacesHandlerTest { .displaySetupWizard(true) .news(false) .anonymousDataCollection(false) - .securityUpdates(false); + .securityUpdates(false) + .notifications(List.of(generateApiNotification())); assertEquals(workspaceRead, workspacesHandler.getWorkspace(workspaceIdRequestBody)); } @@ -192,22 +216,27 @@ class WorkspacesHandlerTest { .displaySetupWizard(workspace.getDisplaySetupWizard()) .news(workspace.getNews()) .anonymousDataCollection(workspace.getAnonymousDataCollection()) - .securityUpdates(workspace.getSecurityUpdates()); + .securityUpdates(workspace.getSecurityUpdates()) + .notifications(NotificationConverter.toApi(workspace.getNotifications())); assertEquals(workspaceRead, workspacesHandler.getWorkspaceBySlug(slugRequestBody)); } @Test void testUpdateWorkspace() throws JsonValidationException, ConfigNotFoundException, IOException { - + final io.airbyte.api.model.Notification apiNotification = generateApiNotification(); + apiNotification.getSlackConfiguration().webhook("updated"); final WorkspaceUpdate workspaceUpdate = new WorkspaceUpdate() .workspaceId(workspace.getWorkspaceId()) .anonymousDataCollection(true) .securityUpdates(false) .news(false) .initialSetupComplete(true) - .displaySetupWizard(false); + .displaySetupWizard(false) + .notifications(List.of(apiNotification)); + final Notification expectedNotification = generateNotification(); + expectedNotification.getSlackConfiguration().withWebhook("updated"); final StandardWorkspace expectedWorkspace = new StandardWorkspace() .withWorkspaceId(workspace.getWorkspaceId()) .withCustomerId(workspace.getCustomerId()) @@ -219,7 +248,8 @@ class WorkspacesHandlerTest { .withNews(false) .withInitialSetupComplete(true) .withDisplaySetupWizard(false) - .withTombstone(false); + .withTombstone(false) + .withNotifications(List.of(expectedNotification)); when(configRepository.getStandardWorkspace(workspace.getWorkspaceId(), false)) .thenReturn(workspace) @@ -227,6 +257,8 @@ class WorkspacesHandlerTest { final WorkspaceRead actualWorkspaceRead = workspacesHandler.updateWorkspace(workspaceUpdate); + final io.airbyte.api.model.Notification expectedNotificationRead = generateApiNotification(); + expectedNotificationRead.getSlackConfiguration().webhook("updated"); final WorkspaceRead expectedWorkspaceRead = new WorkspaceRead() .workspaceId(workspace.getWorkspaceId()) .customerId(workspace.getCustomerId()) @@ -237,7 +269,8 @@ class WorkspacesHandlerTest { .displaySetupWizard(false) .news(false) .anonymousDataCollection(true) - .securityUpdates(false); + .securityUpdates(false) + .notifications(List.of(expectedNotificationRead)); verify(configRepository).writeStandardWorkspace(expectedWorkspace); diff --git a/docs/api/generated-api-html/index.html b/docs/api/generated-api-html/index.html index d7a557b3b04..532d8154990 100644 --- a/docs/api/generated-api-html/index.html +++ b/docs/api/generated-api-html/index.html @@ -4000,6 +4000,15 @@ font-style: italic; "email" : "email", "slug" : "slug", "securityUpdates" : true, + "notifications" : [ { + "slackConfiguration" : { + "webhook" : "webhook" + } + }, { + "slackConfiguration" : { + "webhook" : "webhook" + } + } ], "workspaceId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } @@ -4106,6 +4115,15 @@ font-style: italic; "email" : "email", "slug" : "slug", "securityUpdates" : true, + "notifications" : [ { + "slackConfiguration" : { + "webhook" : "webhook" + } + }, { + "slackConfiguration" : { + "webhook" : "webhook" + } + } ], "workspaceId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } @@ -4173,6 +4191,15 @@ font-style: italic; "email" : "email", "slug" : "slug", "securityUpdates" : true, + "notifications" : [ { + "slackConfiguration" : { + "webhook" : "webhook" + } + }, { + "slackConfiguration" : { + "webhook" : "webhook" + } + } ], "workspaceId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } @@ -4240,6 +4267,15 @@ font-style: italic; "email" : "email", "slug" : "slug", "securityUpdates" : true, + "notifications" : [ { + "slackConfiguration" : { + "webhook" : "webhook" + } + }, { + "slackConfiguration" : { + "webhook" : "webhook" + } + } ], "workspaceId" : "046b6c7f-0b8a-43b9-b35d-6489e6daee91" } @@ -4311,6 +4347,9 @@ font-style: italic;
  • LogRead -
  • LogType -
  • LogsRequestBody -
  • +
  • Notification -
  • +
  • NotificationType -
  • +
  • SlackNotificationConfiguration -
  • SlugRequestBody -
  • SourceCoreConfig -
  • SourceCreate -
  • @@ -4715,6 +4754,27 @@ font-style: italic;
    logType
    +
    +

    Notification - Up

    +
    +
    +
    notificationType
    +
    slackConfiguration (optional)
    +
    +
    + +

    SlugRequestBody - Up

    @@ -4936,6 +4996,7 @@ font-style: italic;
    name
    news (optional)
    securityUpdates (optional)
    +
    notifications (optional)
    @@ -4959,6 +5020,7 @@ font-style: italic;
    anonymousDataCollection (optional)
    news (optional)
    securityUpdates (optional)
    +
    notifications (optional)
    @@ -4972,6 +5034,7 @@ font-style: italic;
    anonymousDataCollection
    news
    securityUpdates
    +
    notifications (optional)