Giter VIP home page Giter VIP logo

cachet-node's Introduction

cachet-node

cachet-node is an implementation of the Cachet API. This API is automatically generated based on a swagger documentation file on cachet-swagger through the use of swagger-js-codegen.

Currently it supports the following operations from the Cachet API Reference:

  • General
  • Components
  • Component Groups
  • Incidents
  • Incident Updates
  • Metrics

Table of Contents

Usage

Installation

npm install cachet-node

Basics

In order to start leveraging the cachet-node library you will generally have an API key located under your Teams -> User area. This is going to be necessary to do anything that is not a read-only event. You only need to set this information once you have initialized the library.

const Cachet = require('cachet-node').Cachet;

const cachet = new Cachet({
  domain: 'https://status.yourdomain.com/api/v1',
  token: {
    value: 'token value from user',
    headerOrQueryName: 'X-Cachet-Token'
  }
});

Now you can start to leverage one of the many functions such as fetching the current version:

cachet.version()
  .then(response => {
    console.log(response.body);
    // { meta: { on_latest: true, latest: { tag_name: 'v2.3.10', prelease: false, draft: false } }, data: '2.4.0-dev' }
  })
  .catch(err => {
    console.log(err);
  });

Note that all of the methods will provide back a promise with the exception of the setToken method (not documented as you can use the constructor).

This library also makes heavy use of a request object, what you are receiving back is the what the request provides raw and that is where you will need to utilize the "body" parameter.

Parameters

Note that all parameters must be passed in via a JavaScript object. Anytime you are creating, it requires a body parameter. You can find such parameters in the swagger file in cachet-swagger until this documentation reflects all of the methods and functionality of the endpoint.

General

ping

Ping the status system to ensure it is available.

Request
cachet.ping()
Response
{
  "data": "Pong!"
}

version

Fetch the current version of the system.

Request
cachet.version()
Response
{
  "meta": {
    "on_latest": true,
    "latest": {
      "tag_name": "v2.3.10",
      "prelease": false,
      "draft": false
    }
  },
  "data": "2.4.0-dev"
}

Components

getComponents

Fetch all of the components.

Parameters
  • sort
  • order
  • perPage
  • page
  • id
  • name
  • status
  • groupId
  • enabled
Request
cachet.getComponents({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 20,
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Example",
      "description": "",
      "status": 1,
      "order": 0,
      "group_id": 1,
      "created_at": "2017-01-05 16:52:00",
      "updated_at": "2017-01-06 02:27:32",
      "deleted_at": null,
      "enabled": true,
      "meta": null,
      "link": "https://status.example.com",
      "status_name": "Operational",
      "tags": {
        "": ""
      }
    }
  ]
}

getComponentById

Parameters
  • component
Request
cachet.getComponentById({
  component: 4
})
Response
{
  "data": {
    "id": 4,
    "name": "Foo",
    "description": "",
    "status": 0,
    "order": 0,
    "group_id": 0,
    "created_at": "2017-01-06 19:51:29",
    "updated_at": "2017-01-06 19:52:59",
    "deleted_at": null,
    "enabled": false,
    "meta": null,
    "link": "",
    "status_name": "Unknown",
    "tags": []
  }
}

createComponent

Parameters
  • body
    • name
    • description
    • status
    • link
    • order
    • group_id
    • enabled
Request
cachet.createComponent({
  body: {
    name: 'Foo'
  }
})
Response
{
  "data": {
    "order": 0,
    "group_id": 0,
    "description": "",
    "link": "",
    "enabled": true,
    "meta": null,
    "name": "Foo",
    "status": 0,
    "updated_at": "2017-01-06 19:51:29",
    "created_at": "2017-01-06 19:51:29",
    "id": 4,
    "status_name": "Unknown",
    "tags": []
  }
}

updateComponentById

Parameters
  • component
  • body
    • name
    • status
    • link
    • order
    • group_id
    • enabled
Request
cachet.createComponent({
  component: 4,
  body: {
    enabled: 0
  }
})
Response
{
  "data": {
    "id": 4,
    "name": "Foo",
    "description": "",
    "status": 0,
    "order": 0,
    "group_id": 0,
    "created_at": "2017-01-06 19:51:29",
    "updated_at": "2017-01-06 19:52:59",
    "deleted_at": null,
    "enabled": false,
    "meta": null,
    "link": "",
    "status_name": "Unknown",
    "tags": []
  }
}

deleteComponentById

Parameters
  • component
Request
cachet.deleteComponentById({
  component: 4
})
Response

There is no response for this other than the status code.

Component Groups

getComponentGroups

Parameters
  • id
  • name
  • collapsed
  • sort
  • order
  • perPage
  • page
