diff --git a/services/uptimerobot/uptimerobot-status.service.js b/services/uptimerobot/uptimerobot-status.service.js index a9c974b41f79f..bfc881f763982 100644 --- a/services/uptimerobot/uptimerobot-status.service.js +++ b/services/uptimerobot/uptimerobot-status.service.js @@ -1,20 +1,25 @@ -import { pathParams } from '../index.js' +import { pathParam } from '../index.js' +import { queryParamSchema, queryParams } from '../website-status.js' import UptimeRobotBase from './uptimerobot-base.js' export default class UptimeRobotStatus extends UptimeRobotBase { static route = { base: 'uptimerobot/status', pattern: ':monitorSpecificKey', + queryParamSchema, } static openApi = { '/uptimerobot/status/{monitorSpecificKey}': { get: { summary: 'Uptime Robot status', - parameters: pathParams({ - name: 'monitorSpecificKey', - example: 'm778918918-3e92c097147760ee39d02d36', - }), + parameters: [ + pathParam({ + name: 'monitorSpecificKey', + example: 'm778918918-3e92c097147760ee39d02d36', + }), + ...queryParams, + ], }, }, } @@ -23,26 +28,46 @@ export default class UptimeRobotStatus extends UptimeRobotBase { label: 'status', } - static render({ status }) { + static render({ + status, + upMessage = 'up', + downMessage = 'down', + upColor = 'brightgreen', + downColor = 'red', + }) { switch (status) { case 0: return { message: 'paused', color: 'yellow' } case 1: return { message: 'not checked yet', color: 'yellowgreen' } case 2: - return { message: 'up', color: 'brightgreen' } + return { message: upMessage, color: upColor } case 8: return { message: 'seems down', color: 'orange' } case 9: - return { message: 'down', color: 'red' } + return { message: downMessage, color: downColor } default: throw Error('Should not get here due to validation') } } - async handle({ monitorSpecificKey }) { + async handle( + { monitorSpecificKey }, + { + up_message: upMessage, + down_message: downMessage, + up_color: upColor, + down_color: downColor, + }, + ) { const { monitors } = await this.fetch({ monitorSpecificKey }) const { status } = monitors[0] - return this.constructor.render({ status }) + return this.constructor.render({ + status, + upMessage, + downMessage, + upColor, + downColor, + }) } }