Skip to content
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
34 changes: 34 additions & 0 deletions components/opsgenie/actions/add-note-alert/add-note-alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import opsgenie from "../../opsgenie.app.mjs";

export default {
key: "opsgenie-add-note-alert",
name: "Add Note to Alert",
description: "Adds a note to an existing alert in Opsgenie. [See the documentation](https://docs.opsgenie.com/docs/alert-api#add-note-to-alert)",
version: "0.0.1",
type: "action",
props: {
opsgenie,
alertId: {
propDefinition: [
opsgenie,
"alertId",
],
},
note: {
type: "string",
label: "Note",
description: "Alert note to add",
},
},
async run({ $ }) {
const response = await this.opsgenie.addNoteToAlert({
$,
alertId: this.alertId,
data: {
note: this.note,
},
});
$.export("$summary", `Successfully added note to alert with ID: ${this.alertId}`);
return response;
},
};
2 changes: 1 addition & 1 deletion components/opsgenie/actions/create-alert/create-alert.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "opsgenie-create-alert",
name: "Create Alert",
description: "Send a new Alert for processing. [See the documentation](https://www.postman.com/api-evangelist/opsgenie/request/zuj17nj/create-alert)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
26 changes: 26 additions & 0 deletions components/opsgenie/actions/delete-alert/delete-alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import opsgenie from "../../opsgenie.app.mjs";

export default {
key: "opsgenie-delete-alert",
name: "Delete Alert",
description: "Removes an existing alert from Opsgenie. [See the documentation](https://docs.opsgenie.com/docs/alert-api#delete-alert)",
version: "0.0.1",
type: "action",
props: {
opsgenie,
alertId: {
propDefinition: [
opsgenie,
"alertId",
],
},
},
async run({ $ }) {
const response = await this.opsgenie.deleteAlert({
$,
alertId: this.alertId,
});
$.export("$summary", `Successfully deleted alert with ID: ${this.alertId}`);
return response;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
key: "opsgenie-get-alert-status",
name: "Get Alert Status",
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)",
version: "0.0.1",
version: "0.0.2",
type: "action",
props: {
app,
Expand Down
1 change: 1 addition & 0 deletions components/opsgenie/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default {
DEFAULT_LIMIT: 20,
PRIORITY_OPTIONS: [
"P1",
"P2",
Expand Down
59 changes: 53 additions & 6 deletions components/opsgenie/opsgenie.app.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ export default {
type: "app",
app: "opsgenie",
propDefinitions: {
alertId: {
type: "string",
label: "Alert ID",
description: "ID of the alert",
async options({ page }) {
const limit = constants.DEFAULT_LIMIT;
const { data } = await this.listAlerts({
params: {
limit,
offset: page * limit,
},
});
return data?.map(({
id: value, message: label,
}) => ({
value,
label,
})) || [];
},
},
user: {
type: "string",
label: "User ID",
Expand All @@ -22,7 +42,7 @@ export default {
},
message: {
type: "string",
label: "message",
label: "Message",
description: "The message of the alert",
},
note: {
Expand Down Expand Up @@ -56,7 +76,7 @@ export default {
_baseUrl() {
return `https://${this.$auth.instance_region}.opsgenie.com/v2`;
},
async _makeRequest(opts = {}) {
_makeRequest(opts = {}) {
const {
$ = this,
path,
Expand All @@ -66,22 +86,29 @@ export default {
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
url: `${this._baseUrl()}${path}`,
headers: {
...headers,
Authorization: `GenieKey ${APIKey}`,
},
});
},
async createAlert(args = {}) {
listAlerts(opts = {}) {
return this._makeRequest({
path: "/alerts",
APIKey: this.$auth.team_api_key,
...opts,
});
},
createAlert(args = {}) {
return this._makeRequest({
method: "post",
path: "/alerts",
APIKey: this.$auth.team_api_key,
...args,
});
},
async getAlertStatus({
getAlertStatus({
requestId, ...args
}) {
return this._makeRequest({
Expand All @@ -90,12 +117,32 @@ export default {
...args,
});
},
async listUsers(args = {}) {
listUsers(args = {}) {
return this._makeRequest({
path: "/users",
APIKey: this.$auth.api_key,
...args,
});
},
addNoteToAlert({
alertId, ...args
}) {
return this._makeRequest({
method: "POST",
path: `/alerts/${alertId}/notes`,
APIKey: this.$auth.team_api_key,
...args,
});
},
deleteAlert({
alertId, ...args
}) {
return this._makeRequest({
method: "DELETE",
path: `/alerts/${alertId}`,
APIKey: this.$auth.team_api_key,
...args,
});
},
},
};
2 changes: 1 addition & 1 deletion components/opsgenie/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pipedream/opsgenie",
"version": "0.1.0",
"version": "0.2.0",
"description": "Pipedream Opsgenie Components",
"main": "opsgenie.app.mjs",
"keywords": [
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading