Permalink
Browse files

Migrate Amazon CloudWatch from the old awssum, to the new plugin arch…

…itecture.
  • Loading branch information...
0 parents commit f8375abdd3da3a34c1b221edeb39496a8f7d7adf @chilts committed Mar 2, 2013
Showing with 426 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +29 −0 LICENSE
  3. 0 README.md
  4. +88 −0 awssum-amazon-cloudwatch.js
  5. +213 −0 config.js
  6. +48 −0 package.json
  7. +46 −0 test/integration/amazon-cloudwatch.js
@@ -0,0 +1,2 @@
+node_modules/
+*~
@@ -0,0 +1,29 @@
+-------------------------------------------------------------------------------
+
+This software is published under the MIT license as published here:
+
+* http://opensource.org/licenses/MIT
+
+-------------------------------------------------------------------------------
+
+Copyright 2011-2013 Apps Attic Ltd. All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+of the Software, and to permit persons to whom the Software is furnished to do
+so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+-------------------------------------------------------------------------------
No changes.
@@ -0,0 +1,88 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// cloudwatch.js - class for AWS Elastic Load Balancing
+//
+// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
+// Written by Andrew Chilton <chilts@appsattic.com>
+//
+// License: http://opensource.org/licenses/MIT
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------------------------------------------------
+// requires
+
+// built-ins
+var util = require('util');
+
+// dependencies
+var _ = require('underscore');
+
+// our own
+var awssum = require('awssum');
+var amazon = require('awssum-amazon');
+var operations = require('./config.js');
+
+// --------------------------------------------------------------------------------------------------------------------
+// package variables
+
+var MARK = 'cloudwatch: ';
+
+// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html
+var endPoint = {};
+endPoint[amazon.US_EAST_1] = "monitoring.us-east-1.amazonaws.com";
+endPoint[amazon.US_WEST_1] = "monitoring.us-west-1.amazonaws.com";
+endPoint[amazon.US_WEST_2] = "monitoring.us-west-2.amazonaws.com";
+endPoint[amazon.EU_WEST_1] = "monitoring.eu-west-1.amazonaws.com";
+endPoint[amazon.AP_SOUTHEAST_1] = "monitoring.ap-southeast-1.amazonaws.com";
+endPoint[amazon.AP_SOUTHEAST_2] = "monitoring.ap-southeast-2.amazonaws.com";
+endPoint[amazon.AP_NORTHEAST_1] = "monitoring.ap-northeast-1.amazonaws.com";
+endPoint[amazon.SA_EAST_1] = "monitoring.sa-east-1.amazonaws.com";
+endPoint[amazon.US_GOV_WEST_1] = "monitoring.us-gov-west-1.amazonaws.com";
+
+var version = '2010-08-01';
+
+// --------------------------------------------------------------------------------------------------------------------
+// constructor
+
+var CloudWatch = function(opts) {
+ var self = this;
+
+ // call the superclass for initialisation
+ CloudWatch.super_.call(this, opts);
+
+ // check the region is valid
+ if ( ! endPoint[opts.region] ) {
+ throw MARK + "invalid region '" + opts.region + "'";
+ }
+
+ return self;
+};
+
+// inherit from Amazon
+util.inherits(CloudWatch, amazon.Amazon);
+
+// --------------------------------------------------------------------------------------------------------------------
+// methods we need to implement from awssum.js/amazon.js
+
+CloudWatch.prototype.host = function() {
+ return endPoint[this.region()];
+};
+
+CloudWatch.prototype.version = function() {
+ return version;
+};
+
+// --------------------------------------------------------------------------------------------------------------------
+// operations on the service
+
+_.each(operations, function(operation, operationName) {
+ CloudWatch.prototype[operationName] = awssum.makeOperation(operation);
+});
+
+// --------------------------------------------------------------------------------------------------------------------
+// exports
+
+exports.CloudWatch = CloudWatch;
+
+// --------------------------------------------------------------------------------------------------------------------
@@ -0,0 +1,213 @@
+// --------------------------------------------------------------------------------------------------------------------
+//
+// cloudwatch-config.js - config for AWS CloudWatch
+//
+// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
+// Written by Andrew Chilton <chilts@appsattic.com>
+//
+// License: http://opensource.org/licenses/MIT
+//
+// --------------------------------------------------------------------------------------------------------------------
+
+var required = {
+ required : true,
+ type : 'param',
+};
+
+var optional = {
+ required : false,
+ type : 'param',
+};
+
+var paramDataRequired = {
+ // does <Name>.member.N.<whatever>
+ required : true,
+ type : 'param-data',
+ prefix : 'member',
+};
+
+var paramDataOptional = {
+ // does <Name>.member.N.<whatever>
+ required : false,
+ type : 'param-data',
+ prefix : 'member',
+};
+
+// --------------------------------------------------------------------------------------------------------------------
+
+module.exports = {
+
+ DeleteAlarms : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DeleteAlarms.html',
+ defaults : {
+ Action : 'DeleteAlarms',
+ },
+ args : {
+ Action : required,
+ AlarmNames : paramDataRequired,
+ },
+ },
+
+ DescribeAlarmHistory : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarmHistory.html',
+ defaults : {
+ Action : 'DescribeAlarmHistory',
+ },
+ args : {
+ Action : required,
+ AlarmName : optional,
+ EndDate : optional,
+ HistoryItemType : optional,
+ MaxRecords : optional,
+ NextToken : optional,
+ StartDate : optional,
+ },
+ },
+
+ DescribeAlarms : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarms.html',
+ defaults : {
+ Action : 'DescribeAlarms',
+ },
+ args : {
+ Action : required,
+ ActionPrefix : optional,
+ AlarmNamePrefix : optional,
+ AlarmNames : paramDataOptional,
+ MaxRecords : optional,
+ NextToken : optional,
+ StateValue : optional,
+ },
+ },
+
+ DescribeAlarmsForMetric : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DescribeAlarmsForMetric.html',
+ defaults : {
+ Action : 'DescribeAlarmsForMetric',
+ },
+ args : {
+ Action : required,
+ Dimensions : paramDataOptional,
+ MetricName : required,
+ Namespace : required,
+ Period : optional,
+ Statistic : optional,
+ Unit : optional,
+ },
+ },
+
+ DisableAlarmActions : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_DisableAlarmActions.html',
+ defaults : {
+ Action : 'DisableAlarmActions',
+ },
+ args : {
+ Action : required,
+ AlarmNames : paramDataRequired,
+ },
+ },
+
+ EnableAlarmActions : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_EnableAlarmActions.html',
+ defaults : {
+ Action : 'EnableAlarmActions',
+ },
+ args : {
+ Action : required,
+ AlarmNames : paramDataRequired,
+ },
+ },
+
+ GetMetricStatistics : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_GetMetricStatistics.html',
+ defaults : {
+ Action : 'GetMetricStatistics',
+ },
+ args : {
+ Action : required,
+ Dimensions : paramDataOptional,
+ EndTime : required,
+ MetricName : required,
+ Namespace : required,
+ Period : required,
+ StartTime : required,
+ Statistics : paramDataRequired,
+ Unit : optional,
+ },
+ },
+
+ ListMetrics : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_ListMetrics.html',
+ defaults : {
+ Action : 'ListMetrics',
+ },
+ args : {
+ Action : required,
+ Dimensions : paramDataOptional,
+ MetricName : optional,
+ Namespace : optional,
+ NextToken : optional,
+ },
+ },
+
+ PutMetricAlarm : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricAlarm.html',
+ defaults : {
+ Action : 'PutMetricAlarm',
+ },
+ args : {
+ Action : required,
+ ActionsEnabled : optional,
+ AlarmActions : paramDataOptional,
+ AlarmDescription : optional,
+ AlarmName : required,
+ ComparisonOperator : required,
+ Dimensions : paramDataOptional,
+ EvaluationPeriods : required,
+ InsufficientDataActions : paramDataOptional,
+ MetricName : required,
+ Namespace : required,
+ OkActions : {
+ // does <Name>.member.N.<whatever>
+ name : 'OKActions',
+ required : false,
+ type : 'param-data',
+ prefix : 'member',
+ },
+ Period : required,
+ Statistic : required,
+ Threshold : required,
+ Unit : optional,
+ },
+ },
+
+ PutMetricData : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_PutMetricData.html',
+ defaults : {
+ Action : 'PutMetricData',
+ },
+ args : {
+ Action : required,
+ // does <Name>.member.<N>.<whatever>
+ MetricData : paramDataRequired,
+ Namespace : required,
+ },
+ },
+
+ SetAlarmState : {
+ url : 'http://docs.amazonwebservices.com/AmazonCloudWatch/latest/APIReference/API_SetAlarmState.html',
+ defaults : {
+ Action : 'SetAlarmState',
+ },
+ args : {
+ Action : required,
+ AlarmName : required,
+ StateReason : required,
+ StateReasonData : optional,
+ StateValue : required,
+ },
+ },
+
+};
+
+// --------------------------------------------------------------------------------------------------------------------
@@ -0,0 +1,48 @@
+{
+ "name" : "awssum-amazon-cloudwatch",
+ "description" : "NodeJS module to talk to Amazon CloudWatch.",
+ "version" : "1.0.0",
+
+ "main" : "awssum-amazon-cloudwatch.js",
+ "engines" : {
+ "node" : ">= 0.6.0"
+ },
+ "peerDependencies" : {
+ "awssum-amazon" : "1.x.x"
+ },
+ "dependencies" : {
+ "data2xml" : "0.8.x",
+ "underscore" : "1.4.x",
+ "dateformat" : "1.0.4-1.2.3"
+ },
+ "devDependencies" : {
+ "tap" : "0.4.x"
+ },
+ "scripts" : {
+ "test" : "tap test/*.js test/integration/*.js"
+ },
+
+ "homepage" : "https://awssum.io/",
+ "repository" : {
+ "type" : "git",
+ "url" : "git://github.com/awssum/awssum-amazon-cloudwatch.git"
+ },
+ "bugs" : {
+ "url" : "http://github.com/awssum/awssum-amazon-cloudwatch/issues",
+ "mail" : "andychilton@gmail.com"
+ },
+
+ "author" : {
+ "name" : "Andrew Chilton",
+ "email" : "andychilton@gmail.com",
+ "url" : "http://chilts.org/"
+ },
+ "contributors" : [],
+ "licenses" : [{
+ "type" : "MIT",
+ "url" : "http://github.com/awssum/awssum-amazon-cloudwatch/raw/master/LICENSE"
+ }],
+ "keywords" : [
+ "awssum", "awssum-plugin", "amazon", "aws", "webapi", "api", "cloudwatch"
+ ]
+}
Oops, something went wrong. Retry.

0 comments on commit f8375ab

Please sign in to comment.