Permalink
Browse files

Finished renaming Service to Client (including files, tests, etc).

  • Loading branch information...
1 parent 0975672 commit 4fa2d20b51656d5711abe4b1b72821ccd9d564b5 @trevorrowe trevorrowe committed Nov 29, 2012
Showing with 125 additions and 117 deletions.
  1. +1 −1 features/s3/step_definitions/hooks.js
  2. +4 −4 lib/client.js
  3. +4 −4 lib/http.js
  4. 0 lib/{json_service.js → json_client.js}
  5. +8 −8 lib/promise.js
  6. 0 lib/{query_service.js → query_client.js}
  7. 0 lib/{rest_service.js → rest_client.js}
  8. +1 −1 lib/{rest_xml_service.js → rest_xml_client.js}
  9. +2 −2 lib/services/dynamodb.api.js
  10. +6 −4 lib/services/dynamodb.js
  11. +2 −2 lib/services/ec2.api.js
  12. +6 −4 lib/services/ec2.js
  13. +2 −2 lib/services/s3.api.js
  14. +6 −4 lib/services/s3.js
  15. +1 −1 lib/services/simpleworkflow.api.js
  16. +6 −4 lib/services/simpleworkflow.js
  17. +3 −3 test/integration/dynamodb.spec.coffee
  18. +3 −3 test/integration/ec2.spec.coffee
  19. +4 −4 test/integration/s3.spec.coffee
  20. +3 −3 test/integration/simpleworkflow.spec.coffee
  21. +5 −5 test/unit/aws_request.spec.coffee
  22. +24 −24 test/unit/client.spec.coffee
  23. +1 −1 test/unit/{json_service.spec.coffee → json_client.spec.coffee}
  24. +1 −1 test/unit/{query_service.spec.coffee → query_client.spec.coffee}
  25. +1 −1 test/unit/query_param_serializer.spec.coffee
  26. +9 −9 test/unit/request_handler.spec.coffee
  27. +1 −1 test/unit/{rest_service.spec.coffee → rest_client.spec.coffee}
  28. +1 −1 test/unit/{rest_xml_service.spec.coffee → rest_xml_client.spec.coffee}
  29. +3 −3 test/unit/services/dynamodb.spec.coffee
  30. +3 −3 test/unit/services/ec2.spec.coffee
  31. +12 −12 test/unit/services/s3.spec.coffee
  32. +1 −1 test/unit/sigv2.spec.coffee
  33. +1 −1 test/unit/sigv4.spec.coffee
