-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce webhook configs into workspace api and persistence (#17950)
* wip * handle webhook configs in workspaces endpoint and split/hydrate secrets * style improvements to documentation around webhook configs * Clarify documentation around webhook auth tokens * More documentation clarification around webhook configs * Format. * unit test coverage for webhook config handling * use common json parsing libraries around webhook configs * clean up around testing webhook operation configs Co-authored-by: Davin Chia <[email protected]>
- Loading branch information
1 parent
19f7428
commit 6a48da9
Showing
13 changed files
with
354 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
airbyte-config/config-models/src/main/resources/types/WebhookOperationConfigs.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/WebhookOperationConfigs.yaml | ||
title: WebhookOperationConfigs | ||
description: List of configurations for webhook operations | ||
additionalProperties: false | ||
# NOTE: we have an extra layer of object nesting because the generator has some weird behavior with arrays. | ||
# See https://github.com/OpenAPITools/openapi-generator/issues/7802. | ||
type: object | ||
properties: | ||
webhookConfigs: | ||
type: array | ||
items: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
- authToken | ||
properties: | ||
id: | ||
type: string | ||
format: uuid | ||
name: | ||
type: string | ||
description: human readable name for this webhook e.g., for UI display | ||
authToken: | ||
type: string | ||
airbyte_secret: true | ||
description: An auth token, to be passed as the value for an HTTP Authorization header. Note - must include prefix such as "Bearer <credential>". |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...e-server/src/main/java/io/airbyte/server/converters/WebhookOperationConfigsConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.server.converters; | ||
|
||
import com.fasterxml.jackson.databind.JsonNode; | ||
import io.airbyte.api.model.generated.WebhookConfigRead; | ||
import io.airbyte.api.model.generated.WebhookConfigWrite; | ||
import io.airbyte.commons.json.Jsons; | ||
import io.airbyte.config.WebhookConfig; | ||
import io.airbyte.config.WebhookOperationConfigs; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
public class WebhookOperationConfigsConverter { | ||
|
||
public static JsonNode toPersistenceWrite(List<WebhookConfigWrite> apiWebhookConfigs) { | ||
if (apiWebhookConfigs == null) { | ||
return Jsons.emptyObject(); | ||
} | ||
|
||
final WebhookOperationConfigs configs = new WebhookOperationConfigs() | ||
.withWebhookConfigs(apiWebhookConfigs.stream().map(WebhookOperationConfigsConverter::toPersistenceConfig).collect(Collectors.toList())); | ||
|
||
return Jsons.jsonNode(configs); | ||
} | ||
|
||
public static List<WebhookConfigRead> toApiReads(List<WebhookConfig> persistenceConfig) { | ||
if (persistenceConfig.isEmpty()) { | ||
return Collections.emptyList(); | ||
} | ||
return persistenceConfig.stream().map(WebhookOperationConfigsConverter::toApiRead).collect(Collectors.toList()); | ||
} | ||
|
||
private static WebhookConfig toPersistenceConfig(final WebhookConfigWrite input) { | ||
return new WebhookConfig() | ||
.withId(UUID.randomUUID()) | ||
.withName(input.getName()) | ||
.withAuthToken(input.getAuthToken()); | ||
} | ||
|
||
private static WebhookConfigRead toApiRead(final WebhookConfig persistenceConfig) { | ||
final var read = new WebhookConfigRead(); | ||
read.setId(persistenceConfig.getId()); | ||
read.setName(persistenceConfig.getName()); | ||
return read; | ||
} | ||
|
||
} |
Oops, something went wrong.