Skip to content

Commit 19bfd06

Browse files
authored
New Components - opsgenie (#15462)
* new components * pnpm-lock.yaml * versions
1 parent 763548d commit 19bfd06

File tree

7 files changed

+117
-9
lines changed

7 files changed

+117
-9
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import opsgenie from "../../opsgenie.app.mjs";
2+
3+
export default {
4+
key: "opsgenie-add-note-alert",
5+
name: "Add Note to Alert",
6+
description: "Adds a note to an existing alert in Opsgenie. [See the documentation](https://docs.opsgenie.com/docs/alert-api#add-note-to-alert)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
opsgenie,
11+
alertId: {
12+
propDefinition: [
13+
opsgenie,
14+
"alertId",
15+
],
16+
},
17+
note: {
18+
type: "string",
19+
label: "Note",
20+
description: "Alert note to add",
21+
},
22+
},
23+
async run({ $ }) {
24+
const response = await this.opsgenie.addNoteToAlert({
25+
$,
26+
alertId: this.alertId,
27+
data: {
28+
note: this.note,
29+
},
30+
});
31+
$.export("$summary", `Successfully added note to alert with ID: ${this.alertId}`);
32+
return response;
33+
},
34+
};

components/opsgenie/actions/create-alert/create-alert.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "opsgenie-create-alert",
55
name: "Create Alert",
66
description: "Send a new Alert for processing. [See the documentation](https://www.postman.com/api-evangelist/opsgenie/request/zuj17nj/create-alert)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import opsgenie from "../../opsgenie.app.mjs";
2+
3+
export default {
4+
key: "opsgenie-delete-alert",
5+
name: "Delete Alert",
6+
description: "Removes an existing alert from Opsgenie. [See the documentation](https://docs.opsgenie.com/docs/alert-api#delete-alert)",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
opsgenie,
11+
alertId: {
12+
propDefinition: [
13+
opsgenie,
14+
"alertId",
15+
],
16+
},
17+
},
18+
async run({ $ }) {
19+
const response = await this.opsgenie.deleteAlert({
20+
$,
21+
alertId: this.alertId,
22+
});
23+
$.export("$summary", `Successfully deleted alert with ID: ${this.alertId}`);
24+
return response;
25+
},
26+
};

components/opsgenie/actions/get-alert-status/get-alert-status.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export default {
44
key: "opsgenie-get-alert-status",
55
name: "Get Alert Status",
66
description: "Get the status of the alert with the specified ID. [See the documentation](https://www.postman.com/api-evangelist/opsgenie/request/03tcghu/get-request-status-of-alert)",
7-
version: "0.0.1",
7+
version: "0.0.2",
88
type: "action",
99
props: {
1010
app,

components/opsgenie/common/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
2+
DEFAULT_LIMIT: 20,
23
PRIORITY_OPTIONS: [
34
"P1",
45
"P2",

components/opsgenie/opsgenie.app.mjs

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ export default {
55
type: "app",
66
app: "opsgenie",
77
propDefinitions: {
8+
alertId: {
9+
type: "string",
10+
label: "Alert ID",
11+
description: "ID of the alert",
12+
async options({ page }) {
13+
const limit = constants.DEFAULT_LIMIT;
14+
const { data } = await this.listAlerts({
15+
params: {
16+
limit,
17+
offset: page * limit,
18+
},
19+
});
20+
return data?.map(({
21+
id: value, message: label,
22+
}) => ({
23+
value,
24+
label,
25+
})) || [];
26+
},
27+
},
828
user: {
929
type: "string",
1030
label: "User ID",
@@ -22,7 +42,7 @@ export default {
2242
},
2343
message: {
2444
type: "string",
25-
label: "message",
45+
label: "Message",
2646
description: "The message of the alert",
2747
},
2848
note: {
@@ -56,7 +76,7 @@ export default {
5676
_baseUrl() {
5777
return `https://${this.$auth.instance_region}.opsgenie.com/v2`;
5878
},
59-
async _makeRequest(opts = {}) {
79+
_makeRequest(opts = {}) {
6080
const {
6181
$ = this,
6282
path,
@@ -66,22 +86,29 @@ export default {
6686
} = opts;
6787
return axios($, {
6888
...otherOpts,
69-
url: this._baseUrl() + path,
89+
url: `${this._baseUrl()}${path}`,
7090
headers: {
7191
...headers,
7292
Authorization: `GenieKey ${APIKey}`,
7393
},
7494
});
7595
},
76-
async createAlert(args = {}) {
96+
listAlerts(opts = {}) {
97+
return this._makeRequest({
98+
path: "/alerts",
99+
APIKey: this.$auth.team_api_key,
100+
...opts,
101+
});
102+
},
103+
createAlert(args = {}) {
77104
return this._makeRequest({
78105
method: "post",
79106
path: "/alerts",
80107
APIKey: this.$auth.team_api_key,
81108
...args,
82109
});
83110
},
84-
async getAlertStatus({
111+
getAlertStatus({
85112
requestId, ...args
86113
}) {
87114
return this._makeRequest({
@@ -90,12 +117,32 @@ export default {
90117
...args,
91118
});
92119
},
93-
async listUsers(args = {}) {
120+
listUsers(args = {}) {
94121
return this._makeRequest({
95122
path: "/users",
96123
APIKey: this.$auth.api_key,
97124
...args,
98125
});
99126
},
127+
addNoteToAlert({
128+
alertId, ...args
129+
}) {
130+
return this._makeRequest({
131+
method: "POST",
132+
path: `/alerts/${alertId}/notes`,
133+
APIKey: this.$auth.team_api_key,
134+
...args,
135+
});
136+
},
137+
deleteAlert({
138+
alertId, ...args
139+
}) {
140+
return this._makeRequest({
141+
method: "DELETE",
142+
path: `/alerts/${alertId}`,
143+
APIKey: this.$auth.team_api_key,
144+
...args,
145+
});
146+
},
100147
},
101148
};

components/opsgenie/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/opsgenie",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Pipedream Opsgenie Components",
55
"main": "opsgenie.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)