Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jira - Add Override existing webhooks optional prop to all sources #14471

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/jira/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/jira",
"version": "0.1.2",
"version": "0.1.3",
"description": "Pipedream Jira Components",
"main": "jira.app.mjs",
"keywords": [
Expand Down
26 changes: 26 additions & 0 deletions components/jira/sources/common/common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export default {
],
description: "The JQL filter that specifies which issues the webhook is sent for, only a subset of JQL can be used, e.g. `project = P1` [See supported JQL filters](https://developer.atlassian.com/cloud/jira/service-desk/webhooks/#supported-jql-queries)",
},
overrideExistingWebhooks: {
type: "boolean",
label: "Override Existing Webhooks",
description: "Override existing webhooks with this new Pipedream source's webhook. Recommend to set this to `true` if you have an existing Jira webhook that you no longer use and want to override with the new Pipedream source.",
default: false,
optional: true,
},
},
methods: {
_getHookID() {
Expand Down Expand Up @@ -91,9 +98,28 @@ export default {
ts,
};
},
async deleteExistingWebhooks() {
const resourcesStream = await this.jira.getResourcesStream({
cloudId: this.cloudId,
resourceFn: this.jira.getWebhook,
resourceFnArgs: {
params: {},
},
resourceFiltererFn: (resource) => resource.values,
});
for await (const webhook of resourcesStream) {
await this.jira.deleteHook({
hookId: webhook.id,
cloudId: this.cloudId,
});
}
},
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
},
hooks: {
async activate() {
if (this.overrideExistingWebhooks) {
await this.deleteExistingWebhooks();
}
michelle0927 marked this conversation as resolved.
Show resolved Hide resolved
const { hookId } = await this.jira.createHook({
url: this.http.endpoint,
events: this.getEvents(),
Expand Down
2 changes: 1 addition & 1 deletion components/jira/sources/events/events.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default {
key: "jira-events",
name: "New Event",
description: "Emit new event when an event with subscribed event source triggered, [See the docs](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-webhooks/#api-rest-api-3-webhook-post)",
version: "0.0.9",
version: "0.0.10",
type: "source",
dedupe: "unique",
...common,
Expand Down
4 changes: 2 additions & 2 deletions components/jira/sources/issue-created/issue-created.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import common from "../common/common.mjs";

export default {
key: "jira-issue-created",
name: "New Issue Created Event",
name: "New Issue Created Event (Instant)",
description: "Emit new event when an issue is created. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.",
version: "0.0.9",
version: "0.0.10",
type: "source",
dedupe: "unique",
...common,
Expand Down
4 changes: 2 additions & 2 deletions components/jira/sources/issue-deleted/issue-deleted.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import common from "../common/common.mjs";

export default {
key: "jira-issue-deleted",
name: "New Issue Deleted Event",
name: "New Issue Deleted Event (Instant)",
description: "Emit new event when an issue is deleted. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.",
version: "0.0.9",
version: "0.0.10",
type: "source",
dedupe: "unique",
...common,
Expand Down
4 changes: 2 additions & 2 deletions components/jira/sources/issue-updated/issue-updated.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import common from "../common/common.mjs";

export default {
key: "jira-issue-updated",
name: "New Issue Updated Event",
name: "New Issue Updated Event (Instant)",
description: "Emit new event when an issue is updated. Note that Jira supports only one webhook, if more sources are needed please use `New Event` source and select multiple events.",
version: "0.0.9",
version: "0.0.10",
type: "source",
dedupe: "unique",
...common,
Expand Down
Loading