3
3
* SPDX-License-Identifier: Apache-2.0
4
4
*/
5
5
6
- import { Schemas } from 'aws-sdk'
6
+ import {
7
+ DescribeCodeBindingCommand ,
8
+ DescribeCodeBindingResponse ,
9
+ DescribeSchemaCommand ,
10
+ DescribeSchemaResponse ,
11
+ GetCodeBindingSourceCommand ,
12
+ GetCodeBindingSourceResponse ,
13
+ ListRegistriesCommand ,
14
+ ListRegistriesRequest ,
15
+ ListRegistriesResponse ,
16
+ ListSchemasCommand ,
17
+ ListSchemasRequest ,
18
+ ListSchemasResponse ,
19
+ ListSchemaVersionsCommand ,
20
+ ListSchemaVersionsRequest ,
21
+ ListSchemaVersionsResponse ,
22
+ PutCodeBindingCommand ,
23
+ PutCodeBindingResponse ,
24
+ RegistrySummary ,
25
+ SchemasClient ,
26
+ SchemaSummary ,
27
+ SchemaVersionSummary ,
28
+ SearchSchemasCommand ,
29
+ SearchSchemasRequest ,
30
+ SearchSchemasResponse ,
31
+ SearchSchemaSummary ,
32
+ } from '@aws-sdk/client-schemas'
7
33
import globals from '../extensionGlobals'
8
34
9
35
import { ClassToInterfaceType } from '../utilities/tsUtils'
@@ -12,13 +38,13 @@ export type SchemaClient = ClassToInterfaceType<DefaultSchemaClient>
12
38
export class DefaultSchemaClient {
13
39
public constructor ( public readonly regionCode : string ) { }
14
40
15
- public async * listRegistries ( ) : AsyncIterableIterator < Schemas . RegistrySummary > {
16
- const client = await this . createSdkClient ( )
41
+ public async * listRegistries ( ) : AsyncIterableIterator < RegistrySummary > {
42
+ const client = this . createSdkClient ( )
17
43
18
- const request : Schemas . ListRegistriesRequest = { }
44
+ const request : ListRegistriesRequest = { }
19
45
20
46
do {
21
- const response : Schemas . ListRegistriesResponse = await client . listRegistries ( request ) . promise ( )
47
+ const response : ListRegistriesResponse = await client . send ( new ListRegistriesCommand ( request ) )
22
48
23
49
if ( response . Registries ) {
24
50
yield * response . Registries
@@ -28,15 +54,15 @@ export class DefaultSchemaClient {
28
54
} while ( request . NextToken )
29
55
}
30
56
31
- public async * listSchemas ( registryName : string ) : AsyncIterableIterator < Schemas . SchemaSummary > {
32
- const client = await this . createSdkClient ( )
57
+ public async * listSchemas ( registryName : string ) : AsyncIterableIterator < SchemaSummary > {
58
+ const client = this . createSdkClient ( )
33
59
34
- const request : Schemas . ListSchemasRequest = {
60
+ const request : ListSchemasRequest = {
35
61
RegistryName : registryName ,
36
62
}
37
63
38
64
do {
39
- const response : Schemas . ListSchemasResponse = await client . listSchemas ( request ) . promise ( )
65
+ const response : ListSchemasResponse = await client . send ( new ListSchemasCommand ( request ) )
40
66
41
67
if ( response . Schemas ) {
42
68
yield * response . Schemas
@@ -50,31 +76,31 @@ export class DefaultSchemaClient {
50
76
registryName : string ,
51
77
schemaName : string ,
52
78
schemaVersion ?: string
53
- ) : Promise < Schemas . DescribeSchemaResponse > {
54
- const client = await this . createSdkClient ( )
79
+ ) : Promise < DescribeSchemaResponse > {
80
+ const client = this . createSdkClient ( )
55
81
56
- return await client
57
- . describeSchema ( {
82
+ return await client . send (
83
+ new DescribeSchemaCommand ( {
58
84
RegistryName : registryName ,
59
85
SchemaName : schemaName ,
60
86
SchemaVersion : schemaVersion ,
61
87
} )
62
- . promise ( )
88
+ )
63
89
}
64
90
65
91
public async * listSchemaVersions (
66
92
registryName : string ,
67
93
schemaName : string
68
- ) : AsyncIterableIterator < Schemas . SchemaVersionSummary > {
69
- const client = await this . createSdkClient ( )
94
+ ) : AsyncIterableIterator < SchemaVersionSummary > {
95
+ const client = this . createSdkClient ( )
70
96
71
- const request : Schemas . ListSchemaVersionsRequest = {
97
+ const request : ListSchemaVersionsRequest = {
72
98
RegistryName : registryName ,
73
99
SchemaName : schemaName ,
74
100
}
75
101
76
102
do {
77
- const response : Schemas . ListSchemaVersionsResponse = await client . listSchemaVersions ( request ) . promise ( )
103
+ const response : ListSchemaVersionsResponse = await client . send ( new ListSchemaVersionsCommand ( request ) )
78
104
79
105
if ( response . SchemaVersions ) {
80
106
yield * response . SchemaVersions
@@ -84,19 +110,16 @@ export class DefaultSchemaClient {
84
110
} while ( request . NextToken )
85
111
}
86
112
87
- public async * searchSchemas (
88
- keywords : string ,
89
- registryName : string
90
- ) : AsyncIterableIterator < Schemas . SearchSchemaSummary > {
91
- const client = await this . createSdkClient ( )
113
+ public async * searchSchemas ( keywords : string , registryName : string ) : AsyncIterableIterator < SearchSchemaSummary > {
114
+ const client = this . createSdkClient ( )
92
115
93
- const request : Schemas . SearchSchemasRequest = {
116
+ const request : SearchSchemasRequest = {
94
117
Keywords : keywords ,
95
118
RegistryName : registryName ,
96
119
}
97
120
98
121
do {
99
- const response : Schemas . SearchSchemasResponse = await client . searchSchemas ( request ) . promise ( )
122
+ const response : SearchSchemasResponse = await client . send ( new SearchSchemasCommand ( request ) )
100
123
101
124
if ( response . Schemas ) {
102
125
yield * response . Schemas
@@ -111,55 +134,58 @@ export class DefaultSchemaClient {
111
134
registryName : string ,
112
135
schemaName : string ,
113
136
schemaVersion : string
114
- ) : Promise < Schemas . GetCodeBindingSourceResponse > {
115
- const client = await this . createSdkClient ( )
137
+ ) : Promise < GetCodeBindingSourceResponse > {
138
+ const client = this . createSdkClient ( )
116
139
117
- return await client
118
- . getCodeBindingSource ( {
140
+ return await client . send (
141
+ new GetCodeBindingSourceCommand ( {
119
142
Language : language ,
120
143
RegistryName : registryName ,
121
144
SchemaName : schemaName ,
122
145
SchemaVersion : schemaVersion ,
123
146
} )
124
- . promise ( )
147
+ )
125
148
}
126
149
127
150
public async putCodeBinding (
128
151
language : string ,
129
152
registryName : string ,
130
153
schemaName : string ,
131
154
schemaVersion : string
132
- ) : Promise < Schemas . PutCodeBindingResponse > {
133
- const client = await this . createSdkClient ( )
155
+ ) : Promise < PutCodeBindingResponse > {
156
+ const client = this . createSdkClient ( )
134
157
135
- return await client
136
- . putCodeBinding ( {
158
+ return await client . send (
159
+ new PutCodeBindingCommand ( {
137
160
Language : language ,
138
161
RegistryName : registryName ,
139
162
SchemaName : schemaName ,
140
163
SchemaVersion : schemaVersion ,
141
164
} )
142
- . promise ( )
165
+ )
143
166
}
144
167
public async describeCodeBinding (
145
168
language : string ,
146
169
registryName : string ,
147
170
schemaName : string ,
148
171
schemaVersion : string
149
- ) : Promise < Schemas . DescribeCodeBindingResponse > {
150
- const client = await this . createSdkClient ( )
172
+ ) : Promise < DescribeCodeBindingResponse > {
173
+ const client = this . createSdkClient ( )
151
174
152
- return await client
153
- . describeCodeBinding ( {
175
+ return await client . send (
176
+ new DescribeCodeBindingCommand ( {
154
177
Language : language ,
155
178
RegistryName : registryName ,
156
179
SchemaName : schemaName ,
157
180
SchemaVersion : schemaVersion ,
158
181
} )
159
- . promise ( )
182
+ )
160
183
}
161
184
162
- private async createSdkClient ( ) : Promise < Schemas > {
163
- return await globals . sdkClientBuilder . createAwsService ( Schemas , undefined , this . regionCode )
185
+ private createSdkClient ( ) : SchemasClient {
186
+ return globals . sdkClientBuilderV3 . createAwsService ( {
187
+ serviceClient : SchemasClient ,
188
+ clientOptions : { region : this . regionCode } ,
189
+ } )
164
190
}
165
191
}
0 commit comments