@@ -9,6 +9,16 @@ const RoleCredentials = require('./credentials/RoleCredentials');
99const { getAccountCredentials } = require ( './credentials/AccountCredentials' ) ;
1010const { http : HttpAgent } = require ( 'httpagent' ) ;
1111const { lifecycleListing : { NON_CURRENT_TYPE , CURRENT_TYPE , ORPHAN_DM_TYPE } } = require ( './constants' ) ;
12+ const {
13+ CloudserverClient,
14+ CloudserverClientConfig,
15+ GetBucketIndexesCommand,
16+ PutBucketIndexesCommand,
17+ DeleteBucketIndexesCommand,
18+ ListLifecycleCurrentsCommand,
19+ ListLifecycleNonCurrentsCommand,
20+ ListLifecycleOrphansCommand
21+ } = require ( './clients/smithy/build/smithy/source/typescript-codegen' ) ;
1222
1323class BackbeatMetadataProxy extends BackbeatTask {
1424 constructor ( s3Endpoint , s3Auth , sourceHTTPAgent ) {
@@ -229,37 +239,43 @@ class BackbeatMetadataProxy extends BackbeatTask {
229239
230240 listLifecycle ( listType , params , log , cb ) {
231241 if ( listType === CURRENT_TYPE ) {
232- return this . backbeatSource . listLifecycleCurrents ( params , ( err , data ) => {
233- if ( err ) {
242+ const command = new ListLifecycleCurrentsCommand ( params ) ;
243+ return this . cloudserverSourceClient . send ( command )
244+ . then ( data => {
245+ return cb ( null , data . Contents , data . IsTruncated , {
246+ marker : data . NextMarker ,
247+ } ) ;
248+ } )
249+ . catch ( err => {
234250 return cb ( err ) ;
235- }
236- return cb ( null , data . Contents , data . IsTruncated , {
237- marker : data . NextMarker ,
238251 } ) ;
239- } ) ;
240252 }
241253
242254 if ( listType === NON_CURRENT_TYPE ) {
243- return this . backbeatSource . listLifecycleNonCurrents ( params , ( err , data ) => {
244- if ( err ) {
255+ const command = new ListLifecycleNonCurrentsCommand ( params ) ;
256+ return this . cloudserverSourceClient . send ( command )
257+ . then ( data => {
258+ return cb ( null , data . Contents , data . IsTruncated , {
259+ keyMarker : data . NextKeyMarker ,
260+ versionIdMarker : data . NextVersionIdMarker ,
261+ } ) ;
262+ } )
263+ . catch ( err => {
245264 return cb ( err ) ;
246- }
247- return cb ( null , data . Contents , data . IsTruncated , {
248- keyMarker : data . NextKeyMarker ,
249- versionIdMarker : data . NextVersionIdMarker ,
250265 } ) ;
251- } ) ;
252266 }
253267
254268 if ( listType === ORPHAN_DM_TYPE ) {
255- return this . backbeatSource . listLifecycleOrphans ( params , ( err , data ) => {
256- if ( err ) {
269+ const command = new ListLifecycleOrphansCommand ( params ) ;
270+ return this . cloudserverSourceClient . send ( command )
271+ . then ( data => {
272+ return cb ( null , data . Contents , data . IsTruncated , {
273+ marker : data . NextMarker ,
274+ } ) ;
275+ } )
276+ . catch ( err => {
257277 return cb ( err ) ;
258- }
259- return cb ( null , data . Contents , data . IsTruncated , {
260- marker : data . NextMarker ,
261278 } ) ;
262- } ) ;
263279 }
264280
265281 log . error ( 'invalid listType' , {
@@ -272,36 +288,47 @@ class BackbeatMetadataProxy extends BackbeatTask {
272288 }
273289
274290 getBucketIndexes ( bucket , log , cb ) {
275- this . backbeatSource . getBucketIndexes ( { Bucket : bucket } , ( err , res ) => {
276- if ( err ) {
277- return cb ( err ) ;
278- }
279- return cb ( null , res . Indexes ) ;
291+ const command = new GetBucketIndexesCommand ( {
292+ Bucket : bucket ,
280293 } ) ;
294+
295+ return this . cloudserverSourceClient . send ( command )
296+ . then ( res => {
297+ return cb ( null , res . Indexes ) ;
298+ } )
299+ . catch ( err => {
300+ return cb ( err ) ;
301+ } ) ;
281302 }
282303
283304 putBucketIndexes ( bucket , indexes , log , cb ) {
284- this . backbeatSource . putBucketIndexes ( {
305+ const command = new PutBucketIndexesCommand ( {
285306 Bucket : bucket ,
286307 Body : JSON . stringify ( indexes ) ,
287- } , err => {
288- if ( err ) {
289- return cb ( err ) ;
290- }
291- return cb ( null ) ;
292308 } ) ;
309+
310+ return this . cloudserverSourceClient . send ( command )
311+ . then ( ( ) => {
312+ return cb ( null ) ;
313+ } )
314+ . catch ( err => {
315+ return cb ( err ) ;
316+ } ) ;
293317 }
294318
295319 deleteBucketIndexes ( bucket , indexes , log , cb ) {
296- this . backbeatSource . deleteBucketIndexes ( {
320+ const command = new DeleteBucketIndexesCommand ( {
297321 Bucket : bucket ,
298322 Body : JSON . stringify ( indexes ) ,
299- } , err => {
300- if ( err ) {
301- return cb ( err ) ;
302- }
303- return cb ( null ) ;
304323 } ) ;
324+
325+ return this . cloudserverSourceClient . send ( command )
326+ . then ( ( ) => {
327+ return cb ( null ) ;
328+ } )
329+ . catch ( err => {
330+ return cb ( err ) ;
331+ } ) ;
305332 }
306333
307334
0 commit comments