3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
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'
7
36
import globals from '../extensionGlobals'
8
37
9
38
import { ClassToInterfaceType } from '../utilities/tsUtils'
@@ -12,23 +41,21 @@ export type SsmDocumentClient = ClassToInterfaceType<DefaultSsmDocumentClient>
12
41
export class DefaultSsmDocumentClient {
13
42
public constructor ( public readonly regionCode : string ) { }
14
43
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 ( )
17
46
18
- const request : SSM . Types . DeleteDocumentRequest = {
47
+ const request : DeleteDocumentRequest = {
19
48
Name : documentName ,
20
49
}
21
50
22
- return await client . deleteDocument ( request ) . promise ( )
51
+ return await client . send ( new DeleteDocumentCommand ( request ) )
23
52
}
24
53
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 ( )
29
56
30
57
do {
31
- const response : SSM . Types . ListDocumentsResult = await client . listDocuments ( request ) . promise ( )
58
+ const response : ListDocumentsResult = await client . send ( new ListDocumentsCommand ( request ) )
32
59
33
60
if ( response . DocumentIdentifiers ) {
34
61
yield * response . DocumentIdentifiers
@@ -38,15 +65,15 @@ export class DefaultSsmDocumentClient {
38
65
} while ( request . NextToken )
39
66
}
40
67
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 ( )
43
70
44
- const request : SSM . Types . ListDocumentVersionsRequest = {
71
+ const request : ListDocumentVersionsRequest = {
45
72
Name : documentName ,
46
73
}
47
74
48
75
do {
49
- const response : SSM . Types . ListDocumentVersionsResult = await client . listDocumentVersions ( request ) . promise ( )
76
+ const response : ListDocumentVersionsResult = await client . send ( new ListDocumentVersionsCommand ( request ) )
50
77
51
78
if ( response . DocumentVersions ) {
52
79
yield * response . DocumentVersions
@@ -56,60 +83,63 @@ export class DefaultSsmDocumentClient {
56
83
} while ( request . NextToken )
57
84
}
58
85
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 ( )
61
88
62
- const request : SSM . Types . DescribeDocumentRequest = {
89
+ const request : DescribeDocumentRequest = {
63
90
Name : documentName ,
64
91
DocumentVersion : documentVersion ,
65
92
}
66
93
67
- return await client . describeDocument ( request ) . promise ( )
94
+ return await client . send ( new DescribeDocumentCommand ( request ) )
68
95
}
69
96
70
97
public async getDocument (
71
98
documentName : string ,
72
99
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 ( )
76
103
77
- const request : SSM . Types . GetDocumentRequest = {
104
+ const request : GetDocumentRequest = {
78
105
Name : documentName ,
79
106
DocumentVersion : documentVersion ,
80
107
DocumentFormat : documentFormat ,
81
108
}
82
109
83
- return await client . getDocument ( request ) . promise ( )
110
+ return await client . send ( new GetDocumentCommand ( request ) )
84
111
}
85
112
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 ( )
88
115
89
- return await client . createDocument ( request ) . promise ( )
116
+ return await client . send ( new CreateDocumentCommand ( request ) )
90
117
}
91
118
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 ( )
94
121
95
- return await client . updateDocument ( request ) . promise ( )
122
+ return await client . send ( new UpdateDocumentCommand ( request ) )
96
123
}
97
124
98
125
public async updateDocumentVersion (
99
126
documentName : string ,
100
127
documentVersion : string
101
- ) : Promise < SSM . Types . UpdateDocumentDefaultVersionResult > {
102
- const client = await this . createSdkClient ( )
128
+ ) : Promise < UpdateDocumentDefaultVersionResult > {
129
+ const client = this . createSdkClient ( )
103
130
104
- const request : SSM . Types . UpdateDocumentDefaultVersionRequest = {
131
+ const request : UpdateDocumentDefaultVersionRequest = {
105
132
Name : documentName ,
106
133
DocumentVersion : documentVersion ,
107
134
}
108
135
109
- return await client . updateDocumentDefaultVersion ( request ) . promise ( )
136
+ return await client . send ( new UpdateDocumentDefaultVersionCommand ( request ) )
110
137
}
111
138
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
+ } )
114
144
}
115
145
}
0 commit comments