Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Merge ConfigFetchers (airbytehq#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
michel-tricot authored Sep 8, 2020
1 parent aa87ede commit 1fb0963
Show file tree
Hide file tree
Showing 33 changed files with 962 additions and 1,639 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ <T> T getConfig(ConfigSchema configType,

<T> List<T> listConfigs(ConfigSchema configType,
Class<T> clazz)
throws JsonValidationException, IOException, ConfigNotFoundException;
throws ConfigNotFoundException, JsonValidationException, IOException;

<T> void writeConfig(ConfigSchema configType,
String configId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/*
* MIT License
*
* Copyright (c) 2020 Dataline
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package io.dataline.config.persistence;

import io.dataline.config.ConfigSchema;
import io.dataline.config.DestinationConnectionImplementation;
import io.dataline.config.DestinationConnectionSpecification;
import io.dataline.config.SourceConnectionImplementation;
import io.dataline.config.SourceConnectionSpecification;
import io.dataline.config.StandardDestination;
import io.dataline.config.StandardSource;
import io.dataline.config.StandardSync;
import io.dataline.config.StandardSyncSchedule;
import io.dataline.config.StandardWorkspace;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ConfigRepository {

private final static Logger LOGGER = LoggerFactory.getLogger(ConfigRepository.class);

private final ConfigPersistence persistence;

public ConfigRepository(ConfigPersistence persistence) {
this.persistence = persistence;
}

public StandardWorkspace getStandardWorkspace(final UUID workspaceId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.STANDARD_WORKSPACE,
workspaceId.toString(),
StandardWorkspace.class);
}

public void writeStandardWorkspace(final StandardWorkspace workspace)
throws JsonValidationException, IOException {
persistence.writeConfig(
ConfigSchema.STANDARD_WORKSPACE,
workspace.getWorkspaceId().toString(),
workspace);
}

public StandardSource getStandardSource(final UUID sourceId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.STANDARD_SOURCE, sourceId.toString(), StandardSource.class);
}

public List<StandardSource> listStandardSources()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(ConfigSchema.STANDARD_SOURCE, StandardSource.class);
}

public StandardDestination getStandardDestination(final UUID destinationId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.STANDARD_DESTINATION,
destinationId.toString(),
StandardDestination.class);
}

public List<StandardDestination> listStandardDestinations()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(ConfigSchema.STANDARD_DESTINATION, StandardDestination.class);
}

public SourceConnectionSpecification getSourceConnectionSpecification(final UUID sourceSpecificationId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.SOURCE_CONNECTION_SPECIFICATION,
sourceSpecificationId.toString(),
SourceConnectionSpecification.class);
}

public List<SourceConnectionSpecification> listSourceConnectionSpecifications()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(
ConfigSchema.SOURCE_CONNECTION_SPECIFICATION,
SourceConnectionSpecification.class);
}

public DestinationConnectionSpecification getDestinationConnectionSpecification(final UUID destinationSpecificationId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.DESTINATION_CONNECTION_SPECIFICATION,
destinationSpecificationId.toString(),
DestinationConnectionSpecification.class);
}

public List<DestinationConnectionSpecification> listDestinationConnectionSpecifications()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(
ConfigSchema.DESTINATION_CONNECTION_SPECIFICATION,
DestinationConnectionSpecification.class);
}

public SourceConnectionImplementation getSourceConnectionImplementation(final UUID sourceImplementationId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.SOURCE_CONNECTION_IMPLEMENTATION,
sourceImplementationId.toString(),
SourceConnectionImplementation.class);
}

public void writeSourceConnectionImplementation(final SourceConnectionImplementation sourceImplementation)
throws JsonValidationException, IOException {
persistence.writeConfig(
ConfigSchema.SOURCE_CONNECTION_IMPLEMENTATION,
sourceImplementation.getSourceImplementationId().toString(),
sourceImplementation);
}

public List<SourceConnectionImplementation> listSourceConnectionImplementations()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(
ConfigSchema.SOURCE_CONNECTION_IMPLEMENTATION,
SourceConnectionImplementation.class);
}

public DestinationConnectionImplementation getDestinationConnectionImplementation(final UUID destinationImplementationId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.DESTINATION_CONNECTION_IMPLEMENTATION,
destinationImplementationId.toString(),
DestinationConnectionImplementation.class);
}

public void writeDestinationConnectionImplementation(DestinationConnectionImplementation destinationConnectionImplementation)
throws JsonValidationException, IOException {
persistence.writeConfig(
ConfigSchema.DESTINATION_CONNECTION_IMPLEMENTATION,
destinationConnectionImplementation.getDestinationImplementationId().toString(),
destinationConnectionImplementation);
}

public List<DestinationConnectionImplementation> listDestinationConnectionImplementations()
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.listConfigs(
ConfigSchema.DESTINATION_CONNECTION_IMPLEMENTATION,
DestinationConnectionImplementation.class);
}

public StandardSync getStandardSync(final UUID connectionId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.STANDARD_SYNC,
connectionId.toString(),
StandardSync.class);
}

public void writeStandardSync(final StandardSync standardSync)
throws JsonValidationException, IOException {
persistence.writeConfig(
ConfigSchema.STANDARD_SYNC,
standardSync.getConnectionId().toString(),
standardSync);
}

public List<StandardSync> listStandardSyncs()
throws ConfigNotFoundException, IOException, JsonValidationException {
return persistence.listConfigs(ConfigSchema.STANDARD_SYNC, StandardSync.class);
}

public StandardSyncSchedule getStandardSyncSchedule(final UUID connectionId)
throws JsonValidationException, IOException, ConfigNotFoundException {
return persistence.getConfig(
ConfigSchema.STANDARD_SYNC_SCHEDULE,
connectionId.toString(),
StandardSyncSchedule.class);
}

public void writeStandardSchedule(final StandardSyncSchedule schedule)
throws JsonValidationException, IOException {
// todo (cgardens) - stored on sync id (there is no schedule id concept). this is non-intuitive.
persistence.writeConfig(
ConfigSchema.STANDARD_SYNC_SCHEDULE,
schedule.getConnectionId().toString(),
schedule);
}

}

This file was deleted.

Loading

0 comments on commit 1fb0963

Please sign in to comment.