From 4f2d96fd05d0a213a330d573a5cae8982aff0571 Mon Sep 17 00:00:00 2001 From: Sophian Date: Mon, 12 Feb 2018 13:11:53 +0100 Subject: [PATCH 1/2] add search by name record to record command --- gandi/cli/commands/record.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gandi/cli/commands/record.py b/gandi/cli/commands/record.py index 6b1f15cc..cef7d9b4 100644 --- a/gandi/cli/commands/record.py +++ b/gandi/cli/commands/record.py @@ -20,6 +20,8 @@ def record(gandi): @record.command() @click.option('--zone-id', '-z', default=None, type=click.INT, help='Zone ID to use, if not set default zone will be used.') +@click.option('--name', '-n', default=None, required=False, + help='Name of entry to search') @click.option('--output', '-o', is_flag=True, help='Write the records into a file.') @click.option('--format', '-f', type=click.Choice(['text', 'json']), @@ -28,11 +30,15 @@ def record(gandi): show_default=True) @click.argument('domain', required=True) @pass_gandi -def list(gandi, domain, zone_id, output, format, limit): +def list(gandi, domain, name, zone_id, output, format, limit): """List DNS zone records for a domain.""" options = { 'items_per_page': limit, } + + if name is not None: + options['~name'] = '%%%s%%' % name + output_keys = ['name', 'type', 'value', 'ttl'] if not zone_id: From 78579bb25d455328ce5859da3700444dfd86fc98 Mon Sep 17 00:00:00 2001 From: Sophian Date: Mon, 12 Feb 2018 15:40:00 +0100 Subject: [PATCH 2/2] change append dict options and format string --- gandi/cli/commands/record.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gandi/cli/commands/record.py b/gandi/cli/commands/record.py index cef7d9b4..1d02d882 100644 --- a/gandi/cli/commands/record.py +++ b/gandi/cli/commands/record.py @@ -37,7 +37,7 @@ def list(gandi, domain, name, zone_id, output, format, limit): } if name is not None: - options['~name'] = '%%%s%%' % name + options.update({'~name' : '%{}%'.format(name)}) output_keys = ['name', 'type', 'value', 'ttl']