use of org.talend.components.pubsub.PubSubDatastoreProperties in project components by Talend.
the class PubSubDatasetRuntime method listSubscriptions.
@Override
public Set<String> listSubscriptions() throws Exception {
PubSubDatastoreProperties datastore = properties.getDatastoreProperties();
PubSubClient client = PubSubConnection.createClient(datastore);
return client.listSubscriptions(properties.topic.getValue());
}
use of org.talend.components.pubsub.PubSubDatastoreProperties in project components by Talend.
the class PubSubTestConstants method createDatastore.
public static PubSubDatastoreProperties createDatastore() {
PubSubDatastoreProperties datastore = new PubSubDatastoreProperties("datastore");
datastore.init();
datastore.projectName.setValue(PubSubTestConstants.PROJECT);
datastore.serviceAccountFile.setValue(PubSubTestConstants.SERVICE_ACCOUNT_FILE);
return datastore;
}
use of org.talend.components.pubsub.PubSubDatastoreProperties in project components by Talend.
the class PubSubOutputRuntime method expand.
@Override
public PDone expand(PCollection<IndexedRecord> in) {
PubSubDatasetProperties dataset = properties.getDatasetProperties();
PubSubDatastoreProperties datastore = dataset.getDatastoreProperties();
try {
createTopicSubscriptionIfNeeded(properties);
} catch (IOException e) {
throw TalendRuntimeException.createUnexpectedException(e);
}
PubsubIO.Write<PubsubMessage> pubsubWrite = PubsubIO.writeMessages().to(String.format("projects/%s/topics/%s", datastore.projectName.getValue(), dataset.topic.getValue()));
if (properties.idLabel.getValue() != null && !"".equals(properties.idLabel.getValue())) {
pubsubWrite.withIdAttribute(properties.idLabel.getValue());
}
if (properties.timestampLabel.getValue() != null && !"".equals(properties.timestampLabel.getValue())) {
pubsubWrite.withTimestampAttribute(properties.timestampLabel.getValue());
}
switch(dataset.valueFormat.getValue()) {
case CSV:
{
return in.apply(MapElements.via(new FormatCsv(dataset.fieldDelimiter.getValue()))).apply(pubsubWrite);
}
case AVRO:
{
return in.apply(MapElements.via(new FormatAvro())).apply(pubsubWrite);
}
default:
throw new RuntimeException("To be implemented: " + dataset.valueFormat.getValue());
}
}
use of org.talend.components.pubsub.PubSubDatastoreProperties in project components by Talend.
the class PubSubDatasetRuntime method listTopics.
@Override
public Set<String> listTopics() throws Exception {
PubSubDatastoreProperties datastore = properties.getDatastoreProperties();
PubSubClient client = PubSubConnection.createClient(datastore);
return client.listTopics();
}
Aggregations