@@ -16,7 +16,7 @@
module.exports = function () {
this.Before("@s3", function (callback) {
- this.s3 = new this.AWS.S3();
+ this.s3 = new this.AWS.S3.Client();
callback();
});
View
@@ -36,11 +36,11 @@ AWS.Client = inherit({
makeRequest: function makeRequest(method, params, options) {
- var service = options === undefined ? this :
+ var client = options === undefined ? this :
new this.constructor(AWS.util.merge(this.config, options));
var awsResponse = new AWS.AWSResponse({
- service: service,
+ client: client,
method: method,
params: params
});
@@ -106,7 +106,7 @@ AWS.Client = inherit({
},
// How many times a failed request should be retried before giving up.
- // the defaultRetryCount can be overriden by service classes.
+ // the defaultRetryCount can be overriden by client classes.
numRetries: function numRetries() {
if (this.config.maxRetries !== undefined) {
return this.config.maxRetries;
@@ -130,7 +130,7 @@ AWS.Client = inherit({
},
throttledError: function throttledError(error) {
- // this logic varies between services
+ // this logic varies between clients
return (error.code == 'ProvisionedThroughputExceededException');
},
View
@@ -72,13 +72,13 @@ AWS.RequestHandler = inherit({
constructor: function RequestHandler(awsRequest) {
this.awsRequest = awsRequest;
this.awsResponse = awsRequest.awsResponse;
- this.service = this.awsResponse.service;
+ this.client = this.awsResponse.client;
this.method = this.awsResponse.method;
this.params = this.awsResponse.params;
},
makeRequest: function makeRequest() {
- var httpRequest = this.service.buildRequest(this.method, this.params);
+ var httpRequest = this.client.buildRequest(this.method, this.params);
httpRequest.sign();
this.sendRequest(httpRequest);
},
@@ -145,7 +145,7 @@ AWS.RequestHandler = inherit({
handleHttpResponse: function handleHttpResponse(httpResponse) {
var self = this;
- this.service.parseResponse(httpResponse, this.method, function (error, data) {
+ this.client.parseResponse(httpResponse, this.method, function (error, data) {
if (error)
self.handleError(error);
else
@@ -163,7 +163,7 @@ AWS.RequestHandler = inherit({
retryRequest: function retryRequest(error) {
- var delays = this.service.retryDelays();
+ var delays = this.client.retryDelays();
var delay = delays[this.awsResponse.retryCount];
this.awsResponse.retryCount += 1;
File renamed without changes.
View
@@ -28,7 +28,7 @@ AWS.AWSRequest = inherit({
},
/**
- * @param callback [Function] this function is called when the service
+ * @param callback [Function] this function is called when the client
* returns any data
* @option options bind [Object] (response object) an object to bind
* the callback function to. Defaults to the response object.
@@ -43,7 +43,7 @@ AWS.AWSRequest = inherit({
},
/**
- * @param callback [Function] this function is called when the service
+ * @param callback [Function] this function is called when the client
* returns a successful response.
* @option options bind [Object] (response object) an object to bind
* the callback function to. Defaults to the response object.
@@ -59,12 +59,12 @@ AWS.AWSRequest = inherit({
},
/**
- * @param callback [Function] this function is called when the service
+ * @param callback [Function] this function is called when the client
* responds with an error or if a request could not be made.
* @option options bind [Object] (response object) an object to bind
* the callback function to. Defaults to the response object.
* @return [this]
- * @param {Function} callback This function is called when the service
+ * @param {Function} callback This function is called when the client
*/
fail: function fail(callback, options) {
if (this.state === 'fail') {
@@ -77,7 +77,7 @@ AWS.AWSRequest = inherit({
/**
* @param callback [Function] this function is called after after
- * the service returns with a successful response or an error.
+ * the client returns with a successful response or an error.
* It is also called when the request could not be completed.
* @option options bind [Object] (response object) an object to bind
* the callback function to. Defaults to the response object.
@@ -141,13 +141,13 @@ AWS.AWSRequest = inherit({
* @api private
*/
addConfigCallback: function addConfigCallback(cbMethod, configName) {
- if (!this.awsResponse.service) return;
+ if (!this.awsResponse.client) return;
if (configName === undefined) {
configName = 'on' + cbMethod.charAt(0).toUpperCase() + cbMethod.slice(1);
}
- var callbacks = this.awsResponse.service.config[configName];
+ var callbacks = this.awsResponse.client.config[configName];
if (!(callbacks instanceof Array) && callbacks !== undefined) {
callbacks = [callbacks];
}
@@ -166,7 +166,7 @@ AWS.AWSResponse = inherit({
constructor: function AWSResponse(options) {
// the request "context"
- this.service = options.service;
+ this.client = options.client;
this.method = options.method;
this.params = options.params;
File renamed without changes.
File renamed without changes.
@@ -14,7 +14,7 @@
*/
var AWS = require('./core');
-require('./rest_service');
+require('./rest_client');
require('./xml/builder');
require('./xml/parser');
var inherit = AWS.util.inherit;
@@ -15,7 +15,7 @@
var AWS = require('../core');
-AWS.DynamoDB.prototype.api = {
+AWS.DynamoDB.Client.prototype.api = {
format: 'json',
targetPrefix: 'DynamoDB_20111205.',
timestampFormat: 'iso8601',
@@ -957,4 +957,4 @@ AWS.DynamoDB.prototype.api = {
}
}
}
-};
+};
@@ -16,12 +16,14 @@
var AWS = require('../core');
var inherit = AWS.util.inherit;
-require('../json_service');
+require('../json_client');
require('../sigv4');
-AWS.DynamoDB = inherit(AWS.JSONClient, {
+AWS.DynamoDB = {};
- constructor: function DynamoDB(config) {
+AWS.DynamoDB.Client = inherit(AWS.JSONClient, {
+
+ constructor: function DynamoDBClient(config) {
this.serviceName = 'dynamodb';
AWS.JSONClient.call(this, config);
},
@@ -47,4 +49,4 @@ AWS.DynamoDB = inherit(AWS.JSONClient, {
require('./dynamodb.api');
-AWS.Client.defineMethods(AWS.DynamoDB);
+AWS.Client.defineMethods(AWS.DynamoDB.Client);
@@ -15,7 +15,7 @@
var AWS = require('../core');
-AWS.EC2.prototype.api = {
+AWS.EC2.Client.prototype.api = {
format: 'query',
apiVersion: '2012-07-20',
timestampFormat: 'iso8601',
@@ -8899,4 +8899,4 @@ AWS.EC2.prototype.api = {
}
}
}
-};
+};
View
@@ -16,12 +16,14 @@
var AWS = require('../core');
var inherit = AWS.util.inherit;
-require('../query_service');
+require('../query_client');
require('../sigv2');
-AWS.EC2 = inherit(AWS.QueryClient, {
+AWS.EC2 = {};
- constructor: function EC2(config) {
+AWS.EC2.Client = inherit(AWS.QueryClient, {
+
+ constructor: function EC2Client(config) {
this.serviceName = 'ec2';
AWS.QueryClient.call(this, config);
},
@@ -47,4 +49,4 @@ AWS.EC2 = inherit(AWS.QueryClient, {
require('./ec2.api');
-AWS.Client.defineMethods(AWS.EC2);
+AWS.Client.defineMethods(AWS.EC2.Client);
@@ -15,7 +15,7 @@
var AWS = require('../core');
-AWS.S3.prototype.api = {
+AWS.S3.Client.prototype.api = {
format: 'rest-xml',
xmlNamespace: 'http://s3.amazonaws.com/doc/2006-03-01/',
timestampFormat: 'rfc822',
@@ -2190,4 +2190,4 @@ AWS.S3.prototype.api = {
}
}
}
-};
+};
View
@@ -16,12 +16,14 @@
var AWS = require('../core');
var inherit = AWS.util.inherit;
-require('../rest_xml_service');
+require('../rest_xml_client');
require('../sigvs3');
-AWS.S3 = inherit(AWS.RESTXMLClient, {
+AWS.S3 = {};
- constructor: function S3(config) {
+AWS.S3.Client = inherit(AWS.RESTXMLClient, {
+
+ constructor: function S3Client(config) {
this.serviceName = 's3';
AWS.RESTXMLClient.call(this, config);
this.setEndpoint((config || {}).endpoint, config);
@@ -172,4 +174,4 @@ AWS.S3 = inherit(AWS.RESTXMLClient, {
require('./s3.api');
-AWS.Client.defineMethods(AWS.S3);
+AWS.Client.defineMethods(AWS.S3.Client);
@@ -15,7 +15,7 @@
var AWS = require('../core');
-AWS.SimpleWorkflow.prototype.api = {
+AWS.SimpleWorkflow.Client.prototype.api = {
format: 'json',
targetPrefix: 'SimpleWorkflowService.',
timestampFormat: 'unixTimestamp',
@@ -16,12 +16,14 @@
var AWS = require('../core');
var inherit = AWS.util.inherit;
-require('../json_service');
+require('../json_client');
require('../sigv3');
-AWS.SimpleWorkflow = inherit(AWS.JSONClient, {
+AWS.SimpleWorkflow = {};
- constructor: function SimpleWorkflow(config) {
+AWS.SimpleWorkflow.Client = inherit(AWS.JSONClient, {
+
+ constructor: function SimpleWorkflowClient(config) {
this.serviceName = 'swf';
AWS.JSONClient.call(this, config);
},
@@ -32,4 +34,4 @@ AWS.SimpleWorkflow = inherit(AWS.JSONClient, {
require('./simpleworkflow.api');
-AWS.Client.defineMethods(AWS.SimpleWorkflow);
+AWS.Client.defineMethods(AWS.SimpleWorkflow.Client);
@@ -14,18 +14,18 @@
helpers = require('./helpers'); AWS = helpers.AWS
describe 'AWS.DynamoDB', ->
- service = new AWS.DynamoDB()
+ client = new AWS.DynamoDB.Client()
describe 'listTables', ->
it 'should send a request with parameters', ->
- helpers.integration (-> service.listTables(Limit: 3)), (resp) ->
+ helpers.integration (-> client.listTables(Limit: 3)), (resp) ->
expect(resp.error).toEqual(null)
expect(JSON.stringify(resp.data)).toMatch(/\{.*"TableNames":.*\}/)
expect(resp.httpRequest.body).toEqual('{"Limit":3}')
describe 'deleteItem', ->
it 'should fail if TableName not provided', ->
- helpers.integration (-> service.deleteItem()), (resp) ->
+ helpers.integration (-> client.deleteItem()), (resp) ->
errObj =
code: 'ValidationException',
message: 'The paramater \'tableName\' is required but was not present in the request'
@@ -15,14 +15,14 @@ helpers = require('./helpers'); AWS = helpers.AWS
describe 'AWS.EC2', ->
- service = new AWS.EC2()
+ client = new AWS.EC2.Client()
it 'should send a request with parameters', ->
# limit the list of regions returned with this filter
params = { RegionNames: ['us-east-1', 'us-west-1'] }
- helpers.integration (-> service.describeRegions(params)), (resp) ->
+ helpers.integration (-> client.describeRegions(params)), (resp) ->
expect(resp.error).toEqual(null)
expect(resp.data.Regions).toEqual([
{ RegionName: 'us-east-1', Endpoint: 'ec2.us-east-1.amazonaws.com' },
@@ -33,7 +33,7 @@ describe 'AWS.EC2', ->
params = { InstanceIds : ['i-12345678'] }
- helpers.integration (-> service.describeInstances(params)), (resp) ->
+ helpers.integration (-> client.describeInstances(params)), (resp) ->
expect(resp.data).toEqual(null)
expect(resp.error).toEqual(
code : 'InvalidInstanceID.NotFound',
@@ -16,24 +16,24 @@ helpers = require('./helpers'); AWS = helpers.AWS
describe 'AWS.S3', ->
beforeEach ->
- service = new AWS.S3()
+ client = new AWS.S3.Client()
describe 'CRUD buckets', ->
it 'should be able to create and delete buckets in a different region', ->
- service = new AWS.S3(region:'eu-west-1')
+ client = new AWS.S3.Client(region:'eu-west-1')
bucketName = 'aws-sdk-js-integration-' + AWS.util.date.unixTimestamp()
params = { Bucket: bucketName, LocationConstraint: 'EU' }
# create a bucket in the EU
- helpers.integration (-> service.createBucket(params)), (resp) ->
+ helpers.integration (-> client.createBucket(params)), (resp) ->
expect(resp.error).toEqual(null)
expect(resp.data.Location).toEqual("http://#{bucketName}.s3.amazonaws.com/")
# delete the bucket
- helpers.integration (-> service.deleteBucket({Bucket:bucketName})), (resp2) ->
+ helpers.integration (-> client.deleteBucket({Bucket:bucketName})), (resp2) ->
expect(resp2.error).toEqual(null)
expect(resp2.data.RequestId).toBeDefined()
Oops, something went wrong.

0 comments on commit 4fa2d20

Please sign in to comment.