@neoskop/hearnoevil
Advanced tools
Comparing version 0.0.3 to 0.1.0
@@ -45,6 +45,6 @@ #!/usr/bin/env node | ||
var uptime_robot_provider_1 = require("./providers/uptime-robot.provider"); | ||
var loadProvider = function (name, id, apiKey) { | ||
var loadProvider = function (name, ids, apiKey) { | ||
switch (name) { | ||
case "uptimerobot": | ||
return new uptime_robot_provider_1.UptimeRobotProvider(id, apiKey); | ||
return new uptime_robot_provider_1.UptimeRobotProvider(ids, apiKey); | ||
} | ||
@@ -65,3 +65,5 @@ throw new Error("Provider " + name + " is not supported"); | ||
.option("-a, --api-key <api-key>", "API key") | ||
.option("-i, --id <id>", "The ID of the monitor"); | ||
.option("-i, --id <value>", "The ID of the monitor (repeatable)", function (value, previous) { | ||
return previous.concat([value]); | ||
}, []); | ||
commander_1.default | ||
@@ -68,0 +70,0 @@ .command("mute") |
export declare abstract class Provider { | ||
protected id: string; | ||
protected ids: string[]; | ||
protected apiKey: string; | ||
constructor(id: string, apiKey: string); | ||
abstract mute(): Promise<void>; | ||
abstract unmute(): Promise<void>; | ||
constructor(ids: string[], apiKey: string); | ||
abstract mute(): Promise<void[]>; | ||
abstract unmute(): Promise<void[]>; | ||
} |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var Provider = /** @class */ (function () { | ||
function Provider(id, apiKey) { | ||
this.id = id; | ||
function Provider(ids, apiKey) { | ||
this.ids = ids; | ||
this.apiKey = apiKey; | ||
@@ -7,0 +7,0 @@ } |
import { Provider } from "./provider"; | ||
export declare class UptimeRobotProvider extends Provider { | ||
mute(): Promise<void>; | ||
unmute(): Promise<void>; | ||
mute(): Promise<void[]>; | ||
unmute(): Promise<void[]>; | ||
private sendEditMonitorRequest; | ||
} |
@@ -31,9 +31,11 @@ "use strict"; | ||
UptimeRobotProvider.prototype.mute = function () { | ||
return this.sendEditMonitorRequest({ status: 0 }); | ||
var _this = this; | ||
return Promise.all(this.ids.map(function (id) { return _this.sendEditMonitorRequest({ id: id, status: 0 }); })); | ||
}; | ||
UptimeRobotProvider.prototype.unmute = function () { | ||
return this.sendEditMonitorRequest({ status: 1 }); | ||
var _this = this; | ||
return Promise.all(this.ids.map(function (id) { return _this.sendEditMonitorRequest({ id: id, status: 1 }); })); | ||
}; | ||
UptimeRobotProvider.prototype.sendEditMonitorRequest = function (props) { | ||
var form = Object.assign({ api_key: this.apiKey, id: this.id, format: "json" }, props); | ||
var form = Object.assign({ api_key: this.apiKey, format: "json" }, props); | ||
return new Promise(function (resolve, reject) { | ||
@@ -40,0 +42,0 @@ request.post({ |
{ | ||
"name": "@neoskop/hearnoevil", | ||
"version": "0.0.3", | ||
"version": "0.1.0", | ||
"description": "Mute you monitors when doing something evil.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
20512
185