@@ -10,14 +10,14 @@ import {
1010 TerminateSessionCommand ,
1111 TerminateSessionResponse ,
1212 StartSessionCommandOutput ,
13- DescribeInstanceInformationCommand ,
1413 DescribeInstanceInformationCommandInput ,
1514 InstanceInformation ,
1615 SendCommandCommand ,
1716 SendCommandCommandOutput ,
1817 waitUntilCommandExecuted ,
1918 SessionState ,
20- DescribeSessionsCommand ,
19+ paginateDescribeInstanceInformation ,
20+ paginateDescribeSessions ,
2121} from '@aws-sdk/client-ssm'
2222import { WaiterState } from '@smithy/util-waiter'
2323import { ToolkitError } from '../errors'
@@ -52,20 +52,15 @@ export class SsmClient extends ClientWrapper<SSMClient> {
5252 }
5353
5454 public async describeInstance ( target : string ) : Promise < InstanceInformation > {
55- const response = this . makePaginatedRequest (
56- DescribeInstanceInformationCommand ,
57- {
58- InstanceInformationFilterList : [
59- {
60- key : 'InstanceIds' ,
61- valueSet : [ target ] ,
62- } ,
63- ] ,
64- } as DescribeInstanceInformationCommandInput ,
65- 'InstanceIds'
66- )
67- const resolvedResponse = await response . flatten ( ) . flatten ( ) . promise ( )
68- return resolvedResponse [ 0 ] !
55+ return (
56+ await this . makePaginatedRequest (
57+ paginateDescribeInstanceInformation ,
58+ {
59+ InstanceInformationFilterList : [ { key : 'InstanceIds' , valueSet : [ target ] } ] ,
60+ } satisfies DescribeInstanceInformationCommandInput ,
61+ ( page ) => page . InstanceInformationList
62+ )
63+ ) [ 0 ] !
6964 }
7065
7166 public async getTargetPlatformName ( target : string ) : Promise < string > {
@@ -115,6 +110,6 @@ export class SsmClient extends ClientWrapper<SSMClient> {
115110 }
116111
117112 public async describeSessions ( state : SessionState ) {
118- return await this . makePaginatedRequest ( DescribeSessionsCommand , { State : state } , 'Sessions' ) . promise ( )
113+ return await this . makePaginatedRequest ( paginateDescribeSessions , { State : state } , ( page ) => page . Sessions )
119114 }
120115}
0 commit comments