

AWS SDK for JavaScript v2 はサポート終了となりました。[AWS SDK for JavaScript v3](https://docs.aws.amazon.com//sdk-for-javascript/v3/developer-guide/) に移行することをお勧めします。その他の詳細、移行方法については、こちらの[発表内容](https://aws.amazon.com/blogs//developer/announcing-end-of-support-for-aws-sdk-for-javascript-v2/)を参照してください。

# SDK for JavaScript をバージョン 1 からアップグレード
<a name="upgrading-from-v1"></a>

以下の注意事項は、SDK for JavaScript をバージョン 1 からバージョン 2 にアップグレードするのに役立ちます。

## 入出力における Base64 およびタイムスタンプ型の自動変換
<a name="upgrading-from-v1-base64-timestamp-conversion"></a>

SDK は、base64 でエンコードされた値とタイムスタンプ値を、ユーザーに代わって自動的にエンコードおよびデコードするようになりました。この変更は、base64 またはタイムスタンプ値がリクエストにより送信されたか、もしくは base64 でエンコードされた値を許可するレスポンスで返されたすべてのオペレーションに影響します。

以前に base64 を変換したユーザーコードは不要になりました。base64 としてエンコードされた値は、サーバーのレスポンスからバッファオブジェクトとして返されるようになり、バッファ入力として渡すこともできます。たとえば、次のバージョン 1 の `SQS.sendMessage` パラメータがあります。

```
var params = {
   MessageBody: 'Some Message',
   MessageAttributes: {
      attrName: {
         DataType: 'Binary',
         BinaryValue: new Buffer('example text').toString('base64')
      }
   }
};
```

これは次のように書き直すことができます。

```
var params = {
   MessageBody: 'Some Message',
   MessageAttributes: {
      attrName: {
         DataType: 'Binary',
         BinaryValue: 'example text'
      }
   }
};
```

メッセージは以下のように読み取られます。

```
sqs.receiveMessage(params, function(err, data) {
  // buf is <Buffer 65 78 61 6d 70 6c 65 20 74 65 78 74>
  var buf = data.Messages[0].MessageAttributes.attrName.BinaryValue;
  console.log(buf.toString()); // "example text"
});
```

## response.data.RequestId を response.requestId に移動しました
<a name="upgrading-from-v1-response-requestid"></a>

SDK は、`response` プロパティ内ではなく、`response.data` オブジェクト上の一貫した場所にすべてのサービスのリクエスト ID を保存するようになりました。これにより、リクエスト ID をさまざまな方法で公開するサービス間での一貫性が向上します。これはまた、`response.data.RequestId` プロパティを `response.requestId` (コールバック関数内では`this.requestId`) に改名した重要な変更です。

コードで、以下のように変更します。

```
svc.operation(params, function (err, data) {
  console.log('Request ID:', data.RequestId);
});
```

項目の変更後:

```
svc.operation(params, function () {
  console.log('Request ID:', this.requestId);
});
```

## 公開されたラッパー要素
<a name="upgrading-from-v1-exposed-wrapper-elements"></a>

`AWS.ElastiCache`、`AWS.RDS`、または `AWS.Redshift` を使用している場合、一部のオペレーションでは、レスポンス内の最上位の出力プロパティを通じてレスポンスにアクセスする必要があります。

たとえば、以前、`RDS.describeEngineDefaultParameters` メソッドは以下を返していました。

```
{ Parameters: [ ... ] }
```

今では、以下を返すようになりました。

```
{ EngineDefaults: { Parameters: [ ... ] } }
```

次の表に、各サービスの影響を受けるオペレーションの一覧が示されています。


****  

| クライアントクラス | オペレーション | 
| --- | --- | 
| `AWS.ElastiCache` | `authorizeCacheSecurityGroupIngress` `createCacheCluster` `createCacheParameterGroup` `createCacheSecurityGroup` `createCacheSubnetGroup` `createReplicationGroup` `deleteCacheCluster` `deleteReplicationGroup` `describeEngineDefaultParameters` `modifyCacheCluster` `modifyCacheSubnetGroup` `modifyReplicationGroup` `purchaseReservedCacheNodesOffering` `rebootCacheCluster` `revokeCacheSecurityGroupIngress` | 
| `AWS.RDS` | `addSourceIdentifierToSubscription` `authorizeDBSecurityGroupIngress` `copyDBSnapshot` `createDBInstance` `createDBInstanceReadReplica` `createDBParameterGroup` `createDBSecurityGroup` `createDBSnapshot` `createDBSubnetGroup` `createEventSubscription` `createOptionGroup` `deleteDBInstance` `deleteDBSnapshot` `deleteEventSubscription` `describeEngineDefaultParameters` `modifyDBInstance` `modifyDBSubnetGroup` `modifyEventSubscription` `modifyOptionGroup` `promoteReadReplica` `purchaseReservedDBInstancesOffering` `rebootDBInstance` `removeSourceIdentifierFromSubscription` `restoreDBInstanceFromDBSnapshot` `restoreDBInstanceToPointInTime` `revokeDBSecurityGroupIngress` | 
| `AWS.Redshift` | `authorizeClusterSecurityGroupIngress` `authorizeSnapshotAccess` `copyClusterSnapshot` `createCluster` `createClusterParameterGroup` `createClusterSecurityGroup` `createClusterSnapshot` `createClusterSubnetGroup` `createEventSubscription` `createHsmClientCertificate` `createHsmConfiguration` `deleteCluster` `deleteClusterSnapshot` `describeDefaultClusterParameters` `disableSnapshotCopy` `enableSnapshotCopy` `modifyCluster` `modifyClusterSubnetGroup` `modifyEventSubscription` `modifySnapshotCopyRetentionPeriod` `purchaseReservedNodeOffering` `rebootCluster` `restoreFromClusterSnapshot` `revokeClusterSecurityGroupIngress` `revokeSnapshotAccess` `rotateEncryptionKey` | 

## 除外されたクライアントプロパティ
<a name="upgrading-from-v1-dropped-client-properties"></a>

`.Client` および `.client` プロパティはサービスオブジェクトから削除されました。サービスクラスで `.Client` プロパティを使用する場合、またはサービスオブジェクトインスタンスで `.client` プロパティを使用する場合は、これらのプロパティをコードから削除します。

以下のコードは、SDK for JavaScript のバージョン 1 で使用されます。

```
var sts = new AWS.STS.Client();
// or
var sts = new AWS.STS();

sts.client.operation(...);
```

次のコードに変更する必要があります。

```
var sts = new AWS.STS();
sts.operation(...)
```