@@ -139,7 +139,7 @@ private StandardDestinationDefinition getStandardDestinationDefinition(final Str
139
139
return result .get (0 ).getConfig ();
140
140
}
141
141
142
- private SourceConnection getSourceConnection (String configId ) throws IOException , ConfigNotFoundException {
142
+ private SourceConnection getSourceConnection (final String configId ) throws IOException , ConfigNotFoundException {
143
143
final List <ConfigWithMetadata <SourceConnection >> result = listSourceConnectionWithMetadata (Optional .of (UUID .fromString (configId )));
144
144
validate (configId , result , ConfigSchema .SOURCE_CONNECTION );
145
145
return result .get (0 ).getConfig ();
@@ -188,7 +188,7 @@ private List<UUID> connectionOperationIds(final UUID connectionId) throws IOExce
188
188
.fetch ());
189
189
190
190
final List <UUID > ids = new ArrayList <>();
191
- for (Record record : result ) {
191
+ for (final Record record : result ) {
192
192
ids .add (record .get (CONNECTION_OPERATION .OPERATION_ID ));
193
193
}
194
194
@@ -204,13 +204,50 @@ private <T> void validate(final String configId, final List<ConfigWithMetadata<T
204
204
}
205
205
}
206
206
207
+ private <T > ConfigWithMetadata <T > validateAndReturn (final String configId ,
208
+ final List <ConfigWithMetadata <T >> result ,
209
+ final AirbyteConfig airbyteConfig )
210
+ throws ConfigNotFoundException {
211
+ validate (configId , result , airbyteConfig );
212
+ return result .get (0 );
213
+ }
214
+
207
215
@ Override
208
216
public <T > List <T > listConfigs (final AirbyteConfig configType , final Class <T > clazz ) throws JsonValidationException , IOException {
209
217
final List <T > config = new ArrayList <>();
210
218
listConfigsWithMetadata (configType , clazz ).forEach (c -> config .add (c .getConfig ()));
211
219
return config ;
212
220
}
213
221
222
+ @ Override
223
+ public <T > ConfigWithMetadata <T > getConfigWithMetadata (final AirbyteConfig configType , final String configId , final Class <T > clazz )
224
+ throws ConfigNotFoundException , JsonValidationException , IOException {
225
+ final Optional <UUID > configIdOpt = Optional .of (UUID .fromString (configId ));
226
+ if (configType == ConfigSchema .STANDARD_WORKSPACE ) {
227
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardWorkspaceWithMetadata (configIdOpt ), configType );
228
+ } else if (configType == ConfigSchema .STANDARD_SOURCE_DEFINITION ) {
229
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardSourceDefinitionWithMetadata (configIdOpt ), configType );
230
+ } else if (configType == ConfigSchema .STANDARD_DESTINATION_DEFINITION ) {
231
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardDestinationDefinitionWithMetadata (configIdOpt ), configType );
232
+ } else if (configType == ConfigSchema .SOURCE_CONNECTION ) {
233
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listSourceConnectionWithMetadata (configIdOpt ), configType );
234
+ } else if (configType == ConfigSchema .DESTINATION_CONNECTION ) {
235
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listDestinationConnectionWithMetadata (configIdOpt ), configType );
236
+ } else if (configType == ConfigSchema .SOURCE_OAUTH_PARAM ) {
237
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listSourceOauthParamWithMetadata (configIdOpt ), configType );
238
+ } else if (configType == ConfigSchema .DESTINATION_OAUTH_PARAM ) {
239
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listDestinationOauthParamWithMetadata (configIdOpt ), configType );
240
+ } else if (configType == ConfigSchema .STANDARD_SYNC_OPERATION ) {
241
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardSyncOperationWithMetadata (configIdOpt ), configType );
242
+ } else if (configType == ConfigSchema .STANDARD_SYNC ) {
243
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardSyncWithMetadata (configIdOpt ), configType );
244
+ } else if (configType == ConfigSchema .STANDARD_SYNC_STATE ) {
245
+ return (ConfigWithMetadata <T >) validateAndReturn (configId , listStandardSyncStateWithMetadata (configIdOpt ), configType );
246
+ } else {
247
+ throw new IllegalArgumentException ("Unknown Config Type " + configType );
248
+ }
249
+ }
250
+
214
251
@ Override
215
252
public <T > List <ConfigWithMetadata <T >> listConfigsWithMetadata (final AirbyteConfig configType , final Class <T > clazz ) throws IOException {
216
253
final List <ConfigWithMetadata <T >> configWithMetadata = new ArrayList <>();
@@ -258,7 +295,7 @@ private List<ConfigWithMetadata<StandardWorkspace>> listStandardWorkspaceWithMet
258
295
for (final Record record : result ) {
259
296
final List <Notification > notificationList = new ArrayList <>();
260
297
final List fetchedNotifications = Jsons .deserialize (record .get (WORKSPACE .NOTIFICATIONS ).data (), List .class );
261
- for (Object notification : fetchedNotifications ) {
298
+ for (final Object notification : fetchedNotifications ) {
262
299
notificationList .add (Jsons .convertValue (notification , Notification .class ));
263
300
}
264
301
final StandardWorkspace workspace = buildStandardWorkspace (record , notificationList );
0 commit comments