Permalink
Browse files

Add support for AWS Import/Export (AWS.ImportExport)

  • Loading branch information...
1 parent baee9b0 commit 992e19c1d6809c72eca49fbf5ae3c24be084d1db @lsegal lsegal committed Feb 23, 2013
View
@@ -150,6 +150,11 @@ The SDK currently supports the following services:
<td>2010-05-08</td>
<td>AWS.IAM</td>
</tr>
+ <tr>
+ <td>AWS Import/Export</td>
+ <td>2010-06-03</td>
+ <td>AWS.ImportExport</td>
+ </tr>
<tr>
<td>AWS OpsWorks</td>
<td>2013-02-18</td>
@@ -22,6 +22,7 @@ Here's the list of supported service objects:
* [AWS.EMR.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/EMR/Client.html)
* [AWS.ElasticTranscoder.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/ElasticTranscoder/Client.html)
* [AWS.IAM.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/IAM/Client.html)
+* [AWS.ImportExport.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/ImportExport/Client.html)
* [AWS.OpsWorks.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/OpsWorks/Client.html)
* [AWS.RDS.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/RDS/Client.html)
* [AWS.Redshift.Client](http://docs.amazonwebservices.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.amazonwebservices.com/AWSJavaScriptSDK/latest/AWS/Redshift/Client.html)
@@ -0,0 +1,185 @@
+/**
+ * Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You
+ * may not use this file except in compliance with the License. A copy of
+ * the License is located at
+ *
+ * http://aws.amazon.com/apache2.0/
+ *
+ * or in the "license" file accompanying this file. This file is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ * ANY KIND, either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+
+AWS = {};
+
+/**
+ * Constructs a service interface and a low-level {Client}. Use the +client+
+ * property to make API calls. Each API operation is exposed as a function on
+ * the +client+.
+ *
+ * === Sending a Request Using ImportExport
+ *
+ * svc = new AWS.ImportExport();
+ * svc.client.OPERATION_NAME(params, function (err, data) {
+ * if (err) {
+ * console.log(err); // an error occurred
+ * } else {
+ * console.log(data); // successful response
+ * }
+ * });
+ *
+ * @!method constructor(options)
+ * Constructs a service interface. The returned service will have a {client}
+ * property that provides access to the API operations.
+ * @option (see AWS.ImportExport.Client.constructor)
+ *
+ * @!attribute client
+ * @return [AWS.ImportExport.Client] A client that provides one method for each
+ * API operation.
+ *
+ * @see AWS.ImportExport.Client
+ *
+ */
+AWS.ImportExport = inherit({})
+
+/**
+ * The low-level ImportExport client class. This class provides one function
+ * for each API operation on the service.
+ *
+ * @!method cancelJob(params, callback)
+ * Calls the CancelJob API operation.
+ * @param params [Object]
+ * * +JobId+ - (*required*, <tt>String</tt>)
+ * @callback callback function(err, data)
+ * Called when a response from the service is returned. If a
+ * callback is not supplied, you must call {AWS.Request.send}
+ * on the returned request object to initiate the request.
+ * @param err [Object] the error object returned from the request.
+ * Set to +null+ if the request is successful.
+ * @param data [Object] the de-serialized data returned from
+ * the request. Set to +null+ if a request error occurs.
+ * The +data+ object has the following properties:
+ * * +Success+ - (<tt>Boolean</tt>)
+ * @return [AWS.Request] a handle to the operation request for
+ * subsequent event callback registration.
+ *
+ * @!method createJob(params, callback)
+ * Calls the CreateJob API operation.
+ * @param params [Object]
+ * * +JobType+ - (*required*, <tt>String</tt>)
+ * * +Manifest+ - (*required*, <tt>String</tt>)
+ * * +ManifestAddendum+ - (<tt>String</tt>)
+ * * +ValidateOnly+ - (*required*, <tt>Boolean</tt>)
+ * @callback callback function(err, data)
+ * Called when a response from the service is returned. If a
+ * callback is not supplied, you must call {AWS.Request.send}
+ * on the returned request object to initiate the request.
+ * @param err [Object] the error object returned from the request.
+ * Set to +null+ if the request is successful.
+ * @param data [Object] the de-serialized data returned from
+ * the request. Set to +null+ if a request error occurs.
+ * The +data+ object has the following properties:
+ * * +JobId+ - (<tt>String</tt>)
+ * * +JobType+ - (<tt>String</tt>)
+ * * +AwsShippingAddress+ - (<tt>String</tt>)
+ * * +Signature+ - (<tt>String</tt>)
+ * * +SignatureFileContents+ - (<tt>String</tt>)
+ * * +WarningMessage+ - (<tt>String</tt>)
+ * @return [AWS.Request] a handle to the operation request for
+ * subsequent event callback registration.
+ *
+ * @!method getStatus(params, callback)
+ * Calls the GetStatus API operation.
+ * @param params [Object]
+ * * +JobId+ - (*required*, <tt>String</tt>)
+ * @callback callback function(err, data)
+ * Called when a response from the service is returned. If a
+ * callback is not supplied, you must call {AWS.Request.send}
+ * on the returned request object to initiate the request.
+ * @param err [Object] the error object returned from the request.
+ * Set to +null+ if the request is successful.
+ * @param data [Object] the de-serialized data returned from
+ * the request. Set to +null+ if a request error occurs.
+ * The +data+ object has the following properties:
+ * * +JobId+ - (<tt>String</tt>)
+ * * +JobType+ - (<tt>String</tt>)
+ * * +AwsShippingAddress+ - (<tt>String</tt>)
+ * * +LocationCode+ - (<tt>String</tt>)
+ * * +LocationMessage+ - (<tt>String</tt>)
+ * * +ProgressCode+ - (<tt>String</tt>)
+ * * +ProgressMessage+ - (<tt>String</tt>)
+ * * +Carrier+ - (<tt>String</tt>)
+ * * +TrackingNumber+ - (<tt>String</tt>)
+ * * +LogBucket+ - (<tt>String</tt>)
+ * * +LogKey+ - (<tt>String</tt>)
+ * * +ErrorCount+ - (<tt>Integer</tt>)
+ * * +Signature+ - (<tt>String</tt>)
+ * * +SignatureFileContents+ - (<tt>String</tt>)
+ * * +CurrentManifest+ - (<tt>String</tt>)
+ * * +CreationDate+ - (<tt>Date</tt>)
+ * @return [AWS.Request] a handle to the operation request for
+ * subsequent event callback registration.
+ *
+ * @!method listJobs(params, callback)
+ * Calls the ListJobs API operation.
+ * @param params [Object]
+ * * +MaxJobs+ - (<tt>Integer</tt>)
+ * * +Marker+ - (<tt>String</tt>)
+ * @callback callback function(err, data)
+ * Called when a response from the service is returned. If a
+ * callback is not supplied, you must call {AWS.Request.send}
+ * on the returned request object to initiate the request.
+ * @param err [Object] the error object returned from the request.
+ * Set to +null+ if the request is successful.
+ * @param data [Object] the de-serialized data returned from
+ * the request. Set to +null+ if a request error occurs.
+ * The +data+ object has the following properties:
+ * * +Jobs+ - (<tt>Array<Object></tt>)
+ * * +JobId+ - (<tt>String</tt>)
+ * * +CreationDate+ - (<tt>Date</tt>)
+ * * +IsCanceled+ - (<tt>Boolean</tt>)
+ * * +JobType+ - (<tt>String</tt>)
+ * * +IsTruncated+ - (<tt>Boolean</tt>)
+ * @return [AWS.Request] a handle to the operation request for
+ * subsequent event callback registration.
+ *
+ * @!method updateJob(params, callback)
+ * Calls the UpdateJob API operation.
+ * @param params [Object]
+ * * +JobId+ - (*required*, <tt>String</tt>)
+ * * +Manifest+ - (*required*, <tt>String</tt>)
+ * * +JobType+ - (*required*, <tt>String</tt>)
+ * * +ValidateOnly+ - (*required*, <tt>Boolean</tt>)
+ * @callback callback function(err, data)
+ * Called when a response from the service is returned. If a
+ * callback is not supplied, you must call {AWS.Request.send}
+ * on the returned request object to initiate the request.
+ * @param err [Object] the error object returned from the request.
+ * Set to +null+ if the request is successful.
+ * @param data [Object] the de-serialized data returned from
+ * the request. Set to +null+ if a request error occurs.
+ * The +data+ object has the following properties:
+ * * +Success+ - (<tt>Boolean</tt>)
+ * * +WarningMessage+ - (<tt>String</tt>)
+ * @return [AWS.Request] a handle to the operation request for
+ * subsequent event callback registration.
+ *
+ *
+ * @!method constructor(options)
+ * Constructs a service client object. This client has one method for
+ * each API operation.
+ * @option options [String] endpoint The endpoint URI to send requests
+ * to. The default endpoint is built from the configured +region+.
+ * The endpoint should be a string like <tt>'https://s3.amazonaws.com'</tt>.
+ * @option (see AWS.Config.constructor)
+ *
+ * @!attribute endpoint
+ * @return [AWS.Endpoint] an Endpoint object representing'
+ * the endpoint URL for service requests.'
+ *
+ */
+AWS.ImportExport.Client = inherit({});
@@ -0,0 +1,65 @@
+# Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"). You
+# may not use this file except in compliance with the License. A copy of
+# the License is located at
+#
+# http://aws.amazon.com/apache2.0/
+#
+# or in the "license" file accompanying this file. This file is
+# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+# ANY KIND, either express or implied. See the License for the specific
+# language governing permissions and limitations under the License.
+
+# language: en
+@importexport
+Feature: AWS Import/Export
+
+ I want to use AWS Import/Export
+
+ Scenario: Creating a job
+ Given I create a bucket
+ When I create an Import job with manifest:
+ """
+ manifestVersion: 2.0
+ accessKeyId: {ACCESS_KEY_ID}
+ bucket: {BUCKET}
+ deviceId: ABCDE
+ generator: AWS ImportExport Web Service Tool 1.0
+ prefix: imported/
+ eraseDevice: no
+ returnAddress:
+ name: Joe Random
+ company: Amazon Web Services
+ street1: 123 Any Street
+ city: Anytown
+ stateOrProvince: WA
+ postalCode: 91111
+ phoneNumber: 555-555-0100
+ country: USA
+ serviceLevel: expeditedShipping
+ """
+ And I store the Import job ID
+ And I get the Import job status
+ Then the result should contain a property CreationDate with a Date
+ And I cancel the Import job
+ And the result should contain Success with expression true
+ And I get the Import job status
+ Then the result should contain ProgressCode with string value "Canceled"
+ And I delete the bucket
+
+ Scenario: Listing jobs
+ When I list Import/Export jobs
+ Then the result should contain a property IsTruncated with a boolean
+ And the result should contain a property Jobs with an Array
+
+ Scenario: Error handling
+ When I create an Import job with manifest:
+ """
+ INVALID MANIFEST
+ """
+ Then the error code should be "MalformedManifestException"
+ And the error message should be:
+ """
+ Your manifest is not well-formed
+ """
@@ -0,0 +1,57 @@
+/**
+ * Copyright 2012-2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You
+ * may not use this file except in compliance with the License. A copy of
+ * the License is located at
+ *
+ * http://aws.amazon.com/apache2.0/
+ *
+ * or in the "license" file accompanying this file. This file is
+ * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
+ * ANY KIND, either express or implied. See the License for the specific
+ * language governing permissions and limitations under the License.
+ */
+
+module.exports = function() {
+ this.Before("@importexport", function (callback) {
+ this.s3 = new this.AWS.S3.Client();
+ this.client = new this.AWS.ImportExport.Client();
+ callback();
+ });
+
+ this.When(/^I create an (Import|Export) job with manifest:$/, function(type, manifest, callback) {
+ manifest = manifest.replace('{ACCESS_KEY_ID}', this.client.config.credentials.accessKeyId);
+ manifest = manifest.replace('{BUCKET}', this.bucket);
+ var params = {JobType: type, Manifest: manifest, ValidateOnly: false};
+ this.request(null, 'createJob', params, callback, false);
+ });
+
+ this.When(/^I store the Import job ID$/, function(callback) {
+ this.jobId = this.data.JobId;
+ callback();
+ });
+
+ this.Then(/^the result should contain (\S+) with expression (.+)$/, function(property, expr, callback) {
+ this.assert.equal(this.data[property], eval(expr));
+ callback();
+ });
+
+ this.Then(/^the result should contain (\S+) with string value "([^"]*)"$/, function(property, value, callback) {
+ this.assert.equal(this.data[property], value);
+ callback();
+ });
+
+ this.When(/^I get the Import job status$/, function(callback) {
+ this.request(null, 'getStatus', {JobId: this.jobId}, callback);
+ });
+
+ this.When(/^I cancel the Import job$/, function(callback) {
+ var params = {JobId: this.jobId};
+ this.request(null, 'cancelJob', params, callback);
+ });
+
+ this.When(/^I list Import\/Export jobs$/, function(callback) {
+ this.request(null, 'listJobs', {}, callback);
+ });
+};
View
@@ -32,6 +32,7 @@ require('./services/elb');
require('./services/emr');
require('./services/glacier');
require('./services/iam');
+require('./services/importexport');
require('./services/opsworks');
require('./services/rds');
require('./services/redshift');
Oops, something went wrong.

0 comments on commit 992e19c

Please sign in to comment.