33 * SPDX-License-Identifier: Apache-2.0
44 */
55
6- import { SSM } from 'aws-sdk'
6+ import {
7+ CreateDocumentCommand ,
8+ CreateDocumentRequest ,
9+ CreateDocumentResult ,
10+ DeleteDocumentCommand ,
11+ DeleteDocumentRequest ,
12+ DeleteDocumentResult ,
13+ DescribeDocumentCommand ,
14+ DescribeDocumentRequest ,
15+ DescribeDocumentResult ,
16+ DocumentFormat ,
17+ DocumentIdentifier ,
18+ DocumentVersionInfo ,
19+ GetDocumentCommand ,
20+ GetDocumentRequest ,
21+ GetDocumentResult ,
22+ ListDocumentsCommand ,
23+ ListDocumentsRequest ,
24+ ListDocumentsResult ,
25+ ListDocumentVersionsCommand ,
26+ ListDocumentVersionsRequest ,
27+ ListDocumentVersionsResult ,
28+ SSMClient ,
29+ UpdateDocumentCommand ,
30+ UpdateDocumentDefaultVersionCommand ,
31+ UpdateDocumentDefaultVersionRequest ,
32+ UpdateDocumentDefaultVersionResult ,
33+ UpdateDocumentRequest ,
34+ UpdateDocumentResult ,
35+ } from '@aws-sdk/client-ssm'
736import globals from '../extensionGlobals'
837
938import { ClassToInterfaceType } from '../utilities/tsUtils'
@@ -12,23 +41,21 @@ export type SsmDocumentClient = ClassToInterfaceType<DefaultSsmDocumentClient>
1241export class DefaultSsmDocumentClient {
1342 public constructor ( public readonly regionCode : string ) { }
1443
15- public async deleteDocument ( documentName : string ) : Promise < SSM . Types . DeleteDocumentResult > {
16- const client = await this . createSdkClient ( )
44+ public async deleteDocument ( documentName : string ) : Promise < DeleteDocumentResult > {
45+ const client = this . createSdkClient ( )
1746
18- const request : SSM . Types . DeleteDocumentRequest = {
47+ const request : DeleteDocumentRequest = {
1948 Name : documentName ,
2049 }
2150
22- return await client . deleteDocument ( request ) . promise ( )
51+ return await client . send ( new DeleteDocumentCommand ( request ) )
2352 }
2453
25- public async * listDocuments (
26- request : SSM . Types . ListDocumentsRequest = { }
27- ) : AsyncIterableIterator < SSM . DocumentIdentifier > {
28- const client = await this . createSdkClient ( )
54+ public async * listDocuments ( request : ListDocumentsRequest = { } ) : AsyncIterableIterator < DocumentIdentifier > {
55+ const client = this . createSdkClient ( )
2956
3057 do {
31- const response : SSM . Types . ListDocumentsResult = await client . listDocuments ( request ) . promise ( )
58+ const response : ListDocumentsResult = await client . send ( new ListDocumentsCommand ( request ) )
3259
3360 if ( response . DocumentIdentifiers ) {
3461 yield * response . DocumentIdentifiers
@@ -38,15 +65,15 @@ export class DefaultSsmDocumentClient {
3865 } while ( request . NextToken )
3966 }
4067
41- public async * listDocumentVersions ( documentName : string ) : AsyncIterableIterator < SSM . Types . DocumentVersionInfo > {
42- const client = await this . createSdkClient ( )
68+ public async * listDocumentVersions ( documentName : string ) : AsyncIterableIterator < DocumentVersionInfo > {
69+ const client = this . createSdkClient ( )
4370
44- const request : SSM . Types . ListDocumentVersionsRequest = {
71+ const request : ListDocumentVersionsRequest = {
4572 Name : documentName ,
4673 }
4774
4875 do {
49- const response : SSM . Types . ListDocumentVersionsResult = await client . listDocumentVersions ( request ) . promise ( )
76+ const response : ListDocumentVersionsResult = await client . send ( new ListDocumentVersionsCommand ( request ) )
5077
5178 if ( response . DocumentVersions ) {
5279 yield * response . DocumentVersions
@@ -56,60 +83,63 @@ export class DefaultSsmDocumentClient {
5683 } while ( request . NextToken )
5784 }
5885
59- public async describeDocument ( documentName : string , documentVersion ?: string ) : Promise < SSM . DescribeDocumentResult > {
60- const client = await this . createSdkClient ( )
86+ public async describeDocument ( documentName : string , documentVersion ?: string ) : Promise < DescribeDocumentResult > {
87+ const client = this . createSdkClient ( )
6188
62- const request : SSM . Types . DescribeDocumentRequest = {
89+ const request : DescribeDocumentRequest = {
6390 Name : documentName ,
6491 DocumentVersion : documentVersion ,
6592 }
6693
67- return await client . describeDocument ( request ) . promise ( )
94+ return await client . send ( new DescribeDocumentCommand ( request ) )
6895 }
6996
7097 public async getDocument (
7198 documentName : string ,
7299 documentVersion ?: string ,
73- documentFormat ?: string
74- ) : Promise < SSM . Types . GetDocumentResult > {
75- const client = await this . createSdkClient ( )
100+ documentFormat ?: DocumentFormat
101+ ) : Promise < GetDocumentResult > {
102+ const client = this . createSdkClient ( )
76103
77- const request : SSM . Types . GetDocumentRequest = {
104+ const request : GetDocumentRequest = {
78105 Name : documentName ,
79106 DocumentVersion : documentVersion ,
80107 DocumentFormat : documentFormat ,
81108 }
82109
83- return await client . getDocument ( request ) . promise ( )
110+ return await client . send ( new GetDocumentCommand ( request ) )
84111 }
85112
86- public async createDocument ( request : SSM . Types . CreateDocumentRequest ) : Promise < SSM . Types . CreateDocumentResult > {
87- const client = await this . createSdkClient ( )
113+ public async createDocument ( request : CreateDocumentRequest ) : Promise < CreateDocumentResult > {
114+ const client = this . createSdkClient ( )
88115
89- return await client . createDocument ( request ) . promise ( )
116+ return await client . send ( new CreateDocumentCommand ( request ) )
90117 }
91118
92- public async updateDocument ( request : SSM . Types . UpdateDocumentRequest ) : Promise < SSM . Types . UpdateDocumentResult > {
93- const client = await this . createSdkClient ( )
119+ public async updateDocument ( request : UpdateDocumentRequest ) : Promise < UpdateDocumentResult > {
120+ const client = this . createSdkClient ( )
94121
95- return await client . updateDocument ( request ) . promise ( )
122+ return await client . send ( new UpdateDocumentCommand ( request ) )
96123 }
97124
98125 public async updateDocumentVersion (
99126 documentName : string ,
100127 documentVersion : string
101- ) : Promise < SSM . Types . UpdateDocumentDefaultVersionResult > {
102- const client = await this . createSdkClient ( )
128+ ) : Promise < UpdateDocumentDefaultVersionResult > {
129+ const client = this . createSdkClient ( )
103130
104- const request : SSM . Types . UpdateDocumentDefaultVersionRequest = {
131+ const request : UpdateDocumentDefaultVersionRequest = {
105132 Name : documentName ,
106133 DocumentVersion : documentVersion ,
107134 }
108135
109- return await client . updateDocumentDefaultVersion ( request ) . promise ( )
136+ return await client . send ( new UpdateDocumentDefaultVersionCommand ( request ) )
110137 }
111138
112- private async createSdkClient ( ) : Promise < SSM > {
113- return await globals . sdkClientBuilder . createAwsService ( SSM , undefined , this . regionCode )
139+ private createSdkClient ( ) : SSMClient {
140+ return globals . sdkClientBuilderV3 . createAwsService ( {
141+ serviceClient : SSMClient ,
142+ clientOptions : { region : this . regionCode } ,
143+ } )
114144 }
115145}
0 commit comments