forked from syndesisio/syndesis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extends the contract of `ConnectorGenerator` to provide a basic information about the new custom connector. Adds REST API for Custom connectors, first set of API endpoints deals with enumerating connector templates: - `GET /api/v1/custom/connectors` - lists all known connector templates - `GET /api/v1/custom/connectors/{id}` - fetches specific connector template - `POST /api/v1/custom/connectors/{id}/info` - receives a custom connector definition, combines it with the template and using a connector generator provides basic information about the connector (used for confirmation/summary step before creating a new custom connector) - `POST /api/v1/custom/connectors/{id}/validation` - validates the given custom connector definition - `POST /api/v1/custom/connectors/{id}` - creates a new custom connector Fixes syndesisio#434
- Loading branch information
Showing
14 changed files
with
529 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...enerator/src/main/java/io/syndesis/connector/generator/swagger/DefaultPropertyValues.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (C) 2016 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.syndesis.connector.generator.swagger; | ||
|
||
import java.util.Arrays; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import io.swagger.models.Swagger; | ||
|
||
enum DefaultPropertyValues { | ||
|
||
host { | ||
@Override | ||
protected Function<Swagger, String> propertyValueExtractor() { | ||
return Swagger::getHost; | ||
} | ||
}; | ||
|
||
private static final Set<String> KNOWN_PROPERTIES = Arrays.stream(values()).map(DefaultPropertyValues::name) | ||
.collect(Collectors.toSet()); | ||
|
||
protected abstract Function<Swagger, String> propertyValueExtractor(); | ||
|
||
static Optional<String> fetchValue(final String propertyName, final Swagger swagger) { | ||
if (!KNOWN_PROPERTIES.contains(propertyName)) { | ||
return Optional.empty(); | ||
} | ||
|
||
final DefaultPropertyValues defaultPropertyValue = DefaultPropertyValues.valueOf(propertyName); | ||
|
||
final String value = defaultPropertyValue.propertyValueExtractor().apply(swagger); | ||
|
||
return Optional.ofNullable(value); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
rest/model/src/main/java/io/syndesis/model/connection/CustomConnector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright (C) 2016 Red Hat, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.syndesis.model.connection; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
|
||
import io.syndesis.model.WithId; | ||
import io.syndesis.model.WithName; | ||
import io.syndesis.model.WithProperties; | ||
|
||
import org.immutables.value.Value; | ||
|
||
@Value.Immutable | ||
@JsonDeserialize(builder = CustomConnector.Builder.class) | ||
@SuppressWarnings("immutables") | ||
public interface CustomConnector extends WithId<CustomConnector>, WithName, WithProperties { | ||
|
||
class Builder extends ImmutableCustomConnector.Builder { | ||
// make ImmutableCustomConnector accessible | ||
} | ||
|
||
String getDescription(); | ||
|
||
String getIcon(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.