Add filtering CLI options to 'secrets list' sub command.
Change-Id: I14265ad277a02f93af98312e139dc19e23382edd Implements: blueprint secret-list-add-criteria
This commit is contained in:
@@ -209,6 +209,18 @@ class Keep:
|
||||
list_parser.add_argument('--offset', '-o', default=0, help='specify t'
|
||||
'he page offset (default: %(default)s)',
|
||||
type=int)
|
||||
list_parser.add_argument('--name', '-n', default=None, help='specify t'
|
||||
'he secret name (default: %(default)s)')
|
||||
list_parser.add_argument('--algorithm', '-a', default=None,
|
||||
help='the algorithm filter for the list'
|
||||
'(default: %(default)s).')
|
||||
list_parser.add_argument('--bit-length', '-b', default=0,
|
||||
help='the bit length filter for the list'
|
||||
' (default: %(default)s).',
|
||||
type=int)
|
||||
list_parser.add_argument('--mode', '-m', default=None,
|
||||
help='the algorithmm mode filter for the'
|
||||
' list (default: %(default)s).')
|
||||
list_parser.set_defaults(func=self.list)
|
||||
|
||||
def store(self, args):
|
||||
@@ -269,7 +281,12 @@ class Keep:
|
||||
|
||||
def list(self, args):
|
||||
if args.command == 'secret':
|
||||
ls = self.client.secrets.list(args.limit, args.offset)
|
||||
ls = self.client.secrets.list(limit=args.limit,
|
||||
offset=args.offset,
|
||||
name=args.name,
|
||||
mode=args.mode,
|
||||
algorithm=args.algorithm,
|
||||
bits=args.bit_length)
|
||||
elif args.command == 'verification':
|
||||
ls = self.client.verifications.list(args.limit, args.offset)
|
||||
elif args.command == 'order':
|
||||
|
||||
@@ -175,7 +175,8 @@ class SecretManager(base.BaseEntityManager):
|
||||
raise ValueError('secret_ref is required.')
|
||||
self.api.delete(secret_ref)
|
||||
|
||||
def list(self, limit=10, offset=0):
|
||||
def list(self, limit=10, offset=0, name=None, algorithm=None,
|
||||
mode=None, bits=0):
|
||||
"""
|
||||
List all secrets for the tenant
|
||||
|
||||
@@ -187,6 +188,15 @@ class SecretManager(base.BaseEntityManager):
|
||||
limit))
|
||||
href = '{0}/{1}'.format(self.api.base_url, self.entity)
|
||||
params = {'limit': limit, 'offset': offset}
|
||||
if name:
|
||||
params['name'] = name
|
||||
if algorithm:
|
||||
params['alg'] = algorithm
|
||||
if mode:
|
||||
params['mode'] = mode
|
||||
if bits > 0:
|
||||
params['bits'] = bits
|
||||
|
||||
resp = self.api.get(href, params)
|
||||
|
||||
return [Secret(s) for s in resp['secrets']]
|
||||
|
||||
Reference in New Issue
Block a user