Search in sources :

Example 6 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties 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)

Example 7 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoSourceOrSink method getEndpointSchema.

@Override
public Schema getEndpointSchema(RuntimeContainer container, String schemaName) throws IOException {
    MarketoRESTClient client = (MarketoRESTClient) getClientService(null);
    TMarketoInputProperties ip = new TMarketoInputProperties("retrieveSchema");
    Schema describeSchema = MarketoConstants.getCustomObjectDescribeSchema();
    ip.connection = properties.getConnectionProperties();
    ip.inputOperation.setValue(InputOperation.CustomObject);
    ip.customObjectAction.setValue(CustomObjectAction.describe);
    ip.customObjectName.setValue(schemaName);
    ip.schemaInput.schema.setValue(describeSchema);
    MarketoRecordResult r = client.describeCustomObject(ip);
    if (!r.isSuccess()) {
        return null;
    }
    List<IndexedRecord> records = r.getRecords();
    if (records == null || records.isEmpty()) {
        return null;
    }
    IndexedRecord record = records.get(0);
    return FieldDescription.getSchemaFromJson(schemaName, record.get(describeSchema.getField("fields").pos()).toString(), record.get(describeSchema.getField("dedupeFields").pos()).toString());
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) Schema(org.apache.avro.Schema) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) MarketoRESTClient(org.talend.components.marketo.runtime.client.MarketoRESTClient) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult)

Example 8 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputReaderTestIT method testLeadActivityWithSpecificActivitiesREST.

@Test
public void testLeadActivityWithSpecificActivitiesREST() throws Exception {
    TMarketoInputProperties props = getRESTProperties();
    props.inputOperation.setValue(getLeadActivity);
    String since = new SimpleDateFormat(DATETIME_PATTERN_PARAM).format(new Date(new Date().getTime() - 10000000));
    props.sinceDateTime.setValue(since);
    props.batchSize.setValue(300);
    props.afterInputOperation();
    props.beforeMappingInput();
    props.setIncludeTypes.setValue(true);
    props.includeTypes.type.setValue(Arrays.asList("DeleteLead", "AddToList"));
    reader = getReader(props);
    assertTrue(reader.start());
    IndexedRecord r = reader.getCurrent();
    assertNotNull(r);
    assertTrue(r.getSchema().getFields().size() > 6);
    while (reader.advance()) {
        r = reader.getCurrent();
        assertNotNull(r);
        assertThat(Integer.parseInt(r.get(3).toString()), anyOf(is(24), is(37)));
    }
    assertTrue(((int) reader.getReturnValues().get(RETURN_NB_CALL)) >= 1);
}
Also used : IndexedRecord(org.apache.avro.generic.IndexedRecord) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) Test(org.junit.Test)

Example 9 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputReaderTestIT method testTDI38956.

@Test
public void testTDI38956() throws Exception {
    TMarketoInputProperties props = getRESTProperties();
    props.inputOperation.setValue(getLead);
    props.leadKeyTypeREST.setValue(email);
    props.afterInputOperation();
    String email = EMAIL_LEAD_TEST;
    props.leadKeyValue.setValue(email);
    MarketoSource source = new MarketoSource();
    source.initialize(null, props);
    MarketoClientService client = source.getClientService(null);
    MarketoRecordResult result = client.getLead(props, null);
    LOG.debug("{}", result);
    List<IndexedRecord> records = result.getRecords();
    assertNotEquals(emptyList(), records);
    IndexedRecord record = records.get(0);
    assertNotNull(record);
    // createdAt shouldn't be null
    assertNotNull(record.get(4));
    // updatedAt shouldn't be null
    assertNotNull(record.get(5));
}
Also used : MarketoClientService(org.talend.components.marketo.runtime.client.MarketoClientService) IndexedRecord(org.apache.avro.generic.IndexedRecord) TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties) MarketoRecordResult(org.talend.components.marketo.runtime.client.type.MarketoRecordResult) Test(org.junit.Test)

Example 10 with TMarketoInputProperties

use of org.talend.components.marketo.tmarketoinput.TMarketoInputProperties in project components by Talend.

the class MarketoInputReaderTestIT method getSOAPProperties.

public TMarketoInputProperties getSOAPProperties() {
    TMarketoInputProperties props = new TMarketoInputProperties("test");
    props.connection.setupProperties();
    props.connection.endpoint.setValue(ENDPOINT_SOAP);
    props.connection.clientAccessId.setValue(USERID_SOAP);
    props.connection.secretKey.setValue(SECRETKEY_SOAP);
    props.connection.setupLayout();
    props.mappingInput.setupProperties();
    props.setupProperties();
    props.connection.apiMode.setValue(SOAP);
    props.schemaInput.setupProperties();
    props.schemaInput.setupLayout();
    props.includeTypes.setupProperties();
    props.includeTypes.type.setValue(new ArrayList<String>());
    props.excludeTypes.setupProperties();
    props.excludeTypes.type.setValue(new ArrayList<String>());
    props.setupLayout();
    return props;
}
Also used : TMarketoInputProperties(org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)

Aggregations

TMarketoInputProperties (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties)45 Test (org.junit.Test)25 Before (org.junit.Before)11 IndexedRecord (org.apache.avro.generic.IndexedRecord)10 TMarketoOutputProperties (org.talend.components.marketo.tmarketooutput.TMarketoOutputProperties)9 TMarketoListOperationProperties (org.talend.components.marketo.tmarketolistoperation.TMarketoListOperationProperties)6 Date (java.util.Date)5 Schema (org.apache.avro.Schema)5 SimpleDateFormat (java.text.SimpleDateFormat)4 MarketoRecordResult (org.talend.components.marketo.runtime.client.type.MarketoRecordResult)4 RuntimeContainer (org.talend.components.api.container.RuntimeContainer)2 MarketoRESTClient (org.talend.components.marketo.runtime.client.MarketoRESTClient)2 TMarketoBulkExecProperties (org.talend.components.marketo.tmarketobulkexec.TMarketoBulkExecProperties)2 LeadSelector (org.talend.components.marketo.tmarketoinput.TMarketoInputProperties.LeadSelector)2 NamedThing (org.talend.daikon.NamedThing)2 ValidationResult (org.talend.daikon.properties.ValidationResult)2 ValidationResultMutable (org.talend.daikon.properties.ValidationResultMutable)2 Gson (com.google.gson.Gson)1 AuthenticationHeader (com.marketo.mktows.AuthenticationHeader)1 MktowsPort (com.marketo.mktows.MktowsPort)1