use of com.openshift.cloud.api.connector.models.KafkaConnectionSettings in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsApiClientImpl method createConnector.
@Override
public Connector createConnector(ConnectorEntity connectorEntity) {
ConnectorRequest createConnectorRequest = new ConnectorRequest();
String newConnectorName = connectorEntity.getName();
createConnectorRequest.setName(newConnectorName);
DeploymentLocation deploymentLocation = new DeploymentLocation();
deploymentLocation.setKind("addon");
deploymentLocation.setClusterId(mcClusterId);
createConnectorRequest.setDeploymentLocation(deploymentLocation);
String connectorType = connectorEntity.getConnectorType();
JsonNode payload = connectorEntity.getDefinition();
createConnectorRequest.setConnectorTypeId(connectorType);
createConnectorRequest.setConnector(payload);
ServiceAccount serviceAccount = new ServiceAccount();
serviceAccount.setClientId(serviceAccountId);
serviceAccount.setClientSecret(serviceAccountSecret);
createConnectorRequest.setServiceAccount(serviceAccount);
KafkaConnectionSettings kafka = new KafkaConnectionSettings();
kafka.setUrl(kafkaBootstrapServer);
// https://issues.redhat.com/browse/MGDOBR-198
// this is currently ignored in the Connectors API
kafka.setId(KAFKA_ID_IGNORED);
createConnectorRequest.setKafka(kafka);
return createConnector(createConnectorRequest);
}
use of com.openshift.cloud.api.connector.models.KafkaConnectionSettings in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ConnectorsApiClientImpl method createConnector.
@Override
public Connector createConnector(ConnectorEntity connectorEntity) {
ConnectorRequest createConnectorRequest = new ConnectorRequest();
String newConnectorName = connectorEntity.getName();
createConnectorRequest.setName(newConnectorName);
createConnectorRequest.setNamespaceId(mcNamespaceId);
String connectorTypeId = connectorEntity.getConnectorTypeId();
JsonNode payload = connectorEntity.getDefinition();
createConnectorRequest.setConnectorTypeId(connectorTypeId);
createConnectorRequest.setConnector(payload);
ServiceAccount serviceAccount = new ServiceAccount();
serviceAccount.setClientId(serviceAccountId);
serviceAccount.setClientSecret(serviceAccountSecret);
createConnectorRequest.setServiceAccount(serviceAccount);
KafkaConnectionSettings kafka = new KafkaConnectionSettings();
kafka.setUrl(kafkaBootstrapServer);
// https://issues.redhat.com/browse/MGDOBR-198
// this is currently ignored in the Connectors API
kafka.setId(KAFKA_ID_IGNORED);
createConnectorRequest.setKafka(kafka);
return createConnector(createConnectorRequest);
}
use of com.openshift.cloud.api.connector.models.KafkaConnectionSettings in project sandbox by 5733d9e2be6485d52ffa08870cabdee0.
the class ManagedConnectorServiceApplication method createSlackConnector.
private Connector createSlackConnector() throws Exception {
ConnectorsApi apiInstance = createConnectorsAPI();
// Boolean | Perform the action in an asynchronous manner
// Connector | Connector data
Connector createConnectorRequest = new Connector();
ConnectorAllOfMetadata metadata = new ConnectorAllOfMetadata();
metadata.setName("openbridge-slack-connector");
metadata.setKafkaId("kafkaId-ignored");
createConnectorRequest.setMetadata(metadata);
AddonClusterTarget deploymentLocation = new AddonClusterTarget();
deploymentLocation.setKind("addon");
deploymentLocation.setClusterId("c4ovtrsldcav5gaeqkn0");
createConnectorRequest.setDeploymentLocation(deploymentLocation);
createConnectorRequest.setConnectorTypeId("slack_sink_0.1");
KafkaConnectionSettings kafka = new KafkaConnectionSettings();
kafka.setBootstrapServer(kafkaUrl);
kafka.setClientId(serviceAccountId);
kafka.setClientSecret(serviceAccountSecret);
createConnectorRequest.setKafka(kafka);
ConnectorSpec connectorSpec = new ConnectorSpec();
ConnectorSpecKafka connectorSpecKafka = new ConnectorSpecKafka();
connectorSpecKafka.setTopic("slacktopic");
connectorSpec.setConnectorSpecKafka(connectorSpecKafka);
SlackConnector connector = new SlackConnector();
connector.setChannel("mc");
connector.setWebhookUrl(webhookUrl);
connectorSpec.setConnector(connector);
createConnectorRequest.setConnectorSpec(connectorSpec);
try {
Connector connectorResult = apiInstance.createConnector(true, createConnectorRequest);
System.out.println("Connector created: " + connectorResult);
return connectorResult;
} catch (WebApplicationException e) {
Response response = e.getResponse();
System.out.println("Error code: " + response.getStatus());
ByteArrayInputStream arrayInputStream = (ByteArrayInputStream) response.getEntity();
Scanner scanner = new Scanner(arrayInputStream);
// To read all scanner content in one String
scanner.useDelimiter("\\Z");
String data = "";
if (scanner.hasNext()) {
data = scanner.next();
}
System.out.println(data);
throw e;
}
}
Aggregations