├── .gitignore ├── jsconfig.json ├── package.json ├── examples ├── getComponent.js ├── publishMetric.js └── reportIncident.js ├── util └── statusCodes.js ├── README.md ├── index.js └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/ 2 | node_modules 3 | test.js -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "commonjs" 4 | } 5 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "cachet-api", 3 | "version": "1.0.11", 4 | "description": "An API client for Cachet, the open source status page system.", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/eladnava/cachet-api.git" 12 | }, 13 | "author": "Elad Nava ", 14 | "license": "Apache-2.0", 15 | "bugs": { 16 | "url": "https://github.com/eladnava/cachet-api/issues" 17 | }, 18 | "homepage": "https://github.com/eladnava/cachet-api#readme", 19 | "dependencies": { 20 | "bluebird": "^3.4.0", 21 | "request": "^2.72.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /examples/getComponent.js: -------------------------------------------------------------------------------- 1 | // Change '../' to 'cachet-api' to use this code in your own project 2 | var CachetAPI = require('../'); 3 | 4 | // Fill in the parameters accordingly 5 | var cachet = new CachetAPI({ 6 | // Base URL of your installed Cachet status page 7 | url: 'https://demo.cachethq.io', 8 | // Cachet API key (provided within the admin dashboard) 9 | apiKey: 'a1b2c3d4e5f6g7h8i9' 10 | }); 11 | 12 | // Prepare a component ID to fetch 13 | var componentId = 1; 14 | 15 | // Get component info by ID 16 | cachet.getComponentById(componentId) 17 | .then(function (component) { 18 | // Log component info 19 | console.log('Component', component); 20 | }).catch(function (err) { 21 | // Log errors to console 22 | console.log('Fatal Error', err); 23 | }); -------------------------------------------------------------------------------- /examples/publishMetric.js: -------------------------------------------------------------------------------- 1 | // Change '../' to 'cachet-api' to use this code in your own project 2 | var CachetAPI = require('../'); 3 | 4 | // Fill in the parameters accordingly 5 | var cachet = new CachetAPI({ 6 | // Base URL of your installed Cachet status page 7 | url: 'https://demo.cachethq.io', 8 | // Cachet API key (provided within the admin dashboard) 9 | apiKey: 'a1b2c3d4e5f6g7h8i9' 10 | }); 11 | 12 | // Prepare a metric point to publish (so it shows up on the metric's graph) 13 | var metricPoint = { 14 | // Metric ID 15 | id: 1, 16 | // Metric point value 17 | value: 3.37, 18 | // Metric point timestamp (optional, defaults to now) 19 | timestamp: Math.round(new Date().getTime() / 1000) 20 | }; 21 | 22 | // Publish it so it shows up on the status page 23 | cachet.publishMetricPoint(metricPoint) 24 | .then(function (response) { 25 | // Log API response 26 | console.log('Metric point published at ' + response.data.created_at); 27 | }).catch(function (err) { 28 | // Log errors to console 29 | console.log('Fatal Error', err); 30 | }); -------------------------------------------------------------------------------- /util/statusCodes.js: -------------------------------------------------------------------------------- 1 | // Incident status codes to names 2 | var incidentStatuses = { 3 | 'Scheduled': 0, 4 | 'Investigating': 1, 5 | 'Identified': 2, 6 | 'Watching': 3, 7 | 'Fixed': 4 8 | }; 9 | 10 | // Component status codes to names 11 | var componentStatuses = { 12 | 'Operational': 1, 13 | 'Performance Issues': 2, 14 | 'Partial Outage': 3, 15 | 'Major Outage': 4 16 | }; 17 | 18 | exports.getIncidentStatusCode = function (name) { 19 | // Attempt to find incident status code by name 20 | var code = incidentStatuses[name]; 21 | 22 | // Bad name? 23 | if (code === undefined || code === null) { 24 | throw new Error('Invalid incident status provided: ' + name); 25 | } 26 | 27 | // We're good 28 | return code; 29 | }; 30 | 31 | exports.getComponentStatusCode = function (name) { 32 | // Attempt to find component status code by name 33 | var code = componentStatuses[name]; 34 | 35 | // Bad name? 36 | if (!code) { 37 | throw new Error('Invalid component status provided: ' + name); 38 | } 39 | 40 | // We're good 41 | return code; 42 | }; -------------------------------------------------------------------------------- /examples/reportIncident.js: -------------------------------------------------------------------------------- 1 | // Change '../' to 'cachet-api' to use this code in your own project 2 | var CachetAPI = require('../'); 3 | 4 | // Fill in the parameters accordingly 5 | var cachet = new CachetAPI({ 6 | // Base URL of your installed Cachet status page 7 | url: 'https://demo.cachethq.io', 8 | // Cachet API key (provided within the admin dashboard) 9 | apiKey: 'a1b2c3d4e5f6g7h8i9' 10 | }); 11 | 12 | // Prepare an incident to publish 13 | var incident = { 14 | // Incident name 15 | name: 'Database connectivity issues', 16 | // Incident description (supports markdown) 17 | message: 'We\'re investigating connectivity issues with the main DB.', 18 | // Incident status (https://docs.cachethq.io/docs/incident-statuses) 19 | status: 'Investigating', 20 | // Whether the incident will be visible to the public or only to logged in users 21 | visible: true, 22 | // Whether to send out e-mail notifications to subscribers regarding this incident 23 | notify: true, 24 | // Component ID affected by this incident (optional) 25 | component_id: 1, 26 | // Component status (required if component_id is specified) (https://docs.cachethq.io/docs/component-statuses) 27 | component_status: 'Partial Outage' 28 | }; 29 | 30 | // Publish it so it shows up on the status page 31 | cachet.reportIncident(incident) 32 | .then(function (response) { 33 | // Log API response 34 | console.log('New incident reported at ' + response.data.created_at); 35 | }).catch(function (err) { 36 | // Log errors to console 37 | console.log('Fatal Error', err); 38 | }); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # cachet-api 2 | [![npm version](https://badge.fury.io/js/cachet-api.svg)](https://www.npmjs.com/package/cachet-api) 3 | 4 | A Node.js API client for [Cachet](https://cachethq.io/). 5 | 6 | > [Cachet](https://cachethq.io/) is a beautiful and powerful open source status page system, a free replacement to services such as StatusPage.io, Status.io and others. 7 | 8 | ## Usage 9 | 10 | First, install the package using npm: 11 | 12 | ```shell 13 | npm install cachet-api --save 14 | ``` 15 | 16 | Then, start using the package by importing and configuring it: 17 | 18 | ```js 19 | var CachetAPI = require('cachet-api'); 20 | 21 | // Fill in the parameters accordingly 22 | var cachet = new CachetAPI({ 23 | // Base URL of your installed Cachet status page 24 | url: 'https://demo.cachethq.io', 25 | // Cachet API key (provided within the admin dashboard) 26 | apiKey: 'a1b2c3d4e5f6g7h8i9' 27 | }); 28 | ``` 29 | 30 | Make sure to fill in your Cachet status page `url` as well as your Cachet admin account's `apiKey`, which you can find in the [Cachet dashboard](https://docs.cachethq.io/docs/api-authentication#api-token). 31 | 32 | ## Get Component Info 33 | 34 | Use `cachet.getComponentById(id)` to fetch details about an existing component: 35 | 36 | ```js 37 | // Prepare a component ID to fetch 38 | var componentId = 1; 39 | 40 | // Get component info by ID 41 | cachet.getComponentById(componentId) 42 | .then(function (component) { 43 | // Log component info 44 | console.log('Component', component); 45 | }).catch(function (err) { 46 | // Log errors to console 47 | console.log('Fatal Error', err); 48 | }); 49 | ``` 50 | 51 | ## Publish a Metric Point 52 | 53 | Use `cachet.publishMetricPoint(point)` to publish a new metric point to an existing metric: 54 | 55 | ```js 56 | // Prepare a metric point to publish (so it shows up on the metric's graph) 57 | var metricPoint = { 58 | // Metric ID 59 | id: 1, 60 | // Metric point value 61 | value: 3.37, 62 | // Metric point timestamp (optional, defaults to now) 63 | timestamp: Math.round(new Date().getTime() / 1000) 64 | }; 65 | 66 | // Publish it so it shows up on the status page 67 | cachet.publishMetricPoint(metricPoint) 68 | .then(function (response) { 69 | // Log API response 70 | console.log('Metric point published at ' + response.data.created_at); 71 | }).catch(function (err) { 72 | // Log errors to console 73 | console.log('Fatal Error', err); 74 | }); 75 | ``` 76 | 77 | ## Report an Incident 78 | 79 | Use `cachet.reportIncident(incident)` to report a new status incident: 80 | 81 | ```js 82 | // Prepare an incident to report 83 | var incident = { 84 | // Incident name 85 | name: 'Database connectivity issues', 86 | // Incident description (supports markdown) 87 | message: 'We\'re investigating connectivity issues with the main DB.', 88 | // Incident status (https://docs.cachethq.io/docs/incident-statuses) 89 | status: 'Investigating', 90 | // Whether the incident will be visible to the public or only to logged in users 91 | visible: true, 92 | // Whether to send out e-mail notifications to subscribers regarding this incident 93 | notify: true, 94 | // Component ID affected by this incident (optional) 95 | component_id: 1, 96 | // Component status (required if component_id is specified) (https://docs.cachethq.io/docs/component-statuses) 97 | component_status: 'Partial Outage' 98 | }; 99 | 100 | // Report it so it shows up on the status page 101 | cachet.reportIncident(incident) 102 | .then(function (response) { 103 | // Log API response 104 | console.log('New incident reported at ' + response.data.created_at); 105 | }).catch(function (err) { 106 | // Log errors to console 107 | console.log('Fatal Error', err); 108 | }); 109 | ``` 110 | 111 | ## Delete an Incident 112 | 113 | Use `cachet.deleteIncidentById(id)` to delete an existing status incident: 114 | 115 | ```js 116 | cachet.deleteIncidentById(incidentId) 117 | .then(function (response) { 118 | // Log API response 119 | console.log('Incident successfully deleted'); 120 | }).catch(function (err) { 121 | // Log errors to console 122 | console.log('Fatal Error', err); 123 | }); 124 | ``` 125 | 126 | ## Get Incidents by Component ID 127 | 128 | Use `cachet.getIncidentsByComponentId(componentId)` to fetch all incidents associated with the provided component: 129 | 130 | ```js 131 | cachet.getIncidentsByComponentId(componentId) 132 | .then(function (incidents) { 133 | // Log API response 134 | console.log('Incidents successfully fetched', incidents); 135 | }).catch(function (err) { 136 | // Log errors to console 137 | console.log('Fatal Error', err); 138 | }); 139 | ``` 140 | 141 | ## License 142 | 143 | Apache 2.0 144 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var util = require('util'); 2 | var request = require('request'); 3 | var Promise = require('bluebird'); 4 | var statusCodes = require('./util/statusCodes'); 5 | 6 | // Internal package configuration 7 | var config = { 8 | // Supported Cachet API version 9 | apiVersion: 1, 10 | // Default timeout of 5 seconds for each request to the Cachet API 11 | timeout: 5000 12 | }; 13 | 14 | // Package constructor 15 | function CachetAPI(options) { 16 | // Make sure the developer provided the status page URL 17 | if (!options.url) { 18 | throw new Error('Please provide your Cachet API endpoint URL to use this package.'); 19 | } 20 | 21 | // Make sure the developer provided the Cachet API key 22 | if (!options.apiKey) { 23 | throw new Error('Please provide your API key to use this package.'); 24 | } 25 | 26 | // Add trailing slash if ommitted in status page URL 27 | if (options.url.substr(-1) !== '/') { 28 | options.url += '/'; 29 | } 30 | 31 | // Append api/v1 to the URL 32 | options.url += 'api/v' + config.apiVersion; 33 | 34 | // Keep track of URL for later 35 | this.url = options.url; 36 | 37 | // Prepare extra headers to be sent with all API requests 38 | this.headers = { 39 | // Cachet API authentication header 40 | 'X-Cachet-Token': options.apiKey 41 | }; 42 | 43 | // Set timeout to value passed in or default to config.timeout 44 | this.timeout = options.timeout || config.timeout; 45 | 46 | // Use ca certificate if one is provided 47 | this.ca = options.ca || null; 48 | } 49 | 50 | CachetAPI.prototype.publishMetricPoint = function (metricPoint) { 51 | // Dirty hack 52 | var that = this; 53 | 54 | // Return a promise 55 | return new Promise(function (resolve, reject) { 56 | // No metric point provided? 57 | if (!metricPoint) { 58 | return reject(new Error('Please provide the metric point to publish.')); 59 | } 60 | 61 | // Point must be an object 62 | if (typeof metricPoint !== 'object') { 63 | return reject(new Error('Please provide the metric point as an object.')); 64 | } 65 | 66 | // Check for missing metric ID 67 | if (!metricPoint.id) { 68 | return reject(new Error('Please provide the metric ID.')); 69 | } 70 | 71 | // Check for missing metric value 72 | if (metricPoint.value === null) { 73 | return reject(new Error('Please provide the metric point value.')); 74 | } 75 | 76 | // Prepare API request 77 | var req = { 78 | method: 'POST', 79 | timeout: that.timeout, 80 | json: metricPoint, 81 | headers: that.headers, 82 | url: that.url + '/metrics/' + metricPoint.id + '/points', 83 | ca: that.ca 84 | }; 85 | 86 | // Execute request 87 | request(req, function (err, res, body) { 88 | // Handle the response accordingly 89 | handleResponse(err, res, body, reject, resolve); 90 | }); 91 | }); 92 | }; 93 | 94 | CachetAPI.prototype.reportIncident = function (incident) { 95 | // Dirty hack 96 | var that = this; 97 | 98 | // Return a promise 99 | return new Promise(function (resolve, reject) { 100 | // No incident provided? 101 | if (!incident) { 102 | return reject(new Error('Please provide the incident to report.')); 103 | } 104 | 105 | // Incident must be an object 106 | if (typeof incident !== 'object') { 107 | return reject(new Error('Please provide the incident as an object.')); 108 | } 109 | 110 | // Check for required parameters 111 | if (!incident.name || !incident.message || !incident.status || incident.visible === undefined) { 112 | return reject(new Error('Please provide the incident name, message, status, and visibility.')); 113 | } 114 | 115 | // Convert boolean values to integers 116 | incident.notify = incident.notify ? 1 : 0; 117 | incident.visible = incident.visible ? 1 : 0; 118 | 119 | try { 120 | // Attempt to convert incident status name to code 121 | incident.status = statusCodes.getIncidentStatusCode(incident.status); 122 | 123 | // Incident status provided? 124 | if (incident.component_status) { 125 | // Attempt to convert component status name to code 126 | incident.component_status = statusCodes.getComponentStatusCode(incident.component_status); 127 | } 128 | } 129 | catch (err) { 130 | // Bad status provided 131 | return reject(err); 132 | } 133 | 134 | // Prepare API request 135 | var req = { 136 | method: 'POST', 137 | timeout: that.timeout, 138 | json: incident, 139 | headers: that.headers, 140 | url: that.url + '/incidents', 141 | ca: that.ca 142 | }; 143 | 144 | // Execute request 145 | request(req, function (err, res, body) { 146 | // Handle the response accordingly 147 | handleResponse(err, res, body, reject, resolve); 148 | }); 149 | }); 150 | }; 151 | 152 | CachetAPI.prototype.deleteIncidentById = function (id) { 153 | // Dirty hack 154 | var that = this; 155 | 156 | // Return a promise 157 | return new Promise(function (resolve, reject) { 158 | // No incident id provided? 159 | if (!id) { 160 | return reject(new Error('Please provide the id of the incident to delete.')); 161 | } 162 | 163 | // Prepare API request 164 | var req = { 165 | method: 'DELETE', 166 | timeout: that.timeout, 167 | headers: that.headers, 168 | url: that.url + '/incidents/' + id, 169 | ca: that.ca 170 | }; 171 | 172 | // Execute request 173 | request(req, function (err, res, body) { 174 | // Handle the response accordingly 175 | handleResponse(err, res, body, reject, resolve); 176 | }); 177 | }); 178 | }; 179 | 180 | CachetAPI.prototype.getIncidentsByComponentId = function (id) { 181 | // Dirty hack 182 | var that = this; 183 | 184 | // Return a promise 185 | return new Promise(function (resolve, reject) { 186 | // No component ID provided? 187 | if (!id) { 188 | return reject(new Error('Please provide the component ID of the incidents to fetch.')); 189 | } 190 | 191 | // Prepare API request 192 | var req = { 193 | method: 'GET', 194 | json: true, 195 | timeout: that.timeout, 196 | headers: that.headers, 197 | url: that.url + '/incidents?component_id=' + id, 198 | ca: that.ca 199 | }; 200 | 201 | // Execute request 202 | request(req, function (err, res, body) { 203 | // Extract data object from body if it exists 204 | body = (body && body.data) ? body.data : body; 205 | 206 | // Handle the response accordingly 207 | handleResponse(err, res, body, reject, resolve); 208 | }); 209 | }); 210 | }; 211 | 212 | CachetAPI.prototype.getComponentById = function (id) { 213 | // Dirty hack 214 | var that = this; 215 | 216 | // Return a promise 217 | return new Promise(function (resolve, reject) { 218 | // No component ID provided? 219 | if (!id) { 220 | return reject(new Error('Please provide the component ID to fetch.')); 221 | } 222 | 223 | // Prepare API request 224 | var req = { 225 | method: 'GET', 226 | json: true, 227 | timeout: that.timeout, 228 | headers: that.headers, 229 | url: that.url + '/components/' + id, 230 | ca: that.ca 231 | }; 232 | 233 | // Execute request 234 | request(req, function (err, res, body) { 235 | // Extract data object from body if it exists 236 | body = (body && body.data) ? body.data : body; 237 | 238 | // Handle the response accordingly 239 | handleResponse(err, res, body, reject, resolve); 240 | }); 241 | }); 242 | }; 243 | 244 | function handleResponse(err, res, body, reject, resolve) { 245 | // Handle errors by rejecting the promise 246 | if (err) { 247 | return reject(err); 248 | } 249 | 250 | // Error(s) returned? 251 | if (body.errors) { 252 | // Stringify and reject promise 253 | return reject(new Error(util.inspect(body.errors))); 254 | } 255 | 256 | // Require 200 OK for success 257 | if (res.statusCode != 200 && res.statusCode != 204) { 258 | // Throw generic error 259 | return reject(new Error('An invalid response code was returned from the API: ' + res.statusCode)); 260 | } 261 | 262 | // Resolve promise with request body 263 | resolve(body); 264 | } 265 | 266 | // Expose the class object 267 | module.exports = CachetAPI; 268 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------