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/uptimerobot/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import constants from "../../common/constants.mjs";
import app from "../../uptimerobot.app.mjs";

export default {
key: "uptimerobot-create-alert-contact",
name: "Create Alert Contact",
description: "Create a new alert contact. [See the documentation](https://uptimerobot.com/api/).",
version: "0.0.1",
type: "action",
props: {
app,
type: {
type: "string",
label: "Alert Contact Type",
description: "The type of the alert contact.",
options: Object.values(constants.ALERT_CONTACT_TYPE),
default: constants.ALERT_CONTACT_TYPE.EMAIL.value,
},
friendlyName: {
description: "A friendly name for the alert contact.",
propDefinition: [
app,
"friendlyName",
],
},
value: {
type: "string",
label: "Value",
description: "Alert contact's email address Eg. `[email protected]`, phone Eg. `12345678910` (with country code), username, url Eg. `https://example.com/webhook/` or api key Eg. `dXB0aW1lcm9ib3Q=` depending on the alert contact type.",
},
},
methods: {
createAlertContact(args = {}) {
return this.app.post({
path: "/newAlertContact",
...args,
});
},
},
async run({ $ }) {
const {
createAlertContact,
type,
friendlyName,
value,
} = this;

const response = await createAlertContact({
$,
data: {
type,
friendly_name: friendlyName,
value,
},
});

$.export("$summary", "Successfully created the alert contact.");
return response;
},
};
269 changes: 269 additions & 0 deletions components/uptimerobot/actions/create-monitor/create-monitor.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,269 @@
import constants from "../../common/constants.mjs";
import app from "../../uptimerobot.app.mjs";
import utils from "../../common/utils.mjs";

export default {
key: "uptimerobot-create-monitor",
name: "Create Monitor",
description: "Create a new monitor. [See the documentation](https://uptimerobot.com/api/).",
version: "0.0.1",
type: "action",
props: {
app,
type: {
type: "string",
label: "Monitor Type",
description: "The type of the monitor.",
reloadProps: true,
default: constants.MONITOR_TYPE.PING.value,
options: Object.values(constants.MONITOR_TYPE),
},
friendlyName: {
description: "A friendly name for the monitor.",
propDefinition: [
app,
"friendlyName",
],
},
url: {
type: "string",
label: "URL, IP Or Host",
description: "The URL, IP address or Host to monitor.",
},
interval: {
type: "string",
label: "Monitor Interval",
description: "The interval for the monitoring check in seconds. It is recommended to use at least 1-minute checks [available in paid plans](https://app.uptimerobot.com/billing/pricing).",
default: String(5 * 60),
options: [
{
label: "5 Minutes",
value: String(5 * 60),
},
{
label: "30 Minutes",
value: String(30 * 60),
},
{
label: "1 Hour",
value: String(60 * 60),
},
{
label: "12 Hours",
value: String(12 * 60 * 60),
},
{
label: "1 Day",
value: String(24 * 60 * 60),
},
],
},
alertContacts: {
type: "string[]",
label: "Alert Contacts",
propDefinition: [
app,
"alertContact",
],
},
},
additionalProps() {
const {
type: monitorType,
subType,
} = this;

const timeout = {
type: "string",
label: "Request Timeout",
description: "The request timeout. The shorter the timeout the earlier we mark website as down.",
default: "30",
options: [
{
label: "1 Second",
value: "1",
},
{
label: "15 Seconds",
value: "15",
},
{
label: "30 Seconds",
value: "30",
},
{
label: "45 Seconds",
value: "45",
},
{
label: "1 Minute",
value: "60",
},
],
};

const authProps = {
httpAuthType: {
type: "string",
label: "HTTP Auth Type",
description: "The HTTP auth type for the monitor.",
optional: true,
options: [
{
label: "HTTP Basic",
value: "1",
},
{
label: "Digest",
value: "2",
},
],
},
httpUsername: {
type: "string",
label: "HTTP Username",
description: "The HTTP username for the monitor.",
optional: true,
},
httpPassword: {
type: "string",
label: "HTTP Password",
description: "The HTTP password for the monitor.",
optional: true,
},
};

if (monitorType === constants.MONITOR_TYPE.PORT.value) {
return {
timeout,
subType: {
type: "string",
label: "Port Type",
description: "The type of the port.",
options: Object.values(constants.PORT_TYPE),
default: constants.PORT_TYPE.HTTP.value,
reloadProps: true,
},
...(subType === constants.PORT_TYPE.CUSTOM.value && {
port: {
type: "string",
label: "Port",
description: "The port number to monitor.",
},
}),
};
}

if (monitorType === constants.MONITOR_TYPE.KEYWORD.value) {
return {
keywordValue: {
type: "string",
label: "Keyword Value",
description: "The keyword must be present in the response HTML source. You can use HTML markup, too. Eg. `apple` or `<span id=\"availability\">Out of stock</span>`.",
},
keywordType: {
type: "string",
label: "Keyword Type",
description: "The keyword type of the monitor.",
default: "1",
options: [
{
label: "Start incident when keyword exists",
value: "1",
},
{
label: "Start incident when keyword does not exist",
value: "2",
},
],
},
keywordCaseType: {
type: "string",
label: "Keyword Case Type",
description: "The keyword case type of the monitor.",
default: "1",
options: [
{
label: "Case Sensitive",
value: "0",
},
{
label: "Case Insensitive",
value: "1",
},
],
},
...authProps,
};
}

if (monitorType === constants.MONITOR_TYPE.HTTPS.value) {
return {
timeout,
...authProps,
};
}

return {};
},
methods: {
formatAlertContacts(alertContacts, useDefaultThresholdAndRecurrence = true) {
const threshold = 0;
const recurrence = 0;
return utils.parseArray(alertContacts)
?.map((value) => useDefaultThresholdAndRecurrence
? `${value}_${threshold}_${recurrence}`
: value)
.join("-");
},
createMonitor(args = {}) {
return this.app.post({
path: "/newMonitor",
...args,
});
},
},
async run({ $ }) {
const {
createMonitor,
formatAlertContacts,
type,
friendlyName,
url,
interval,
alertContacts,
timeout,
subType,
port,
keywordType,
keywordValue,
keywordCaseType,
httpUsername,
httpPassword,
httpAuthType,
} = this;

const response = await createMonitor({
$,
data: {
friendly_name: friendlyName,
url,
type,
interval,
alert_contacts: formatAlertContacts(alertContacts),
timeout,
sub_type: subType,
port,
keyword_type: keywordType,
keyword_value: keywordValue,
keyword_case_type: keywordCaseType,
http_username: httpUsername,
http_password: httpPassword,
http_auth_type: httpAuthType,
},
});

$.export("$summary", `Successfully created monitor with ID \`${response.monitor.id}\`.`);
return response;
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import app from "../../uptimerobot.app.mjs";

export default {
key: "uptimerobot-update-monitor-status",
name: "Update Monitor Status",
description: "Update an existing monitor's status to pause or resume monitoring. [See the documentation](https://uptimerobot.com/api/).",
version: "0.0.1",
type: "action",
props: {
app,
monitorId: {
propDefinition: [
app,
"monitorId",
],
},
status: {
propDefinition: [
app,
"status",
],
},
},
async run({ $ }) {
const {
app,
monitorId,
status,
} = this;

const response = await app.updateMonitor({
$,
data: {
id: monitorId,
status,
},
});
$.export("$summary", "Successfully updated the monitor status.");
return response;
},
};
13 changes: 0 additions & 13 deletions components/uptimerobot/app/uptimerobot.app.ts

This file was deleted.

Loading
Loading