|
| 1 | +package org.radarbase.connect.rest.oura; |
| 2 | + |
| 3 | +/* |
| 4 | + * Copyright 2018 The Hyve |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + */ |
| 19 | + |
| 20 | +import java.util.Collections; |
| 21 | +import java.util.HashMap; |
| 22 | +import java.util.List; |
| 23 | +import java.util.Map; |
| 24 | +import org.apache.kafka.connect.connector.Task; |
| 25 | +import org.apache.kafka.connect.source.SourceConnector; |
| 26 | +import org.radarbase.connect.rest.util.VersionUtil; |
| 27 | + |
| 28 | +@SuppressWarnings("unused") |
| 29 | +public abstract class AbstractRestSourceConnector extends SourceConnector { |
| 30 | + protected OuraRestSourceConnectorConfig config; |
| 31 | + |
| 32 | + @Override |
| 33 | + public String version() { |
| 34 | + return VersionUtil.getVersion(); |
| 35 | + } |
| 36 | + |
| 37 | + @Override |
| 38 | + public Class<? extends Task> taskClass() { |
| 39 | + return OuraSourceTask.class; |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public List<Map<String, String>> taskConfigs(int maxTasks) { |
| 44 | + return Collections.nCopies(maxTasks, new HashMap<>(config.originalsStrings())); |
| 45 | + } |
| 46 | + |
| 47 | + @Override |
| 48 | + public void start(Map<String, String> props) { |
| 49 | + config = getConfig(props); |
| 50 | + } |
| 51 | + |
| 52 | + public abstract OuraRestSourceConnectorConfig getConfig(Map<String, String> conf); |
| 53 | + |
| 54 | + @Override |
| 55 | + public void stop() { |
| 56 | + } |
| 57 | +} |
0 commit comments