Request
cachet.getComponentGroups({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": 20,
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Example Group",
      "created_at": "2017-01-05 16:52:50",
      "updated_at": "2017-01-05 16:53:23",
      "order": 0,
      "collapsed": 0,
      "visible": 1,
      "enabled_components": [
        {
          "id": 1,
          "name": "Example",
          "description": "",
          "status": 1,
          "order": 0,
          "group_id": 1,
          "created_at": "2017-01-05 16:52:00",
          "updated_at": "2017-01-06 02:27:32",
          "deleted_at": null,
          "enabled": true,
          "meta": null,
          "link": "https://status.example.com",
          "status_name": "Operational",
          "tags": {
            "": ""
          }
        }
      ],
      "enabled_components_lowest": [
        {
          "id": 1,
          "name": "Example",
          "description": "",
          "status": 1,
          "order": 0,
          "group_id": 1,
          "created_at": "2017-01-05 16:52:00",
          "updated_at": "2017-01-06 02:27:32",
          "deleted_at": null,
          "enabled": true,
          "meta": null,
          "link": "https://status.example.com",
          "status_name": "Operational",
          "tags": {
            "": ""
          }
        }
      ],
      "lowest_human_status": "Operational"
    }
  ]
}

createComponentGroup

Parameters
  • name
  • order
  • collapsed
Request
cachet.createComponentGroup({
  body: {
    name: 'Foo Group'
  }
})
Response
{
  "data": {
    "order": 0,
    "collapsed": 0,
    "visible": 0,
    "name": "Foo Group",
    "updated_at": "2017-01-06 20:06:49",
    "created_at": "2017-01-06 20:06:49",
    "id": 2,
    "lowest_human_status": null
  }
}

getComponentGroupById

Parameters
  • group
Request
cachet.getComponentGroupById({
  group: 2
})
Response
{
  "data": {
    "id": 2,
    "name": "Foo Group",
    "created_at": "2017-01-06 20:06:49",
    "updated_at": "2017-01-06 20:06:49",
    "order": 0,
    "collapsed": 0,
    "visible": 0,
    "enabled_components": [],
    "enabled_components_lowest": [],
    "lowest_human_status": null
  }
}

updateComponentGroupById

Parameters
  • group
  • body
    • name
    • order
    • collapsed
Request
cachet.updateComponentGroupById({
  group: 2,
  body: {
    order: 10
  }
})
Response
{
  "data": {
    "id": 2,
    "name": "Foo Group",
    "created_at": "2017-01-06 20:06:49",
    "updated_at": "2017-01-06 20:09:43",
    "order": 10,
    "collapsed": 0,
    "visible": 0,
    "enabled_components": [],
    "enabled_components_lowest": [],
    "lowest_human_status": null
  }
}

deleteComponentGroupById

Parameters
  • group
Request
cachet.deleteComponentGroupById({
  group: 2
})
Response

There is no response for this other than the status code.

Incidents

getIncidents

Parameters
  • id
  • componentId
  • name
  • status
  • visible
  • sort
  • order
  • perPage
  • page
Request
cachet.getIncidents({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": "20",
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "component_id": 0,
      "name": "Incident Name",
      "status": 4,
      "visible": 1,
      "message": "Incident Message",
      "scheduled_at": "2015-08-01 12:00:00",
      "created_at": "2015-08-01 12:00:00",
      "updated_at": "2015-08-01 12:00:00",
      "deleted_at": null,
      "human_status": "Fixed"
    }
  ]
}

createIncident

Parameters
  • body
    • name
    • message
    • status
    • visible
    • component_id
    • component_status
    • notify
    • created_at
    • template
    • vars
