示例#1
0
def main():
    parsed_args = singer.utils.parse_args(REQUIRED_CONFIG_KEYS)
    catalog = parsed_args.catalog if parsed_args.catalog else discover()

    if parsed_args.discover:
        write_catalog(catalog)
    else:
        with OutreachClient(parsed_args.config) as client:
            check_auth(client)
            sync(client, parsed_args.config, catalog, parsed_args.state,
                 parsed_args.config['start_date'])
def do_discover(client):
    LOGGER.info('Testing authentication')
    try:
        client.get(path='stages', endpoint='stages')
    except:
        raise Exception('Error testing Outreach authentication')

    LOGGER.info('Starting discover')
    catalog = discover()
    json.dump(catalog.to_dict(), sys.stdout, indent=2)
    LOGGER.info('Finished discover')
示例#3
0
def do_discover(client):
    LOGGER.info("Testing authentication")
    try:
        client.get("stages", endpoint="stages")
    except KeyboardInterrupt:
        raise
    except:
        raise Exception("Error testing Outreach authentication")

    LOGGER.info("Starting discover")
    catalog = discover()
    json.dump(catalog.to_dict(), sys.stdout, indent=2)
    LOGGER.info("Finished discover")
示例#4
0
def sync(client, catalog, state, start_date):
    if not catalog:
        catalog = discover()
        selected_streams = catalog.streams
    else:
        selected_streams = catalog.get_selected_streams(state)

    selected_streams = sorted(selected_streams, key=lambda x: x.tap_stream_id)

    for stream in selected_streams:
        mdata = metadata.to_map(stream.metadata)
        update_current_stream(state, stream.tap_stream_id)
        sync_endpoint(client, catalog, state, start_date, stream, mdata)

    update_current_stream(state)
示例#5
0
def sync(client, catalog, state, start_date):
    if not catalog:
        catalog = discover()
        selected_streams = catalog.streams
    else:
        selected_streams = catalog.get_selected_streams(state)

    selected_streams = sorted(selected_streams, key=lambda x: x.tap_stream_id)

    for stream in selected_streams:
        try:
            if stream.tap_stream_id in [
                    "accounts",
                    "prospects",
                    "events",
                    "calls",
                    "users",
                    "stages",
                    "personas",
                    "opportunities",
                    "mailings",
                    "mailboxes",
                    "sequences",
                    "sequence_states",
                    "sequence_steps",
                    "sequence_templates",
            ]:
                mdata = metadata.to_map(stream.metadata)
                update_current_stream(state, stream.tap_stream_id)
                sync_endpoint(client, catalog, state, start_date, stream,
                              mdata)
        except KeyboardInterrupt:
            raise
        except:
            update_current_stream(state)
            continue

    update_current_stream(state)