UNPKG

5.12 kBMarkdownView Raw
1# @!title Upgrading Notes (1.x to 2.0)
2
3# Upgrading Notes (1.x to 2.0)
4
5This document captures breaking changes from 1.x versions to the first
6stable 2.x (non-RC) release of the AWS SDK for JavaScript.
7
8## 1. Automatic Conversion of Base64 and Timestamp Types on Input/Output
9
10The SDK will now automatically encode and decode base64-encoded values, as well
11as timestamp values, on the user's behalf. This change affects any operation
12where Base64 or Timestamp values were sent by a request or returned in a
13response, i.e., `AWS.DynamoDB` and `AWS.SQS`, which allow for Base64
14encoded values.
15
16User code that previously did base64 conversion no longer requires this.
17Furthermore, values encoded as base64 are now returned as Buffer objects
18from server responses (and can also be passed as Buffer input). For
19example, the following 1.x `SQS.sendMessage()` parameters:
20
21```javascript
22var params = {
23 MessageBody: 'Some Message',
24 MessageAttributes: {
25 attrName: {
26 DataType: 'Binary',
27 BinaryValue: new Buffer('example text').toString('base64')
28 }
29 }
30};
31```
32
33Can be rewritten as:
34
35```javascript
36var params = {
37 MessageBody: 'Some Message',
38 MessageAttributes: {
39 attrName: {
40 DataType: 'Binary',
41 BinaryValue: 'example text'
42 }
43 }
44};
45```
46
47And the message will be read as:
48
49```javascript
50sqs.receiveMessage(params, function(err, data) {
51 // buf is <Buffer 65 78 61 6d 70 6c 65 20 74 65 78 74>
52 var buf = data.Messages[0].MessageAttributes.attrName.BinaryValue;
53 console.log(buf.toString()); // "example text"
54});
55```
56
57## 2. Moved response.data.RequestId to response.requestId
58
59The SDK now stores request IDs for all services in a consistent place on the
60response object, rather than inside the response.data property. This is to
61improve consistency across services that expose request IDs in different ways.
62Note that this is also a breaking change that renames the
63`response.data.RequestId` property to `response.requestId`
64(or `this.requestId` inside of a callback).
65
66To migrate your code, change:
67
68```javascript
69svc.operation(params, function (err, data) {
70 console.log('Request ID:', data.RequestId);
71});
72```
73
74To the following:
75
76```javascript
77svc.operation(params, function () {
78 console.log('Request ID:', this.requestId);
79});
80```
81
82## 3. Exposed Wrapper Elements
83
84If you use {AWS.ElastiCache}, {AWS.RDS}, or {AWS.Redshift}, you must now access
85the response through the top-level output property in the response for certain
86operations. This change corrects the SDK to behave according to documentation
87output, which was previously listing this wrapper element.
88
89Example:
90
91`RDS.describeEngineDefaultParameters()` used to return:
92
93```javascript
94{ Parameters: [ ... ] }
95```
96
97This operation now returns:
98
99```javascript
100{ EngineDefaults: { Parameters: [ ... ] } }
101```
102
103The full list of affected operations for each service are:
104
105**AWS.ElastiCache**: authorizeCacheSecurityGroupIngress, createCacheCluster,
106createCacheParameterGroup, createCacheSecurityGroup, createCacheSubnetGroup,
107createReplicationGroup, deleteCacheCluster, deleteReplicationGroup,
108describeEngineDefaultParameters, modifyCacheCluster, modifyCacheSubnetGroup,
109modifyReplicationGroup, purchaseReservedCacheNodesOffering, rebootCacheCluster,
110revokeCacheSecurityGroupIngress
111
112**AWS.RDS**: addSourceIdentifierToSubscription, authorizeDBSecurityGroupIngress,
113copyDBSnapshot, createDBInstance, createDBInstanceReadReplica,
114createDBParameterGroup, createDBSecurityGroup, createDBSnapshot,
115createDBSubnetGroup, createEventSubscription, createOptionGroup,
116deleteDBInstance, deleteDBSnapshot, deleteEventSubscription,
117describeEngineDefaultParameters, modifyDBInstance, modifyDBSubnetGroup,
118modifyEventSubscription, modifyOptionGroup, promoteReadReplica,
119purchaseReservedDBInstancesOffering, rebootDBInstance,
120removeSourceIdentifierFromSubscription, restoreDBInstanceFromDBSnapshot,
121restoreDBInstanceToPointInTime, revokeDBSecurityGroupIngress
122
123**AWS.Redshift**: authorizeClusterSecurityGroupIngress, authorizeSnapshotAccess,
124copyClusterSnapshot, createCluster, createClusterParameterGroup,
125createClusterSecurityGroup, createClusterSnapshot, createClusterSubnetGroup,
126createEventSubscription, createHsmClientCertificate, createHsmConfiguration,
127deleteCluster, deleteClusterSnapshot, describeDefaultClusterParameters,
128disableSnapshotCopy, enableSnapshotCopy, modifyCluster,
129modifyClusterSubnetGroup, modifyEventSubscription,
130modifySnapshotCopyRetentionPeriod, purchaseReservedNodeOffering, rebootCluster,
131restoreFromClusterSnapshot, revokeClusterSecurityGroupIngress,
132revokeSnapshotAccess, rotateEncryptionKey
133
134## 4. Dropped `.Client` and `.client` Properties
135
136The `.Client` and `.client` properties have been removed from Service objects.
137If you are using the `.Client` property on a Service class or a `.client`
138property on an instance of the service, remove these properties from your code.
139
140Upgrading example:
141
142The following 1.x code:
143
144```
145var sts = new AWS.STS.Client();
146// or
147var sts = new AWS.STS();
148
149sts.client.operation(...);
150```
151
152Should be changed to the following:
153
154```
155var sts = new AWS.STS();
156sts.operation(...)
157```