This repository has been archived by the owner on Jun 5, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
awssum-amazon-elasticache.js
87 lines (65 loc) · 3.02 KB
/
awssum-amazon-elasticache.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
// --------------------------------------------------------------------------------------------------------------------
//
// elasticache.js - class for AWS Elasticache
//
// Copyright (c) 2011 AppsAttic Ltd - http://www.appsattic.com/
// Written by Andrew Chilton <[email protected]>
//
// 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 = 'elasticache: ';
// From: http://docs.amazonwebservices.com/general/latest/gr/rande.html
var endPoint = {};
endPoint[amazon.US_EAST_1] = "elasticache.us-east-1.amazonaws.com";
endPoint[amazon.US_WEST_1] = "elasticache.us-west-1.amazonaws.com";
endPoint[amazon.US_WEST_2] = "elasticache.us-west-2.amazonaws.com";
endPoint[amazon.EU_WEST_1] = "elasticache.eu-west-1.amazonaws.com";
endPoint[amazon.AP_SOUTHEAST_1] = "elasticache.ap-southeast-1.amazonaws.com";
endPoint[amazon.AP_NORTHEAST_1] = "elasticache.ap-northeast-1.amazonaws.com";
endPoint[amazon.SA_EAST_1] = "elasticache.sa-east-1.amazonaws.com";
// endPoint[amazon.US_GOV_WEST_1] = "...";
var version = '2011-07-15';
// --------------------------------------------------------------------------------------------------------------------
// constructor
var ElastiCache = function(opts) {
var self = this;
// call the superclass for initialisation
ElastiCache.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(ElastiCache, amazon.AmazonSignatureV2);
// --------------------------------------------------------------------------------------------------------------------
// methods we need to implement from awssum.js/amazon.js
ElastiCache.prototype.host = function() {
return endPoint[this.region()];
};
ElastiCache.prototype.version = function() {
return version;
};
// --------------------------------------------------------------------------------------------------------------------
// operations on the service
_.each(operations, function(operation, operationName) {
ElastiCache.prototype[operationName] = awssum.makeOperation(operation);
});
// --------------------------------------------------------------------------------------------------------------------
// exports
exports.ElastiCache = ElastiCache;
// --------------------------------------------------------------------------------------------------------------------