-
Notifications
You must be signed in to change notification settings - Fork 5.5k
[Components] uptimerobot - new action components #15054
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
60 changes: 60 additions & 0 deletions
60
components/uptimerobot/actions/create-alert-contact/create-alert-contact.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
269
components/uptimerobot/actions/create-monitor/create-monitor.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/).", | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
| }; | ||
41 changes: 41 additions & 0 deletions
41
components/uptimerobot/actions/update-monitor-status/update-monitor-status.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/).", | ||
jcortes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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; | ||
| }, | ||
| }; | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.