const fetch = require('node-fetch');
let url = 'https://api.coralogix.com/mgmt/openapi/v1/dashboards/dashboards';
let options = {
method: 'POST',
headers: {Authorization: 'Bearer <API_KEY>', 'content-type': 'application/json'},
body: '{"dashboard":{"absoluteTimeFrame":{"from":"2019-08-24T14:15:22Z","to":"2019-08-24T14:15:22Z"},"actions":[{"dataSource":"ACTION_DATA_SOURCE_TYPE_NONE_UNSPECIFIED","definition":{"customAction":{"url":"string"}},"id":"string","name":"string","shouldOpenInNewWindow":true,"widgetId":"string"}],"annotations":[{"enabled":true,"id":"string","name":"string","source":{"metrics":{"labels":["string"],"messageTemplate":"string","promqlQuery":{"value":"string"},"strategy":{"startTimeMetric":{}}}}}],"description":"Sample description","filters":[{"collapsed":true,"displayName":"string","enabled":true,"source":{"logs":{"field":"string","observationField":{"keypath":["string"],"scope":"DATASET_SCOPE_UNSPECIFIED"},"operator":{"equals":{"selection":{"all":{}}}}}}}],"folderId":{"value":"string"},"id":"GZLHSeqelCbD3I7HbIDtL","layout":{"sections":[{"id":{"value":"string"},"options":{"internal":{}},"rows":[{"appearance":{"height":{"value":16}},"id":{"value":"string"},"widgets":[{"appearance":{"width":0},"createdAt":"2019-08-24T14:15:22Z","definition":{"lineChart":{"connectNulls":false,"legend":{"columns":["LEGEND_COLUMN_UNSPECIFIED"],"groupByQuery":true,"isVisible":true,"placement":"LEGEND_PLACEMENT_UNSPECIFIED"},"queryDefinitions":[{"colorScheme":{"value":"classic"},"customUnit":{"value":"rpm"},"dataModeType":"DATA_MODE_TYPE_HIGH_UNSPECIFIED","decimal":4,"decimalPrecision":false,"hashColors":false,"id":{"value":"73c65643-91d5-dba2-35cd-baa49dc65331"},"isVisible":true,"name":{"value":"Query A"},"query":{"logs":{"aggregations":[],"filters":[],"groupBy":[],"groupBys":[]}},"resolution":{"bucketsPresented":0,"interval":"string"},"scaleType":"SCALE_TYPE_UNSPECIFIED","seriesCountLimit":{"value":50},"seriesNameTemplate":{"value":"Trace of {{ application }}"},"unit":"UNIT_UNSPECIFIED","yAxisMax":1000,"yAxisMin":-1000}],"stackedLine":"STACKED_LINE_UNSPECIFIED","tooltip":{"showLabels":true,"type":"TOOLTIP_TYPE_UNSPECIFIED"}}},"description":{"value":"Average delay of application"},"id":{"value":"string"},"title":{"value":"Gauge"},"updatedAt":"2019-08-24T14:15:22Z"}]}]}]},"name":"Example Name","off":{},"slugName":"system-health-monitoring","variables":[{"definition":{"constant":{"value":"string"}},"description":"string","displayName":"string","displayType":"VARIABLE_DISPLAY_TYPE_UNSPECIFIED","name":"string"}],"variablesV2":[{"description":"string","displayFullRow":true,"displayName":"string","displayType":"VARIABLE_DISPLAY_TYPE_V2_UNSPECIFIED","name":"string","source":{"static":{"allOption":{"includeAll":true,"label":"string"},"values":[{"isDefault":true,"label":"string","value":"string"}],"valuesOrderDirection":"ORDER_DIRECTION_UNSPECIFIED"}},"value":{"multiString":{"all":{}}}}]},"isLocked":true,"requestId":"string"}'
};
fetch(url, options)
.then(res => res.json())
.then(json => console.log(json))
.catch(err => console.error('error:' + err));