Exemplo n.º 1
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    CONFIG.update(args.config)
    STATE.update(args.state)
    account_ids = CONFIG['account_ids'].split(",")

    if args.discover:
        do_discover(account_ids)
        LOGGER.info("Discovery complete")
    elif args.catalog:
        do_sync_all_accounts(account_ids, args.catalog)
        LOGGER.info("Sync Completed")
    else:
        LOGGER.info("No catalog was provided")
Exemplo n.º 2
0
def main():
    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        Catalog.from_dict(discover_catalog()).dump()
    # Otherwise run in sync mode
    elif args.catalog:
        state = args.state or {}
        sync(args.config, args.state, args.catalog)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = args.state or {}
        sync(args.config, state, catalog)
Exemplo n.º 3
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    con = connect_with_backoff(args.config)

    if args.discover:
        do_discover(con)
    elif args.catalog:
        state = args.state or {}
        do_sync(con, args.catalog, state)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = args.state or {}
        do_sync(con, catalog, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 4
0
def main():
    args = utils.parse_args(
        ["oauth_client_id", "oauth_client_secret", "refresh_token"])
    CONFIG.update(args.config)
    STATE = {}

    if args.state:
        STATE.update(args.state)

    if args.discover:
        do_discover()
    elif args.properties:
        do_sync(args.properties)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 5
0
def main():
    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        catalog = discover()
        catalog.dump()
    # Otherwise run in sync mode
    else:
        if args.catalog:
            catalog = args.catalog
        else:
            catalog = discover()
        sync(args.config, args.state, catalog)
Exemplo n.º 6
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    CONFIG.update(args.config)
    STATE.update(args.state)
    customer_ids = CONFIG['customer_ids'].split(",")

    if args.discover:
        do_discover(customer_ids)
        LOGGER.info("Discovery complete")
    elif args.properties:
        do_sync_all_customers(customer_ids, args.properties)
        LOGGER.info("Sync Completed")
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 7
0
def main():
    """ Entry point """
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    CONFIG.update(args.config)

    if args.discover:
        catalog = discover()
        catalog.dump()
    else:
        if args.catalog:
            catalog = args.catalog
        else:
            catalog = discover()
        sync(args.state, catalog)
Exemplo n.º 8
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    connection = MySQLConnection(args.config)

    connect_with_backoff(connection)

    warnings = []
    with connection.cursor() as cur:
        try:
            cur.execute('SET @@session.time_zone="+0:00"')
        except pymysql.err.InternalError as e:
            warnings.append(
                'Could not set session.time_zone. Error: ({}) {}'.format(
                    *e.args))

        try:
            cur.execute('SET @@session.wait_timeout=2700')
        except pymysql.err.InternalError as e:
            warnings.append(
                'Could not set session.wait_timeout. Error: ({}) {}'.format(
                    *e.args))

        try:
            cur.execute('SET @@session.innodb_lock_wait_timeout=2700')
        except pymysql.err.InternalError as e:
            warnings.append(
                'Could not set session.innodb_lock_wait_timeout. Error: ({}) {}'
                .format(*e.args))

    if warnings:
        LOGGER.info((
            "Encountered non-fatal errors when configuring MySQL session that could "
            "impact performance:"))
    for w in warnings:
        LOGGER.warning(w)

    log_server_params(connection)
    if args.discover:
        do_discover(connection)
    elif args.catalog:
        state = args.state or {}
        do_sync(connection, args.config, args.catalog, state)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = args.state or {}
        do_sync(connection, args.config, catalog, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 9
0
def main():
    try:
        # Parse command line arguments
        args = utils.parse_args(REQUIRED_CONFIG_KEYS)

        Context.config = args.config
        Context.state = args.state

        # If discover flag was passed, run discovery mode and dump output to stdout
        if args.discover:
            catalog = discover()
            print(json.dumps(catalog, indent=2))
        # Otherwise run in sync mode
        else:
            Context.tap_start = utils.now()
            if args.properties:
                # Sort the properties
                streams = args.properties['streams']
                for stream in streams:
                    new_properties = {}
                    old_properties = stream['schema']['properties']
                    order = stream['column_order']

                    for column in order:
                        new_properties[column] = old_properties[column]

                    stream['schema']['properties'] = new_properties

                Context.catalog = args.properties
            else:
                Context.catalog = discover()

            sync()
    except pyactiveresource.connection.ResourceNotFound as exc:
        raise ShopifyError(exc, 'Ensure shop is entered correctly') from exc
    except pyactiveresource.connection.UnauthorizedAccess as exc:
        raise ShopifyError(exc, 'Invalid access token - Re-authorize the connection') \
            from exc
    except pyactiveresource.connection.ConnectionError as exc:
        msg = ''
        try:
            body_json = exc.response.body.decode()
            body = json.loads(body_json)
            msg = body.get('errors')
        finally:
            raise ShopifyError(exc, msg) from exc
    except Exception as exc:
        raise ShopifyError(exc) from exc
Exemplo n.º 10
0
def main():
    # Parse command line arguments

    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    if args.discover:
        catalog = {"streams": do_discover()}
        json.dump(catalog, sys.stdout, indent=2)
    # Otherwise run in sync mode
    else:
        if args.catalog:
            catalog = args.catalog
        else:
            catalog = {"streams": do_discover()}
            json.dump(catalog, sys.stdout, indent=2)
        sync(args.config, args.state, catalog)
Exemplo n.º 11
0
def main():
    '''Entry point'''
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    CONFIG.update(args.config)
    STATE = {}

    if args.state:
        STATE.update(args.state)

    if args.discover:
        do_discover()
    elif args.properties:
        do_sync(STATE, args.properties)
    else:
        LOGGER.info("No Streams were selected")
Exemplo n.º 12
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    mssql_conn = MSSQLConnection(args.config)
    log_server_params(mssql_conn)

    if args.discover:
        do_discover(mssql_conn, args.config)
    elif args.catalog:
        state = args.state or {}
        do_sync(mssql_conn, args.config, args.catalog, state)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = args.state or {}
        do_sync(mssql_conn, args.config, catalog, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 13
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    snowflake_conn = SnowflakeConnection(args.config)

    if args.discover:
        do_discover(snowflake_conn, args.config)
    elif args.catalog:
        state = args.state or {}
        do_sync(snowflake_conn, args.config, args.catalog, state)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = args.state or {}
        do_sync(snowflake_conn, args.config, catalog, state)
    else:
        LOGGER.info('No properties were selected')
Exemplo n.º 14
0
def main_impl():
    args = utils.parse_args(
        ["merchant_id", "public_key", "private_key", "start_date"])
    config = args.config

    environment = getattr(braintree.Environment,
                          config.pop("environment", "Production"))

    CONFIG['start_date'] = config.pop('start_date')

    braintree.Configuration.configure(environment, **config)

    if args.state:
        STATE.update(args.state)

    do_sync()
Exemplo n.º 15
0
def main():
    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    if args.discover:
        # If discover flag is passed, run discovery mode and dump output to stdout
        catalog = catalog_spec.discover()
        catalog.dump()
    else:
        # Otherwise run in sync mode
        if args.catalog:
            LOGGER.info("Parsing catalog from command line argument...")
            catalog = args.catalog
        else:
            LOGGER.info("Parsing catalog from discovery...")
            catalog = catalog_spec.discover()
        sync_spec.sync(args.config, args.state, catalog)
Exemplo n.º 16
0
def main():
    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        catalog = discover()
        print(json.dumps(catalog, indent=2))
    # Otherwise run in sync mode
    else:
        if args.catalog:
            catalog = args.catalog
        else:
            catalog = Catalog.from_dict(discover())

        sync(args.config, args.state, catalog)
Exemplo n.º 17
0
def main():

    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        catalog = discover_streams()
        print(json.dumps(catalog, indent=2))
    # Otherwise run in sync mode
    elif args.catalog:
        try:
            sync_streams(args.config, args.state, args.catalog)
        except Exception as e:
            LOGGER.critical(e)
            sys.exit(1)
Exemplo n.º 18
0
def main():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    url = "https://api.businesscentral.dynamics.com/v2.0/{}/{}/api/BCSItera/dashboards/v1.0/".format(args.config["tenantId"], args.config["environment"])
    service = ODataService(
        url,
        reflect_entities=True,
        auth=requests.auth.HTTPBasicAuth(args.config["username"], args.config["password"])
    )
    catalog = args.catalog or do_discover(service)
    
    if args.discover:
        catalog = discover(service)
        catalog.dump()

    else:
        sync(service, catalog, args.state, args.config["start_date"],)
Exemplo n.º 19
0
def main():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    CONFIG.update(args.config)
    connection = open_connection(args.config)
    db_schema = args.config.get('schema') or 'public'
    if args.discover:
        do_discover(connection, db_schema)
    elif args.catalog:
        state = build_state(args.state, args.catalog)
        do_sync(connection, db_schema, args.catalog, state)
    elif args.properties:
        catalog = Catalog.from_dict(args.properties)
        state = build_state(args.state, catalog)
        do_sync(connection, db_schema, catalog, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 20
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    config = args.config

    #client =  MongoClient(host=config['host'],
    #                      port=int(config['port']),
    #                      username=config.get('user', None),
    #                      password=config.get('password', None),
    #                      authSource=config['dbname'])
    client =  MongoClient(config['host'])
    LOGGER.info(client)
	
    if args.discover:
         do_discover(client)
    else:
        LOGGER.info("Only discovery mode supported right now")
Exemplo n.º 21
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    config = args.config

    client = MongoClient(host=config['host'],
                         port=int(config['port']),
                         username=config.get('user', None),
                         password=config.get('password', None),
                         authSource=config['dbname'])

    if args.discover:
        do_discover(client)
    elif args.properties:
        state = args.state or {}
        do_sync(client, args.properties, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 22
0
def main():
    args = utils.parse_args(
        ["merchant_id", "public_key", "private_key", "start_date"])
    config = args.config

    environment = getattr(braintree.Environment,
                          config.pop("environment", "Production"))

    CONFIG['start_date'] = config.pop('start_date')
    CONFIG['enable_continuous_import'] = config.pop("enable_continuous_import",
                                                    False)
    CONFIG['continuous_import_window'] = timedelta(
        days=config.pop("continuous_import_window", 120))

    braintree.Configuration.configure(environment, **config)

    if args.state:
        STATE.update(args.state)

    if args.discover:
        try:
            check_auth()
            catalog = discover()
            print(json.dumps(catalog, indent=2))
        except braintree.exceptions.authentication_error.AuthenticationError:
            logger.critical(
                'Authentication error occured. '
                'Please check your merchant_id, public_key, and '
                'private_key for errors',
                exc_info=True)
    else:
        try:
            if args.catalog:
                Context.catalog = args.catalog.to_dict()
            else:
                Context.catalog = discover()
            do_sync()
        except braintree.exceptions.authentication_error.AuthenticationError:
            logger.critical(
                'Authentication error occured. '
                'Please check your merchant_id, public_key, and '
                'private_key for errors',
                exc_info=True)
        except Exception as ex:
            singer.write_state({'stop_importing': True})
            raise ex
Exemplo n.º 23
0
def main_impl():
    LOGGER.info("=== Welcome to tap-text! ===")

    LOGGER.info('Reading config file')
    args = singer_utils.parse_args(REQUIRED_CONFIG_KEYS)
    CONFIG.update(args.config)
    LOGGER.info('Going to sync data from {} directories'.format(
        len(CONFIG['directories'])))

    rec_hash_keys = CONFIG.get('rec_hash_keys', False)
    file_format = CONFIG.get('file_format', 'jsonl')
    tap = TapText(CONFIG['directories'],
                  state=args.state,
                  file_format=file_format,
                  rec_hash_keys=rec_hash_keys)
    tap.build_schemas()
    tap.do_sync()
Exemplo n.º 24
0
def main():
    # Parse command line arguments
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    client = Five9API(args.config)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        catalog = discover(client, args.config.get('custom_reports'))
        catalog.dump()
    # Otherwise run in sync mode
    else:
        if args.catalog:
            catalog = args.catalog
        else:
            catalog = discover(client, args.config.get('custom_reports'))
        start_date = args.config['start_date']
        do_sync(client, catalog, args.state, start_date)
Exemplo n.º 25
0
def main_impl():
    args = utils.parse_args([
        "redirect_uri", "client_id", "client_secret", "refresh_token",
        "start_date"
    ])

    CONFIG.update(args.config)
    state = {}

    if args.state:
        state.update(args.state)

    if args.discover:
        logger.error('Tap does not support -d/--discover')
        exit(1)
    else:
        do_sync(state)
Exemplo n.º 26
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    kafka_config = {
        'topic': args.config['topic'],
        'group_id': args.config['group_id'],
        'reject_topic': args.config.get('reject_topic'),
        'bootstrap_servers': args.config['bootstrap_servers'].split(',')
    }

    if args.discover:
        do_discovery(args.config)
    elif args.properties:
        state = args.state or {}
        # streams = args.properties or {'streams' : common.default_streams(kafka_config)}
        sync.do_sync(kafka_config, args.properties, state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 27
0
def main():
    # Parse command line arguments
    args = utils.parse_args([REQUIRED_CONFIG_KEYS])
    tables_config = tables_config_util.validate(args.config)

    # If discover flag was passed, run discovery mode and dump output to stdout
    if args.discover:
        catalog = discover(tables_config)
        catalog.dump()
    # Otherwise run in sync mode
    else:
        if args.catalog:
            catalog = args.catalog
            LOGGER.info(f"Using supplied catalog {args.catalog_path}.")
        else:
            LOGGER.info(f"Generating catalog through sampling.")
            catalog = discover(tables_config)
        sync(tables_config, args.state, catalog)
Exemplo n.º 28
0
def main():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)

    success = True

    if args.discover:
        do_discover(args)
    elif args.properties:
        success = do_sync(args)
    else:
        LOGGER.info("No properties were selected")

    if success:
        LOGGER.info("Completed successfully, exiting.")
        exit(0)
    else:
        LOGGER.info("Run failed, exiting.")
        exit(1)
Exemplo n.º 29
0
def main_impl():
    args = utils.parse_args([
        "redirect_uri", "client_id", "client_secret", "refresh_token",
        "start_date"
    ])

    CONFIG.update(args.config)
    STATE = {}

    if args.state:
        STATE.update(args.state)

    if args.discover:
        do_discover()
    elif args.properties:
        do_sync(STATE, args.properties)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 30
0
def main_impl():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    conn_config = {
        'host': args.config['host'],
        'user': args.config['user'],
        'password': args.config['password'],
        'port': args.config['port'],
        'dbname': args.config['dbname']
    }

    if args.discover:
        do_discovery(conn_config)
    elif args.catalog:
        state = args.state
        do_sync(conn_config, args.catalog,
                args.config.get('default_replication_method'), state)
    else:
        LOGGER.info("No properties were selected")
Exemplo n.º 31
0
def main():
    args = utils.parse_args(REQUIRED_CONFIG_KEYS)
    CONFIG.update(args.config)
    STATE.update(args.state)
    do_sync()