Request
cachet.createIncident({
  body: {
    name: 'Incident Name',
    message: 'Incident Message',
    status: 4,
    visible: 1
  }
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Incident Name",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

getIncidentById

Parameters
  • incident
Request
cachet.getIncidentById({
  incident: 1
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Incident Name",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

updateIncidentById

Parameters
  • incident
  • body
    • name
    • message
    • status
    • visible
    • component_id
    • component_status
    • notify
Request
cachet.updateIncidentById({
  incident: 1,
  body: {
    name: 'Foo'
  }
})
Response
{
  "data": {
    "id": 1,
    "component_id": 0,
    "name": "Foo",
    "status": 4,
    "visible": 1,
    "message": "Incident Message",
    "scheduled_at": "2015-08-01 12:00:00",
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:01",
    "deleted_at": null,
    "human_status": "Fixed"
  }
}

deleteIncidentById

Parameters
  • incident
Request
cachet.deleteIncidentById({
  incident: 1
})
Response

There is no response for this other than the status code.

getIncidentUpdatesById

Parameters
  • incident
  • sort
  • order
  • perPage
  • page
Request
cachet.getIncidentUpdatesById({
  incident: 1
})
Response
{
  "meta":{
    "pagination":{
      "total":4,
      "count":4,
      "per_page":20,
      "current_page":1,
      "total_pages":1,
      "links":{
        "next_page":null,
        "previous_page":null
      }
    }
  },
  "data":[
    {
      "id":1,
      "incident_id":1,
      "status":4,
      "message":"The monkeys are back and rested!",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Fixed",
      "permalink":"http://cachet.app/incidents/1#update-1"
    },
    {
      "id":2,
      "incident_id":1,
      "status":3,
      "message":"Our monkeys need a break from performing. They'll be back after a good rest.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Watching",
      "permalink":"http://cachet.app/incidents/1#update-2"
    },
    {
      "id":3,
      "incident_id":1,
      "status":2,
      "message":"We have identified the issue with our lovely performing monkeys.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Identified",
      "permalink":"http://cachet.app/incidents/1#update-3"
    },
    {
      "id":4,
      "incident_id":2,
      "status":3,
      "message":"We're actively watching this issue, so it remains unresolved.",
      "user_id":1,
      "created_at":"2016-12-05 19:37:20",
      "updated_at":"2016-12-05 19:37:20",
      "human_status":"Watching",
      "permalink":"http://cachet.app/incidents/2#update-4"
    }
  ]
}

getIncidentUpdateById

Parameters
  • incident
  • update
Request
cachet.getIncidentUpdateById({
  incident: 1,
  update: 1
})
Response
{
  "data": {
    "id":1,
    "incident_id":1,
    "status":4,
    "message":"The monkeys are back and rested!",
    "user_id":1,
    "created_at":"2016-12-05 19:37:20",
    "updated_at":"2016-12-05 19:37:20",
    "human_status":"Fixed",
    "permalink":"http://cachet.app/incidents/1#update-1"
  }
}

Metrics

getMetrics

Parameters
  • sort
  • order
  • perPage
  • page
Request
cachet.getMetric({ ... parameters ... })
Response
{
  "meta": {
    "pagination": {
      "total": 1,
      "count": 1,
      "per_page": "20",
      "current_page": 1,
      "total_pages": 1,
      "links": {
        "next_page": null,
        "previous_page": null
      }
    }
  },
  "data": [
    {
      "id": 1,
      "name": "Coffee",
      "suffix": "Cups",
      "description": "Cups of coffee consumed.",
      "default_value": "0.000",
      "calc_type": 1,
      "display_chart": 1,
      "created_at": "2015-08-01 12:00:00",
      "updated_at": "2015-08-01 12:00:00",
      "default_view_name": "Last 12 Hours"
    }
  ]
}

createMetric

Parameters
  • body
    • name
    • suffix
    • description
    • default_value
    • display_chart
Request
cachet.createMetric({
  body: {
    name: "Visitors",
    description: "How many visitors",
    suffix: "Visitors per hour",
    default_value: 0,
    display_chart: 1
  }
}
Response
{
  "name":"Visitors",
  "description":"How many visitors",
  "suffix":"Visitors per hour",
  "default_value":"0",
  "display_chart":"1"
}

getMetricById

Parameters
  • metric
Request
cachet.getMetricById({
  metric: 1
})
Response
{
  "data": {
    "id": 1,
    "name": "Coffee",
    "suffix": "Cups",
    "description": "Cups of coffee consumed.",
    "default_value": "0.000",
    "calc_type": 1,
    "display_chart": 1,
    "created_at": "2015-08-01 12:00:00",
    "updated_at": "2015-08-01 12:00:00",
    "default_view_name": "Last 12 Hours"
  }
}

deleteMetricById

Parameters
  • metric
Request
cachet.deleteMetricById({
  metric: 1
})
Response

There is no response for this other than the status code.

getMetricPointsById

Parameters
  • metric
  • sort
  • order
  • perPage
  • page
Request
cachet.getMetricPointsById({
  metric: 1
})
Response
{
  "data": [
    {
      "id": 1,
      "metric_id": 1,
      "value": 1,
      "created_at": "2015-03-11 14:21:44",
      "updated_at": "2015-03-11 14:21:44"
    },
    {
      "id": 2,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:22:11",
      "updated_at": "2015-03-11 14:22:11"
    },
    {
      "id": 3,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:34:55",
      "updated_at": "2015-03-11 14:34:55"
    }
  ]
}

createMetricPointById

Parameters
  • metric
  • body
    • value
    • timestamp
Request
cachet.createMetricPointById({
  metric: 1,
  body: {
    value: 3
    timestamp: '2015-03-11 14:34:55'
  }
}
Response
{
  "data": [
    {
      "id": 1,
      "metric_id": 1,
      "value": 1,
      "created_at": "2015-03-11 14:21:44",
      "updated_at": "2015-03-11 14:21:44"
    },
    {
      "id": 2,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:22:11",
      "updated_at": "2015-03-11 14:22:11"
    },
    {
      "id": 3,
      "metric_id": 1,
      "value": 3,
      "created_at": "2015-03-11 14:34:55",
      "updated_at": "2015-03-11 14:34:55"
    }
  ]
}

deleteMetricPointById

Parameters
  • metric
  • point
Request
cachet.deleteMetricPointById({
  metric: 1,
  point: 3
})
Response

There is no response for this other than the status code.

Contributing

Contributions in this repository can be documentation and/or build changes. Since the code is automatically generated no changes to the index.js file will be taken.

cachet-node's People

Contributors

mwillbanks avatar

Watchers

 avatar  avatar

Forkers

gavd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.