Add fields for create password
This commit is contained in:
parent
e0451d116a
commit
9c18aee704
1 changed files with 98 additions and 4 deletions
|
@ -1146,8 +1146,31 @@ class NcPasswordClient:
|
|||
'''List all password folders'''
|
||||
self.info(self.nc.list_passwords_folders())
|
||||
|
||||
def create_password(self, obj, update):
|
||||
def create_password(self, obj, update, label, password, folder, username,
|
||||
url, notes, custom_fields, sha1_hash, hidden, favorite):
|
||||
'''Create a password with an object'''
|
||||
if obj is None:
|
||||
obj = {}
|
||||
if label:
|
||||
obj['label'] = label
|
||||
if password:
|
||||
obj['password'] = password
|
||||
if username:
|
||||
obj['username'] = username
|
||||
if url:
|
||||
obj['url'] = url
|
||||
if notes:
|
||||
obj['notes'] = notes
|
||||
if custom_fields:
|
||||
obj['custom_fields'] = custom_fields
|
||||
if hidden is not None:
|
||||
obj['hidden'] = hidden
|
||||
if favorite is not None:
|
||||
obj['favorite'] = favorite
|
||||
if folder:
|
||||
obj['folder'] = folder
|
||||
if sha1_hash:
|
||||
obj['sha1_hash'] = sha1_hash
|
||||
safer_obj = dict(obj, **{ 'password': '***' })
|
||||
self.debug(
|
||||
{ "action": "create_password", "object": safer_obj }
|
||||
|
@ -1461,7 +1484,74 @@ def ls(ctx):
|
|||
ctx.obj['NcPasswordClient'].list_passwords()
|
||||
|
||||
@cli.command()
|
||||
@click.option('--obj', '-o', required=True, help='JSON object for a password')
|
||||
@click.option(
|
||||
'--obj', '-o',
|
||||
required=False,
|
||||
default='',
|
||||
help='JSON object for a password'
|
||||
)
|
||||
@click.option(
|
||||
'--label', '-l',
|
||||
required=False,
|
||||
default='',
|
||||
help='Label/name of the password'
|
||||
)
|
||||
@click.option(
|
||||
'--username', '-u',
|
||||
required=False,
|
||||
default='',
|
||||
help='User name of the password'
|
||||
)
|
||||
@click.option(
|
||||
'--password', '-p',
|
||||
required=False,
|
||||
default='',
|
||||
help='Password or secret to store'
|
||||
)
|
||||
@click.option(
|
||||
'--url', '-U',
|
||||
required=False,
|
||||
default='',
|
||||
help='The url of the associated website'
|
||||
)
|
||||
@click.option(
|
||||
'--notes', '-n',
|
||||
required=False,
|
||||
default='',
|
||||
help='The users notes'
|
||||
)
|
||||
@click.option(
|
||||
'--custom-fields', '-c',
|
||||
required=False,
|
||||
default='',
|
||||
help='The custom fields defined by the user'
|
||||
)
|
||||
@click.option(
|
||||
'--sha1-hash', '-H',
|
||||
required=False,
|
||||
default='',
|
||||
help='The SHA1 hash of the password'
|
||||
)
|
||||
@click.option(
|
||||
'--folder', '-f',
|
||||
required=False,
|
||||
default='',
|
||||
help='The current folder of the password'
|
||||
)
|
||||
@click.option(
|
||||
'--hidden', '-i',
|
||||
required=False,
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help='Whether or not the password should be hidden'
|
||||
)
|
||||
@click.option(
|
||||
'--favorite', '-f',
|
||||
required=False,
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help='Whether or not the user has marked this password as favorite'
|
||||
)
|
||||
@click.option(
|
||||
'--update', '-u',
|
||||
is_flag=True,
|
||||
|
@ -1470,9 +1560,13 @@ def ls(ctx):
|
|||
)
|
||||
@click_config_file.configuration_option()
|
||||
@click.pass_context
|
||||
def create_password(ctx, obj, update):
|
||||
def create_password(ctx, obj, update, label, password, folder, username,
|
||||
url, notes, custom_fields, sha1_hash, hidden, favorite):
|
||||
'''Create a password'''
|
||||
ctx.obj['NcPasswordClient'].create_password(json.loads(obj), update)
|
||||
ctx.obj['NcPasswordClient'].create_password(
|
||||
json.loads(obj), update, label, password, folder, username,
|
||||
url, notes, custom_fields, sha1_hash, hidden, favorite
|
||||
)
|
||||
|
||||
@cli.command()
|
||||
@click.option('--name', '-n', help='Name of the password to delete')
|
||||
|
|
Loading…
Reference in a new issue