1- import fetch , { Response } from "node-fetch" ;
21import * as Serverless from "serverless" ;
32import { MonitorParams , ServerlessMonitor , replaceCriticalThreshold } from "./monitors" ;
43
@@ -44,7 +43,7 @@ export async function createMonitor(
4443 monitorsApiKey : string ,
4544 monitorsAppKey : string ,
4645) : Promise < Response > {
47- const response : Response = await fetch ( `https://api.${ site } /api/v1/monitor` , {
46+ const response = await fetch ( `https://api.${ site } /api/v1/monitor` , {
4847 method : "POST" ,
4948 headers : {
5049 "DD-API-KEY" : monitorsApiKey ,
@@ -63,7 +62,7 @@ export async function updateMonitor(
6362 monitorsApiKey : string ,
6463 monitorsAppKey : string ,
6564) : Promise < Response > {
66- const response : Response = await fetch ( `https://api.${ site } /api/v1/monitor/${ monitorId } ` , {
65+ const response = await fetch ( `https://api.${ site } /api/v1/monitor/${ monitorId } ` , {
6766 method : "PUT" ,
6867 headers : {
6968 "DD-API-KEY" : monitorsApiKey ,
@@ -82,7 +81,7 @@ export async function deleteMonitor(
8281 monitorsApiKey : string ,
8382 monitorsAppKey : string ,
8483) : Promise < Response > {
85- const response : Response = await fetch ( `https://api.${ site } /api/v1/monitor/${ monitorId } ` , {
84+ const response = await fetch ( `https://api.${ site } /api/v1/monitor/${ monitorId } ` , {
8685 method : "DELETE" ,
8786 headers : {
8887 "DD-API-KEY" : monitorsApiKey ,
@@ -105,7 +104,7 @@ export async function searchMonitors(
105104 let pageCount = 1 ;
106105 do {
107106 const query = `tag:"${ queryTag } "` ;
108- const response : Response = await fetch ( `https://api.${ site } /api/v1/monitor/search?query=${ query } &page=${ page } ` , {
107+ const response = await fetch ( `https://api.${ site } /api/v1/monitor/search?query=${ query } &page=${ page } ` , {
109108 method : "GET" ,
110109 headers : {
111110 "DD-API-KEY" : monitorsApiKey ,
@@ -118,7 +117,7 @@ export async function searchMonitors(
118117 throw new Error ( `Can't fetch monitors. Status code: ${ response . status } . Message: ${ response . statusText } ` ) ;
119118 }
120119
121- const json = await response . json ( ) ;
120+ const json : any = await response . json ( ) ; // TODO: use proper type/parsing
122121 monitors = monitors . concat ( json . monitors ) ;
123122 pageCount = json . metadata . page_count ;
124123 page += 1 ;
@@ -178,7 +177,7 @@ export async function getRecommendedMonitors(
178177 const recommendedMonitors : { [ key : string ] : ServerlessMonitor } = { } ;
179178 // Setting a count of 50 in the hope that all can be fetched at once. The default is 10 per page.
180179 const endpoint = `https://api.${ site } /api/v2/monitor/recommended?count=50&start=0&search=tag%3A%22product%3Aserverless%22%20AND%20tag%3A%22integration%3Aamazon-lambda%22` ;
181- const response : Response = await fetch ( endpoint , {
180+ const response = await fetch ( endpoint , {
182181 method : "GET" ,
183182 headers : {
184183 "DD-API-KEY" : monitorsApiKey ,
@@ -190,7 +189,7 @@ export async function getRecommendedMonitors(
190189 throw new Error ( `Can't fetch monitor params. Status code: ${ response . status } . Message: ${ response . statusText } ` ) ;
191190 }
192191
193- const json = await response . json ( ) ;
192+ const json : any = await response . json ( ) ; // TODO: use proper type/parsing
194193 const recommendedMonitorsData = json . data ;
195194 recommendedMonitorsData . forEach ( ( recommendedMonitorParam : RecommendedMonitorParams ) => {
196195 const recommendedMonitorId = parseRecommendedMonitorServerlessId ( recommendedMonitorParam ) ;
0 commit comments