Search in sources :

Example 1 with MarketoClientServiceExtended

use of org.talend.components.marketo.runtime.client.MarketoClientServiceExtended in project components by Talend.

the class MarketoSourceOrSink method getSchemaNames.

@Override
public List<NamedThing> getSchemaNames(RuntimeContainer container) throws IOException {
    List<NamedThing> customObjects = new ArrayList<>();
    MarketoClientServiceExtended client = (MarketoClientServiceExtended) getClientService(null);
    TMarketoInputProperties ip = new TMarketoInputProperties("COSchemas");
    ip.init();
    ip.connection = properties.getConnectionProperties();
    ip.inputOperation.setValue(InputOperation.CustomObject);
    ip.customObjectAction.setValue(CustomObjectAction.list);
    ip.customObjectNames.setValue("");
    ip.schemaInput.schema.setValue(MarketoConstants.getCustomObjectDescribeSchema());
    MarketoRecordResult r = client.listCustomObjects(ip);
    for (IndexedRecord co : r.getRecords()) {
        // name cannot be null
        String name = co.get(0).toString();
        Object displayName = co.get(1);
        if (displayName == null) {
            displayName = name;
        }
        customObjects.add(new SimpleNamedThing(name, displayName.toString()));
    }
    // 
    return customObjects;
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) MarketoClientServiceExtended(org.talend.components.marketo.runtime.client.MarketoClientServiceExtended) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult)

Aggregations

ArrayList (java.util.ArrayList)1 IndexedRecord (org.apache.avro.generic.IndexedRecord)1 MarketoClientServiceExtended (org.talend.components.marketo.runtime.client.MarketoClientServiceExtended)1 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)1 TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)1 NamedThing (org.talend.daikon.NamedThing)1 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)1