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
3 changes: 0 additions & 3 deletions components/opsgenie/.gitignore

This file was deleted.

65 changes: 65 additions & 0 deletions components/opsgenie/actions/create-alert/create-alert.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import app from "../../opsgenie.app.mjs";

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",
type: "action",
props: {
app,
user: {
propDefinition: [
app,
"user",
],
},
message: {
propDefinition: [
app,
"message",
],
},
note: {
propDefinition: [
app,
"note",
],
},
description: {
propDefinition: [
app,
"description",
],
},
tags: {
propDefinition: [
app,
"tags",
],
},
priority: {
propDefinition: [
app,
"priority",
],
},
},
async run({ $ }) {
const response = await this.app.createAlert({
$,
data: {
message: this.message,
user: this.user,
note: this.note,
description: this.description,
tags: this.tags,
priority: this.priority,
},
});

$.export("$summary", `Successfully sent a new alert for processing. The alert ID can be used to check the request status: '${response.requestId}'`);

return response;
},
};
28 changes: 28 additions & 0 deletions components/opsgenie/actions/get-alert-status/get-alert-status.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import app from "../../opsgenie.app.mjs";

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",
type: "action",
props: {
app,
requestId: {
propDefinition: [
app,
"requestId",
],
},
},
async run({ $ }) {
const response = await this.app.getAlertStatus({
$,
requestId: this.requestId,
});

$.export("$summary", `Request processing status: '${response.data.status}'`);

return response;
},
};
13 changes: 0 additions & 13 deletions components/opsgenie/app/opsgenie.app.ts

This file was deleted.

9 changes: 9 additions & 0 deletions components/opsgenie/common/constants.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default {
PRIORITY_OPTIONS: [
"P1",
"P2",
"P3",
"P4",
"P5",
],
};
101 changes: 101 additions & 0 deletions components/opsgenie/opsgenie.app.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import { axios } from "@pipedream/platform";
import constants from "./common/constants.mjs";

export default {
type: "app",
app: "opsgenie",
propDefinitions: {
user: {
type: "string",
label: "User ID",
description: "ID of the User",
async options() {
const response = await this.listUsers();
const usersIds = response.data;
return usersIds.map(({
id, fullName,
}) => ({
value: id,
label: fullName,
}));
},
},
message: {
type: "string",
label: "message",
description: "The message of the alert",
},
note: {
type: "string",
label: "Note",
description: "Note of the alert",
},
description: {
type: "string",
label: "Description",
description: "Description of the alert",
},
tags: {
type: "string[]",
label: "Tags",
description: "Tags of the alert",
},
priority: {
type: "string",
label: "Priority",
description: "Priority of the alert",
options: constants.PRIORITY_OPTIONS,
},
requestId: {
type: "string",
label: "Request ID",
description: "ID of the alert request to be checked",
},
},
methods: {
_baseUrl() {
return `https://${this.$auth.instance_region}.opsgenie.com/v2`;
},
async _makeRequest(opts = {}) {
const {
$ = this,
path,
headers,
APIKey,
...otherOpts
} = opts;
return axios($, {
...otherOpts,
url: this._baseUrl() + path,
headers: {
...headers,
Authorization: `GenieKey ${APIKey}`,
},
});
},
async createAlert(args = {}) {
return this._makeRequest({
method: "post",
path: "/alerts",
APIKey: this.$auth.team_api_key,
...args,
});
},
async getAlertStatus({
requestId, ...args
}) {
return this._makeRequest({
path: `/alerts/requests/${requestId}`,
APIKey: this.$auth.team_api_key,
...args,
});
},
async listUsers(args = {}) {
return this._makeRequest({
path: "/users",
APIKey: this.$auth.api_key,
...args,
});
},
},
};
8 changes: 5 additions & 3 deletions components/opsgenie/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "@pipedream/opsgenie",
"version": "0.0.2",
"version": "0.1.0",
"description": "Pipedream Opsgenie Components",
"main": "dist/app/opsgenie.app.mjs",
"main": "opsgenie.app.mjs",
"keywords": [
"pipedream",
"opsgenie"
],
"files": ["dist"],
"homepage": "https://pipedream.com/apps/opsgenie",
"author": "Pipedream <[email protected]> (https://pipedream.com/)",
"publishConfig": {
"access": "public"
},
"dependencies": {
"@pipedream/platform": "^3.0.1"
}
}
107 changes: 55 additions & 52 deletions pnpm-lock.yaml

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