def parse_args()

in tools/deletebyquery/deletebyquery.py [0:0]


def parse_args():
    parser = argparse.ArgumentParser(description='Delete data from NEXUS using a Solr Query',
                                     formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    parser.add_argument('--solr',
                        help='The url of the SOLR server.',
                        required=True,
                        metavar='127.0.0.1:8983')

    parser.add_argument('--collection',
                        help='The name of the SOLR collection.',
                        required=False,
                        default='nexustiles',
                        metavar='nexustiles')

    parser.add_argument('--solrIdField',
                        help='The name of the unique ID field for this collection.',
                        required=False,
                        default='id',
                        metavar='id')

    parser.add_argument('--cassandra',
                        help='The hostname(s) or IP(s) of the Cassandra server(s).',
                        required=True,
                        nargs='+',
                        metavar=('127.0.0.100', '127.0.0.101'))

    parser.add_argument('-k', '--cassandraKeyspace',
                        help='The Cassandra keyspace.',
                        default='nexustiles',
                        required=False,
                        metavar='nexustiles')

    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument('-q', '--query',
                       help='The ''q'' parameter passed to SOLR Search',
                       metavar='*:*')

    group.add_argument('--jsonparams',
                       help='Full query prameters formatted as JSON')

    parser.add_argument('-fq', '--filterquery',
                        help='The ''fq'' parameter passed to SOLR Search. Only used if --jsonparams is not provided',
                        required=False,
                        nargs='+')

    parser.add_argument('-t', '--cassandraTable',
                        help='The name of the cassandra table.',
                        required=False,
                        default='sea_surface_temp')

    parser.add_argument('-p', '--cassandraPort',
                        help='The port used to connect to Cassandra.',
                        required=False,
                        default='9042')

    parser.add_argument('--cassandraUsername',
                        help='The username used to connect to Cassandra.',
                        required=False)

    parser.add_argument('--cassandraPassword',
                        help='The password used to connect to Cassandra.',
                        required=False)

    parser.add_argument('-pv', '--cassandraProtocolVersion',
                        help='The version of the Cassandra protocol the driver should use.',
                        required=False,
                        choices=['1', '2', '3', '4', '5'],
                        default='4')

    parser.add_argument('--solr-rows',
                        help='Number of rows to fetch with each Solr query to build the list of tiles to delete',
                        required=False,
                        dest='rows',
                        default=1000,
                        type=int)

    return parser.parse_args()