diff --git a/.changes/next-release/bugfix-apiVersion-3752650d.json b/.changes/next-release/bugfix-apiVersion-3752650d.json new file mode 100644 index 0000000000..802e19c58c --- /dev/null +++ b/.changes/next-release/bugfix-apiVersion-3752650d.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "apiVersion", + "description": "Fixes an issue where some service clients would fail to instantiate if an older apiVersion was specified." +} \ No newline at end of file diff --git a/clients/cloudfront.js b/clients/cloudfront.js index 3cd40f6945..d6efc89ef3 100644 --- a/clients/cloudfront.js +++ b/clients/cloudfront.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['cloudfront'] = {}; -AWS.CloudFront = Service.defineService('cloudfront', ['2016-09-07']); +AWS.CloudFront = Service.defineService('cloudfront', ['2013-05-12*', '2013-11-11*', '2014-05-31*', '2014-10-21*', '2014-11-06*', '2015-04-17*', '2015-07-27*', '2015-09-17*', '2016-01-13*', '2016-01-28*', '2016-08-01*', '2016-08-20*', '2016-09-07']); require('../lib/services/cloudfront'); Object.defineProperty(apiLoader.services['cloudfront'], '2016-09-07', { get: function get() { diff --git a/clients/cloudwatchevents.js b/clients/cloudwatchevents.js index 9c2d249d47..a9e44196e0 100644 --- a/clients/cloudwatchevents.js +++ b/clients/cloudwatchevents.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['cloudwatchevents'] = {}; -AWS.CloudWatchEvents = Service.defineService('cloudwatchevents', ['2015-10-07']); +AWS.CloudWatchEvents = Service.defineService('cloudwatchevents', ['2014-02-03*', '2015-10-07']); Object.defineProperty(apiLoader.services['cloudwatchevents'], '2015-10-07', { get: function get() { var model = require('../apis/events-2015-10-07.min.json'); diff --git a/clients/ec2.js b/clients/ec2.js index 4261d61f4a..37ac9fa871 100644 --- a/clients/ec2.js +++ b/clients/ec2.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['ec2'] = {}; -AWS.EC2 = Service.defineService('ec2', ['2016-04-01']); +AWS.EC2 = Service.defineService('ec2', ['2013-06-15*', '2013-10-15*', '2014-02-01*', '2014-05-01*', '2014-06-15*', '2014-09-01*', '2014-10-01*', '2015-03-01*', '2015-04-15*', '2015-10-01*', '2016-04-01']); require('../lib/services/ec2'); Object.defineProperty(apiLoader.services['ec2'], '2016-04-01', { get: function get() { diff --git a/clients/elasticache.js b/clients/elasticache.js index 658c6828e5..4420db7f67 100644 --- a/clients/elasticache.js +++ b/clients/elasticache.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['elasticache'] = {}; -AWS.ElastiCache = Service.defineService('elasticache', ['2015-02-02']); +AWS.ElastiCache = Service.defineService('elasticache', ['2012-11-15*', '2014-03-24*', '2014-07-15*', '2014-09-30*', '2015-02-02']); Object.defineProperty(apiLoader.services['elasticache'], '2015-02-02', { get: function get() { var model = require('../apis/elasticache-2015-02-02.min.json'); diff --git a/clients/inspector.js b/clients/inspector.js index e0a133235a..365ff90945 100644 --- a/clients/inspector.js +++ b/clients/inspector.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['inspector'] = {}; -AWS.Inspector = Service.defineService('inspector', ['2016-02-16']); +AWS.Inspector = Service.defineService('inspector', ['2015-08-18*', '2016-02-16']); Object.defineProperty(apiLoader.services['inspector'], '2016-02-16', { get: function get() { var model = require('../apis/inspector-2016-02-16.min.json'); diff --git a/clients/rds.js b/clients/rds.js index bf942f423f..134f089592 100644 --- a/clients/rds.js +++ b/clients/rds.js @@ -4,7 +4,7 @@ var Service = require('../lib/service'); var apiLoader = require('../lib/api_loader'); apiLoader.services['rds'] = {}; -AWS.RDS = Service.defineService('rds', ['2013-01-10', '2013-02-12', '2013-09-09', '2014-10-31']); +AWS.RDS = Service.defineService('rds', ['2013-01-10', '2013-02-12', '2013-09-09', '2014-09-01*', '2014-10-31']); Object.defineProperty(apiLoader.services['rds'], '2013-01-10', { get: function get() { var model = require('../apis/rds-2013-01-10.min.json'); diff --git a/dist-tools/client-creator.js b/dist-tools/client-creator.js index c3d434c31d..52d7769577 100644 --- a/dist-tools/client-creator.js +++ b/dist-tools/client-creator.js @@ -80,6 +80,7 @@ ClientCreator.prototype.generateClientFileSource = function generateClientFileSo if (!modelVersions) { throw new Error('Unable to get models for ' + modelName); } + var obsoleteVersions = serviceMetadata.versions || []; var versionNumbers = Object.keys(modelVersions); var tab = ' '; var code = ''; @@ -88,7 +89,7 @@ ClientCreator.prototype.generateClientFileSource = function generateClientFileSo code += 'var Service = require(\'../lib/service\');\n'; code += 'var apiLoader = require(\'../lib/api_loader\');\n\n'; code += 'apiLoader.services[\'' + serviceName +'\'] = {};\n'; - code += 'AWS.' + className + ' = Service.defineService(\'' + serviceName + '\', [\'' + versionNumbers.join('\', \'') + '\']);\n'; + code += 'AWS.' + className + ' = Service.defineService(\'' + serviceName + '\', [\'' + [].concat(obsoleteVersions, versionNumbers).sort().join('\', \'') + '\']);\n'; // pull in service customizations if (this.customizationsExist(serviceName)) { code += 'require(\'../lib/services/' + serviceName + '\');\n'; diff --git a/test/service.spec.coffee b/test/service.spec.coffee index 495d37020a..e20ca578a2 100644 --- a/test/service.spec.coffee +++ b/test/service.spec.coffee @@ -1,6 +1,7 @@ helpers = require('./helpers') AWS = helpers.AWS MockService = helpers.MockService +metadata = require('../apis/metadata.json') describe 'AWS.Service', -> @@ -135,6 +136,18 @@ describe 'AWS.Service', -> service = new MockService(sslEnabled: false, endpoint: '{scheme}://{service}.{region}.domain.tld') expect(service.config.endpoint).to.equal('http://mockservice.mock-region.domain.tld') + describe 'will work with', -> + allServices = require('../clients/all') + for own className, ctor of allServices + serviceIdentifier = className.toLowerCase() + # check for obsolete versions + obsoleteVersions = metadata[serviceIdentifier].versions || [] + for version in obsoleteVersions + ((ctor, id, v) -> + it id + ' version ' + v, -> + expect(-> new ctor(apiVersion: v)).not.to.throw() + )(ctor, serviceIdentifier, version) + describe 'setEndpoint', -> FooService = null