def add_parser(subparsers, name, desc, config): """Add all upgrade tasks sub commands.""" # api_version = config.server.api_version.value parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list all upgrade tasks.") parser.add_argument('identifier', nargs="?", help="""<Upgrade task identifier>. It will display all previous runs for this upgrade task.""" ).completer = Completer() parser.add_argument( 'run', nargs="?", help="<Run uuid>. It will display the content of one run (console)" ).completer = Completer('complete_async_tasks') parser.add_argument('--criticity', action="append", choices=['DEBUG', 'INFO', 'WARN', 'ERROR'], help="Applied only when displaying run data.") add_list_parser_options(parser, cdate=True) parser.set_defaults(__func__=UpgradeTasksListCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update welcome message.") parser.add_argument('identifier').completer = Completer() parser.add_argument('--force', action="store_true") parser.set_defaults(__func__=UpgradeTasksTriggerCommand(config))
def add_parser(subparsers, name, desc, config): """Add all domain policies sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list domain policies") parser.add_argument('identifiers', nargs="*", help="Filter domain policies by their identifiers") add_list_parser_options(parser) parser.set_defaults(__func__=DomainPoliciesListCommand(config)) # command : delete parser_tmp2 = subparsers2.add_parser('delete', help="delete domain policies.") parser_tmp2.add_argument('identifiers', nargs="*", action="store", help="").completer = Completer() parser_tmp2.set_defaults(__func__=DomainPoliciesDeleteCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser('create', help="create domain policies.") parser_tmp2.add_argument('identifier', action="store", help="") parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.add_argument('--cli-mode', action="store_true", help="") parser_tmp2.set_defaults(__func__=DomainPoliciesCreateCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser('update', help="update domain policies.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.set_defaults(__func__=DomainPoliciesUpdateCommand(config))
def add_delete_parser_options(parser, method=None): """TODO""" if method: parser.add_argument('uuids', nargs='+').completer = Completer(method) else: parser.add_argument('uuids', nargs='+').completer = Completer() parser.add_argument('--dry-run', action="store_true")
def add_parser(subparsers, name, desc, config): """Add all public key sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list public key.") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=False) parser.add_argument('--domain', ).completer = Completer("complete_domain") parser.set_defaults(__func__=PublicKeysListCommand(config)) # command : delete parser_tmp2 = subparsers2.add_parser('delete', help="delete public key.") add_delete_parser_options(parser_tmp2) parser_tmp2.set_defaults(__func__=PublicKeyDeleteCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser('create', help="create public key.") parser_tmp2.add_argument('issuer') parser_tmp2.add_argument('-f', '--format', choices=['PEM', 'RSA'], default="PEM", dest="format") parser_tmp2.add_argument('--key', action="store", required=True) parser_tmp2.add_argument('--cli-mode', action="store_true", help="") parser_tmp2.add_argument( '--domain', default="LinShareRootDomain").completer = Completer("complete_domain") parser_tmp2.set_defaults(__func__=PublicKeysCreateCommand(config))
def add_download_parser_options(parser, method=None): """TODO""" if method: parser.add_argument('uuids', nargs='+').completer = Completer(method) else: parser.add_argument('uuids', nargs='+').completer = Completer() parser.add_argument('--dry-run', action="store_true") parser.add_argument('-o', '--output-dir', action="store", dest="directory")
def add_parser(subparsers, name, desc, config): """TODO""" # api_version = config.server.api_version.value parser_tmp = subparsers.add_parser(name, help=desc) parser_tmp.add_argument( '-u', '--uuid', action="store", dest="thread_uuid", help="thread uuid", required=True).completer = ThreadCompleter(config) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser( 'list', help="list thread members") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options( parser, delete=False, cdate=True ) parser.set_defaults(__func__=ThreadMembersListCommand(config)) # command : delete parser = subparsers2.add_parser( 'delete', help="delete thread members") add_delete_parser_options(parser) parser.set_defaults(__func__=ThreadMembersDeleteCommand(config)) # command : create parser = subparsers2.add_parser( 'create', help="create thread member.") parser.add_argument( '--mail', dest="user_mail", required=True, help="").completer = Completer('complete_mail') group = parser.add_mutually_exclusive_group() group.add_argument('--admin', action="store_true", help="") group.add_argument('--readonly', action="store_true", help="") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=ThreadMembersCreateCommand(config)) # command : update parser = subparsers2.add_parser( 'update', help="update thread.") parser.add_argument( 'userUuid', action="store", help="").completer = Completer() parser.add_argument('role', choices=["admin", "normal", "restricted"], help="") parser.set_defaults(__func__=ThreadMembersUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', formatter_class=RawTextHelpFormatter, help="list guests from linshare") parser.add_argument('pattern', nargs="*", help="Filter documents by their names") parser.add_argument('-f', '--firstname', action="store") parser.add_argument('-l', '--lastname', action="store") parser.add_argument('-m', '--mail', action="store") parser.add_argument('-u', '--uuid', action="append") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=GuestsListCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create guest.") parser.add_argument('--mail', dest="mail", required=True, help="") parser.add_argument('--firstname', dest="first_name", required=True, help="") parser.add_argument('--lastname', dest="last_name", required=True, help="") parser.add_argument('--can-upload', dest="can_upload", action="store_true", help="") parser.set_defaults(__func__=GuestsCreateCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete guests") add_delete_parser_options(parser) parser.set_defaults(__func__=GuestsDeleteCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update guest.") parser.add_argument('uuid', action="store", help="").completer = Completer() parser.add_argument('--first-name', action="store", help="") parser.add_argument('--last-name', action="store", help="") parser.add_argument('--mail', action="store", help="") parser.add_argument('--can-upload', action="store", help="true or false") parser.add_argument('--restricted', action="store_false") parser.set_defaults(__func__=GuestsUpdateCommand(config)) # command : info parser = subparsers2.add_parser('info', help="info guests") parser.add_argument('uuids', nargs='+').completer = Completer() add_list_parser_options(parser, cdate=True) parser.set_defaults(__func__=GuestsInfoCommand(config))
def add_parser(subparsers, name, desc, config): """Add all ldap connections sub commands.""" api_version = config.server.api_version.value parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser( 'list', help="list ldap connections.") parser.add_argument('identifiers', nargs="*", help="") if api_version == 0: add_list_parser_options(parser, delete=True) else: add_list_parser_options(parser, delete=True, cdate=False) parser.set_defaults(__func__=LdapConnectionsListCommand(config)) # command : delete parser_tmp2 = subparsers2.add_parser( 'delete', help="delete ldap connections.") if api_version == 0: parser_tmp2.add_argument( 'identifier', action="store", help="").completer = Completer() else: add_delete_parser_options(parser_tmp2) parser_tmp2.set_defaults(__func__=LdapConnectionsDeleteCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser( 'create', help="create ldap connections.") parser_tmp2.add_argument('--provider-url', action="store", help="", required=True) parser_tmp2.add_argument('--principal', action="store", help="") parser_tmp2.add_argument('--credential', action="store", help="") parser_tmp2.add_argument('--cli-mode', action="store_true", help="") if api_version == 0: parser_tmp2.add_argument('identifier', action="store", help="") parser_tmp2.set_defaults(__func__=LdapConnectionsCreateCommand(config)) else: parser_tmp2.add_argument('label', action="store", help="") parser_tmp2.set_defaults(__func__=LdapConnectionsCreateCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser( 'update', help="update ldap connections.") parser_tmp2.add_argument( 'identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument('--provider-url', action="store", help="") parser_tmp2.add_argument('--principal', action="store", help="") parser_tmp2.add_argument('--credential', action="store", help="") parser_tmp2.set_defaults(__func__=LdapConnectionsUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser = subparsers.add_parser(name, help=desc) subparsers2 = parser.add_subparsers() # command : list parser = subparsers2.add_parser( 'me', help="Display my account") filter_group = parser.add_argument_group('Filters') filter_group.add_argument( '-k', '--field', action='append', dest="fields" ).completer = Completer("complete_fields") add_list_parser_options_format(parser) parser.set_defaults(__func__=AuthenticationListCommand(config)) # command : update parser = subparsers2.add_parser( 'update', help="update my password (local users only).") password_group = parser.add_argument_group('Password') group = password_group.add_mutually_exclusive_group(required=True) group.add_argument('-n', '--new-password') group.add_argument('-a', '--ask-new-password', action="store_true") group.add_argument( '-e', '--new-password-from-env', action="store", help="If set, the program will load your password from this environement variable.") parser.set_defaults(__func__=ChangePasswordCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list threads") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=ThreadsListCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete threads") add_delete_parser_options(parser) parser.set_defaults(__func__=ThreadsDeleteCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create thread.") parser.add_argument('name', action="store", help="") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=ThreadsCreateCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update thread.") parser.add_argument('uuid', action="store", help="").completer = Completer() parser.add_argument('name', action="store", help="") parser.set_defaults(__func__=ThreadsUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) parser_tmp.add_argument( '-u', '--uuid', action="store", dest="mailing_list_uuid", help="list uuid", required=True).completer = ContactListsCompleter(config) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', formatter_class=RawTextHelpFormatter, help="list contactslist from linshare") parser.add_argument('pattern', nargs="*", help="Filter documents by their names") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=ListCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create contactslist.") parser.add_argument(DefaultCommand.IDENTIFIER, action="store", help="") parser.add_argument('--public', dest="public", action="store_true", help="") parser.add_argument('--first-name', action="store", help="") parser.add_argument('--last-name', action="store", help="") parser.set_defaults(__func__=CreateCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete contactslist") add_delete_parser_options(parser) parser.set_defaults(__func__=DeleteCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update contactslist.") parser.add_argument('uuid', action="store", help="").completer = Completer() #parser.add_argument('--identifier', action="store", help="") parser.add_argument("--" + DefaultCommand.IDENTIFIER, action="store", help="") parser.add_argument('--public', dest="public", action="store_true", help="") parser.add_argument('--first-name', action="store", help="") parser.add_argument('--last-name', action="store", help="") parser.set_defaults(__func__=UpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all Jwt token sub commands.""" parser = subparsers.add_parser(name, help=desc) subparsers2 = parser.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list Jwt token.") parser.add_argument('identifiers', nargs="*", help="") parser.add_argument('-u', '--uuid', dest="uuids", action="append", help="Filter by uuid fragments.") add_list_parser_options(parser, delete=True, cdate=False) parser.add_argument('--domain', ).completer = Completer("complete_domain") parser.set_defaults(__func__=JwtListCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete Jwt token.") add_delete_parser_options(parser) parser.set_defaults(__func__=JwtDeleteCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create Jwt token.") parser.add_argument('label') parser.add_argument('--actor', action="store", required=True, help="Uuid of the owner of the new token") parser.add_argument('--description', action="store") parser.add_argument('--cli-mode', action="store_true", help="") parser.add_argument('-o', '--output-token-file', action="store", dest="output", help=("Storing the JWT token in an outputfile" " instead of stdout.")) parser.add_argument('-f', '--force', action="store_true", help="Override output file even if it already exists.") parser.add_argument('--export-var', action="store", default="TOKEN", help="") parser.set_defaults(__func__=JwtCreateCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update Jwt token.") parser.add_argument('uuid') parser.add_argument('--label') parser.add_argument('--description', action="store") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=JwtUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all thread member sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() parser = subparsers2.add_parser('list', help="list thread members.") parser.add_argument('-u', '--uuid', action="store", dest="uuid", required=True).completer = Completer() add_list_parser_options(parser, cdate=True) parser.set_defaults(__func__=ThreadMembersListCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) parser_tmp.add_argument( 'ss_uuid', help="shared_space uuid").completer = SharedSpaceCompleter(config) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', formatter_class=RawTextHelpFormatter, help="list shared space from linshare") parser.add_argument('names', nargs="*", help="Filter documents by their names") parser.add_argument('-u', '--uuid', dest="uuids", action="append", help="") parser.add_argument('-o', '--role', dest="roles", action="append", choices=['ADMIN', 'WRITER', 'CONTRIBUTOR', 'READER'], help="") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=ListCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create shared space.") parser.add_argument('account', action="store", help="Account uuid") parser.add_argument('--role', action="store", choices=['ADMIN', 'WRITER', 'CONTRIBUTOR', 'READER'], help="") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=CreateCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete shared space") add_delete_parser_options(parser) parser.set_defaults(__func__=DeleteCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update shared space.") parser.add_argument('uuid', action="store", help="").completer = Completer() parser.add_argument('--role', action="store", choices=['ADMIN', 'WRITER', 'CONTRIBUTOR', 'READER'], help="") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=UpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all user sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # api_version = config.server.api_version.value # command : list parser = subparsers2.add_parser('list', help="list domains") parser.add_argument('identifiers', nargs="*", help="Filter domains by their identifiers") parser.add_argument('-n', '--label', action="store_true", help="sort by domain label") parsers = add_list_parser_options(parser, delete=True, cdate=False) actions = parsers[3] actions.add_argument( "--set-domain", help="update all inconsistent users with selected domain" ).completer = Completer("complete_domain") parser.set_defaults(__func__=InconsistentUsersListCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update inconsistent users.") parser.add_argument('identifier', action="store", help="").completer = Completer() parser.add_argument('--domain', action="store", help="").completer = Completer("complete_domain") parser.set_defaults(__func__=InconsistentUsersUpdateCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete inconsistent users.") add_delete_parser_options(parser) parser.set_defaults(__func__=InconsistentUsersDeleteCommand(config))
def add_parser(subparsers, name, desc, config): """Add all mail configs commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser( 'list', help="list mail configs") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=False) parser.add_argument('--parent', action="store_true", help="Display also mail configs from parent domains") parser.add_argument('--domain', ).completer = Completer("complete_domain") parser.set_defaults(__func__=MailConfigsListCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', formatter_class=RawTextHelpFormatter, help="list shared space from linshare") parser.add_argument('names', nargs="*", help="") parser.add_argument('-u', '--uuids', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=ListCommand(config)) # command : detail parser = subparsers2.add_parser('detail', formatter_class=RawTextHelpFormatter, help="detail shared space from linshare") parser.add_argument('uuids', nargs="+", help="") add_list_parser_options(parser, delete=True, cdate=True) parser.set_defaults(__func__=DetailCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete shared space") add_delete_parser_options(parser) parser.set_defaults(__func__=DeleteCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create shared space.") parser.add_argument('name', action="store", help="shared space name") parser.add_argument('--type', dest="node_type", action="store", choices=['WORK_GROUP', 'DRIVE'], help="") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=CreateCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update shared space.") parser.add_argument('uuid', action="store", help="").completer = Completer() parser.add_argument('--name', action="store", help="Filter by name (partial)") parser.add_argument('--cli-mode', action="store_true", help="") parser.set_defaults(__func__=UpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all user sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() parser_tmp2 = subparsers2.add_parser('list', help="list users from linshare") parser_tmp2.add_argument('-f', '--firstname', action="store") parser_tmp2.add_argument('-l', '--lastname', action="store") parser_tmp2.add_argument('-m', '--mail', action="store") parser_tmp2.add_argument('--extended', action="store_true", help="extended format") parser_tmp2.add_argument('-r', '--reverse', action="store_true", help="reverse order while sorting") parser_tmp2.add_argument('-t', '--vertical', action="store_true", help="use vertical output mode") parser_tmp2.add_argument('--csv', action="store_true", help="Csv output") parser_tmp2.add_argument('--raw', action="store_true", help="Disable all formatters") parser_tmp2.add_argument( '-k', '--field', action='append', dest="fields" ).completer = Completer("complete_fields") parser_tmp2.set_defaults(__func__=UsersListCommand(config))
def add_parser(subparsers, name, desc, config): """TODO""" parser_tmp = subparsers.add_parser(name, help=desc) parser_tmp.add_argument( 'wg_uuid', help="workgroup uuid").completer = WorkgroupCompleter(config) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list workgroup nodes from linshare") parser.add_argument('-f', '--filter', action="append", dest="names", help="Filter documents by their names") parser.add_argument( '--flat', action="store_true", dest="flat_mode", help= "Flat document mode : list all documents in every folders in a workgroup" ) parser.add_argument( '--type', action="append", dest="node_types", default=None, choices=["DOCUMENT", "FOLDER", "ROOT_FOLDER", "DOCUMENT_REVISION"], help="Filter the returned objects by type.") parser.add_argument('--no-breadcrumb', action="store_true", help="Do not display breadcrumb.") parser.add_argument( 'folders', nargs="*", help="Browse folders'content: folder_uuid, folder_uuid, ..." ).completer = Completer() add_list_parser_options(parser, download=True, delete=True, cdate=True) parser.set_defaults(__func__=WgNodeContentListCommand(config)) # command : show parser = subparsers2.add_parser( 'show', help="show workgroup nodes (folders, documents, ...)") parser.add_argument( 'nodes', nargs="*", help="Display folders'content: folder_uuid, folder_uuid, ...") parser.add_argument('--extended', action="store_true", help="Display results using extended format.") parser.add_argument('--json', action="store_true", help="Json output") parser.add_argument('--raw-json', action="store_true", help="Display every attributes for json output.") parser.add_argument('--raw', action="store_true", help="Disable all data formatters (time, size, ...)") parser.set_defaults(__func__=WgNodeContentDisplayCommand(config)) # command : delete parser = subparsers2.add_parser( 'delete', help="delete workgroup nodes (folders, documents, ...)") add_delete_parser_options(parser, 'complete_root_only') parser.set_defaults(__func__=WorkgroupDocumentsDeleteCommand(config)) # command : download parser = subparsers2.add_parser('download', help="download documents from linshare") add_download_parser_options(parser, 'complete_root_only') parser.set_defaults(__func__=WorkgroupDocumentsDownloadCommand(config)) # command : upload parser = subparsers2.add_parser('upload', help="upload documents to linshare") parser.add_argument('--desc', action="store", dest="description", required=False, help="Optional description.") parser.add_argument('files', nargs='+') parser.add_argument( '-f', '--folders', action="append", help="""The new files will be uploaded in the last folder in the list. Otherwise it will be create at the root of the workgroup""" ).completer = Completer() parser.set_defaults(__func__=WorkgroupDocumentsUploadCommand(config)) # command : create parser = subparsers2.add_parser('create', help="create a folder.") parser.add_argument('name', action="store", help="") parser.add_argument('--cli-mode', action="store_true", help="""Cli mode will format output to be used in a script, by returning only identifiers or numbers without any information messages.""") parser.add_argument( 'folders', nargs="*", help="""The new folder will be created in the last folder list. Otherwise it will be create at the root of the workgroup""" ).completer = Completer() parser.set_defaults(__func__=FolderCreateCommand(config)) # command : update parser = subparsers2.add_parser('update', help="update a folder.") parser.add_argument( 'nodes', nargs="*", help="Browse files and folders'content: node_uuid, node_uuid, ..." ).completer = Completer('complete_nodes') # parser.add_argument( 'uuid', action="store", help="") group = parser.add_argument_group('properties') group.add_argument('--name', action="store", help="") group.add_argument('--description', action="store", help="") group.add_argument('--meta-data', action="store", help=argparse.SUPPRESS) parser.add_argument('--cli-mode', action="store_true", help="""Cli mode will format output to be used in a script, by returning only identifiers or numbers without any information messages.""") parser.set_defaults(__func__=NodeUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """This method adds to the input subparser, all parsers for document methods""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : upload parser = subparsers2.add_parser('upload', help="upload documents to linshare") parser.add_argument('--desc', action="store", dest="description", required=False, help="Optional description.") parser.add_argument('files', nargs='+') parser.set_defaults(__func__=DocumentsUploadCommand(config)) # command : upshare parser = subparsers2.add_parser('upshare', help="upload and share documents") parser.add_argument('files', nargs='+') parser.add_argument('-m', '--mail', action="append", dest="mails", required=True, help="Recipient mails.").completer = Completer() parser.set_defaults(__func__=DocumentsUploadAndSharingCommand(config)) # command : download parser = subparsers2.add_parser('download', help="download documents from linshare") add_download_parser_options(parser) parser.set_defaults(__func__=DocumentsDownloadCommand(config)) # command : delete parser = subparsers2.add_parser('delete', help="delete documents from linshare") add_delete_parser_options(parser) parser.set_defaults(__func__=DocumentsDeleteCommand(config)) # command : list parser = subparsers2.add_parser('list', formatter_class=RawTextHelpFormatter, help="list documents from linshare") parser.add_argument('names', nargs="*", help="Filter documents by their names") # command : list : share action action_parser = add_list_parser_options(parser, download=True, delete=True, cdate=True, ssize=True)[3] action_parser.add_argument( '--share', action="store_true", dest="share", help="You can share all displayed files by the list command.") parser.set_defaults(__func__=DocumentsListCommand(config)) # command : list : share options share_group = parser.add_argument_group('Sharing options') share_group.add_argument('--expiration-date', action="store") share_group.add_argument('--secured', action="store_true", default=None) share_group.add_argument('--no-secured', action="store_false", default=None, dest="secured") share_group.add_argument('--message', action="store") share_group.add_argument('--subject', action="store") share_group.add_argument( '-m', '--mail', action="append", dest="mails", # required=True, help="Recipient (email).").completer = Completer("complete_mail") # command : update parser = subparsers2.add_parser('update', help="update document meta data.") parser.add_argument('uuid').completer = Completer() parser.add_argument('--name', action="store", help="document new name") parser.add_argument('--meta-data', action="store", help="document meta data") parser.add_argument('--description', action="store", help="document description") parser.add_argument('--file', dest='new_file') parser.set_defaults(__func__=DocumentsUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all welcome message sub commands.""" parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list welcome message.") parser.add_argument('identifiers', nargs="*", help="") add_list_parser_options(parser, delete=True, cdate=False) parser.add_argument('--detail', action="store_true", help="Display the whole content of a welcome message") parser.add_argument('--current-domain').completer = Completer( "complete_domain") parser.set_defaults(__func__=WelcomeMessagesListCommand(config)) # command : delete parser_tmp2 = subparsers2.add_parser('delete', help="delete welcome message.") add_delete_parser_options(parser_tmp2) parser_tmp2.add_argument('--current-domain').completer = Completer( "complete_domain") parser_tmp2.set_defaults(__func__=WelcomeMessagesDeleteCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser('create', help="create welcome message.") parser_tmp2.add_argument('uuid').completer = Completer() parser_tmp2.add_argument('name') parser_tmp2.add_argument('--domain').completer = Completer( "complete_domain") parser_tmp2.add_argument('--cli-mode', action="store_true", help="") parser_tmp2.set_defaults(__func__=WelcomeMessagesCreateCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser('update', help="update welcome message.") parser_tmp2.add_argument('identifier').completer = Completer() parser_tmp2.add_argument('name', action="store", help="") parser_tmp2.add_argument('--current-domain').completer = Completer( "complete_domain") parser_tmp2.set_defaults(__func__=WelcomeMessagesUpdateCommand(config)) # command : update-entry parser_tmp2 = subparsers2.add_parser( 'update-entry', help="update welcome message entries.") parser_tmp2.add_argument('identifier').completer = Completer() parser_tmp2.add_argument('--entry', choices=['ENGLISH', 'FRENCH', 'VIETNAMESE'], action="store", help="", required=True) parser_tmp2.add_argument('value', action="store", help="Payload for an entry.") parser_tmp2.add_argument( '--is-file', action="store_true", help= "If True, value attribute should contains the path to a file to load.") parser_tmp2.set_defaults(__func__=WelcomeMessagesUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all domain pattern sub commands.""" # pylint: disable=too-many-statements api_version = config.server.api_version.value parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list domain patterns.") parser.add_argument('identifiers', nargs="*", help="Filter domain patterns by their names") parser.add_argument('-m', '--model', action="store_true", help="show model of domain patterns") if api_version == 0: add_list_parser_options(parser) else: add_list_parser_options(parser, delete=True, cdate=False) parser.set_defaults(__func__=DomainPatternsListCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser('create', help="create domain pattern.") parser_tmp2.add_argument('--model', action="store", help="").completer = Completer() parser_tmp2.add_argument('--completion-page-size', action="store", type=int, help="") parser_tmp2.add_argument('--completion-size-limit', action="store", type=int, help="") parser_tmp2.add_argument('--search-page-size', action="store", type=int, help="") parser_tmp2.add_argument('--search-size-limit', action="store", type=int, help="") parser_tmp2.add_argument('--ldap-uid', action="store", help="") parser_tmp2.add_argument('--first-name', action="store", help="") parser_tmp2.add_argument('--last-name', action="store", help="") parser_tmp2.add_argument('--mail', action="store", help="") parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.add_argument('--auth-command', action="store", help="") parser_tmp2.add_argument('--search-user-command', action="store", help="") parser_tmp2.add_argument('--auto-complete-command-on-all-attributes', action="store", help="") parser_tmp2.add_argument('--auto-complete-command-on-first-and-last-name', action="store", help="") parser_tmp2.add_argument('--cli-mode', action="store_true", help="") if api_version == 0: parser_tmp2.add_argument('identifier', action="store", help="") parser_tmp2.set_defaults(__func__=DomainPatternsCreateCommand(config)) else: parser_tmp2.add_argument('label', action="store", help="") parser_tmp2.set_defaults(__func__=DomainPatternsCreateCommand2(config)) # command : delete parser_tmp2 = subparsers2.add_parser('delete', help="delete domain pattern.") if api_version == 0: parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() else: add_delete_parser_options(parser_tmp2) parser_tmp2.set_defaults(__func__=DomainPatternsDeleteCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser('update', help="update domain patterns.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument('--completion-page-size', action="store", type=int, help="") parser_tmp2.add_argument('--completion-size-limit', action="store", type=int, help="") parser_tmp2.add_argument('--search-page-size', action="store", type=int, help="") parser_tmp2.add_argument('--search-size-limit', action="store", type=int, help="") parser_tmp2.add_argument('--ldap-uid', action="store", help="") parser_tmp2.add_argument('--first-name', action="store", help="") parser_tmp2.add_argument('--last-name', action="store", help="") parser_tmp2.add_argument('--mail', action="store", help="") parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.add_argument('--model', action="store", help="").completer = Completer() parser_tmp2.add_argument('--auth-command', action="store", help="") parser_tmp2.add_argument('--search-user-command', action="store", help="") parser_tmp2.add_argument('--auto-complete-command-on-all-attributes', action="store", help="") parser_tmp2.add_argument('--auto-complete-command-on-first-and-last-name', action="store", help="") parser_tmp2.set_defaults(__func__=DomainPatternsUpdateCommand(config))
def add_parser(subparsers, name, desc, config): """Add all domain sub commands.""" # pylint: disable=too-many-statements parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() # command : list parser = subparsers2.add_parser('list', help="list functionalities.") parser.add_argument('identifiers', nargs="*") parser.add_argument('-d', '--domain', action="store", help="").completer = Completer('complete_domain') groups = add_list_parser_options(parser) # groups : filter_group, sort_group, format_group, actions_group actions_group = groups[3] actions_group.add_argument('--dry-run', action="store_true") filter_group = groups[0] filter_group.add_argument('--type', action="append", dest="funct_type", help="Filter on functionality type") filter_group.add_argument( '--sub-funcs', action="store_true", help="Sub functionalities will not be displayed, since core 1.7") sort_group = groups[1] sort_group.add_argument('--sort-type', action="store_true", help="Sort functionalities by type") add_update_parser(parser, required=False) parser.set_defaults(__func__=FunctionalityListCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser('update', help="update a functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('--dry-run', action="store_true") add_update_parser(parser_tmp2) parser_tmp2.set_defaults(__func__=FunctionalityUpdateCommand(config)) # command : update-str parser_tmp2 = subparsers2.add_parser('update-str', help="update STRING functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('string', help="string value", action="store") parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults(__func__=FunctionalityUpdateStringCommand(config)) # command : update-int parser_tmp2 = subparsers2.add_parser('update-int', help="update INTEGER functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('integer', type=int, help="integer value", action="store") parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults( __func__=FunctionalityUpdateIntegerCommand(config)) # command : update-bool parser_tmp2 = subparsers2.add_parser('update-bool', help="update BOOLEAN functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') status_group = parser_tmp2.add_argument_group('Boolean value') group = status_group.add_mutually_exclusive_group(required=True) group.add_argument('--disable', action="store_false", dest="boolean") group.add_argument('--enable', action="store_true", dest="boolean") parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults( __func__=FunctionalityUpdateBooleanCommand(config)) # command : update-lang parser_tmp2 = subparsers2.add_parser('update-lang', help="update language functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('-l', '--lang', action="store", choices=('EN', 'FR')) parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults(__func__=FunctionalityUpdateLangCommand(config)) # command : update-time parser_tmp2 = subparsers2.add_parser('update-time', help="update UNIT functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('value', type=int, help="time value", action="store") parser_tmp2.add_argument('-u', '--unit', action="store", choices=('DAY', 'WEEK', 'MONTH')) parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults(__func__=FunctionalityUpdateTimeCommand(config)) # command : update-size parser_tmp2 = subparsers2.add_parser('update-size', help="update UNIT functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument( '-d', '--domain', action="store", help="Completion available").completer = Completer('complete_domain') parser_tmp2.add_argument('value', type=int, help="size value", action="store") parser_tmp2.add_argument('-u', '--unit', action="store", choices=('KILO', 'MEGA', 'GIGA')) parser_tmp2.add_argument('--dry-run', action="store_true") parser_tmp2.set_defaults(__func__=FunctionalityUpdateSizeCommand(config)) # command : reset parser_tmp2 = subparsers2.add_parser('reset', help="reset a functionality.") parser_tmp2.add_argument('identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument('domain', action="store", help="").completer = Completer('complete_domain') parser_tmp2.set_defaults(__func__=FunctionalityResetCommand(config))
def add_parser(subparsers, name, desc, config): """Add all domain sub commands.""" # pylint: disable=too-many-statements parser_tmp = subparsers.add_parser(name, help=desc) subparsers2 = parser_tmp.add_subparsers() api_version = config.server.api_version.value # command : list parser = subparsers2.add_parser( 'list', help="list domains") parser.add_argument( 'identifiers', nargs="*", help="Filter domains by their identifiers") parser.add_argument('-n', '--label', action="store_true", help="sort by domain label") if api_version == 0: add_list_parser_options(parser, delete=True, cdate=False) else: add_list_parser_options(parser, delete=True, cdate=False) parser.set_defaults(__func__=DomainsListCommand(config)) # command : create parser_tmp2 = subparsers2.add_parser( 'create', help="create domain.") parser_tmp2.add_argument('--label', action="store", help="") parser_tmp2.add_argument('identifier', action="store", help="") parser_tmp2.add_argument( '--type', dest="domain_type", action="store", help="", required=True).completer = Completer("complete_type") parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.add_argument( '--role', dest="role", action="store", help="").completer = Completer("complete_role") parser_tmp2.add_argument( '--language', dest="language", action="store", help="").completer = Completer("complete_language") parser_tmp2.add_argument( '--parent', dest="parent_id", action="store", help="TODO").completer = Completer() parser_tmp2.add_argument( '--mime-policy', dest="mime_policy", action="store", help="TODO").completer = Completer("complete_mime") parser_tmp2.add_argument( '--domain-policy', dest="domain_policy", action="store", help="TODO").completer = Completer("complete_policy") parser_tmp2.add_argument( '--mail-config', dest="mail_config", action="store", help="TODO").completer = Completer("complete_mail") parser_tmp2.add_argument('--cli-mode', action="store_true", help="") parser_tmp2.set_defaults(__func__=DomainsCreateCommand(config)) # command : update parser_tmp2 = subparsers2.add_parser( 'update', help="update domain.") parser_tmp2.add_argument( 'identifier', action="store", help="").completer = Completer() parser_tmp2.add_argument('--label', action="store", help="") parser_tmp2.add_argument('--description', action="store", help="") parser_tmp2.add_argument( '--role', dest="role", action="store", help="").completer = Completer("complete_role") parser_tmp2.add_argument( '--language', dest="language", action="store", help="").completer = Completer("complete_language") if api_version >= 1: parser_tmp2.add_argument( '--mail-language', dest="external_mail_locale", action="store", help="").completer = Completer("complete_mail_language") parser_tmp2.add_argument( '--welcome', dest="current_welcome_message", action="store", help="welcome message identifier").completer = Completer( "complete_welcome") parser_tmp2.set_defaults(__func__=DomainsUpdateCommand(config)) # command : delete parser_tmp2 = subparsers2.add_parser( 'delete', help="delete domain.") if api_version == 0: parser_tmp2.add_argument( 'identifier', action="store", help="").completer = Completer() else: add_delete_parser_options(parser_tmp2) parser_tmp2.set_defaults(__func__=DomainsDeleteCommand(config)) # command : set provider parser_tmp2 = subparsers2.add_parser( 'setup', help="configure user provider.") parser_tmp2.add_argument( 'identifier', action="store", help="domain identifier").completer = Completer() parser_tmp2.add_argument('--basedn', action="store", help="", required=True) parser_tmp2.add_argument( '--ldap', dest="ldap", action="store", help="ldap identifier", required=True).completer = Completer("complete_ldap") parser_tmp2.add_argument( '--dpattern', dest="dpattern", action="store", help="domain pattern identifier", required=True).completer = Completer("complete_dpattern") parser_tmp2.set_defaults(__func__=DomainProvidersCreateCommand(config)) # command : update provider parser_tmp2 = subparsers2.add_parser( 'updateup', help="update user provider.") parser_tmp2.add_argument( 'identifier', action="store", help="domain identifier").completer = Completer() parser_tmp2.add_argument('--basedn', action="store", help="") parser_tmp2.add_argument( '--ldap', dest="ldap", action="store", help="ldap identifier").completer = Completer("complete_ldap") parser_tmp2.add_argument( '--dpattern', dest="dpattern", action="store", help="domain pattern identifier").completer = Completer( "complete_dpattern") parser_tmp2.set_defaults(__func__=DomainProvidersUpdateCommand(config)) # command : del provider parser_tmp2 = subparsers2.add_parser( 'cleanup', help="clean user provider.") parser_tmp2.add_argument( 'identifier', action="store", help="domain identifier").completer = Completer() parser_tmp2.set_defaults(__func__=DomainProvidersDeleteCommand(config))
def add_list_parser_options(parser, download=False, delete=False, cdate=False, ssize=False): """Add default argparse options for all ListCommands.""" # filters filter_group = parser.add_argument_group('Filters') filter_group.add_argument( '--start', action="store", type=int, default=0, help="Print all left rows after the first n rows.") filter_group.add_argument('--end', action="store", type=int, default=0, help="Print the last n rows.") filter_group.add_argument('--limit', action="store", type=int, default=0, help="Used to limit the number of row to print.") if cdate: filter_group.add_argument('--date', action="store", dest="cdate", help="Filter on creation date") filter_group.add_argument( '-k', '--field', action='append', dest="fields").completer = Completer("complete_fields") # sort sort_group = parser.add_argument_group('Sort') sort_group.add_argument('-r', '--reverse', action="store_true", help="Reverse order while sorting") sort_group.add_argument('--sort-by', action="store", default=None, help="Sort by column.") sort_group.add_argument('--sort-name', action="store_true", help="Sort by name") if ssize: sort_group.add_argument('--sort-size', action="store_true", help="Sort by size") format_group = add_list_parser_options_format(parser) # actions actions_group = parser.add_argument_group('Actions') download_group = parser.add_argument_group('Downloading options') actions_group.add_argument( '-c', '--count', action="store_true", dest="count_only", help="Just display number of results instead of results.") if download or delete: if download: download_group.add_argument('-o', '--output-dir', action="store", dest="directory") download_group.add_argument('--no-progress', action="store_true", help="disable progress bar.", default=False) if download and delete: group = actions_group.add_mutually_exclusive_group() if download: group.add_argument('-d', '--download', action="store_true") if delete: group.add_argument('-D', '--delete', action="store_true") else: if download: actions_group.add_argument('-o', '--output-dir', action="store", dest="directory") actions_group.add_argument('-d', '--download', action="store_true") if delete: actions_group.add_argument('-D', '--delete', action="store_true") actions_group.add_argument('--dry-run', action="store_true") return filter_group, sort_group, format_group, actions_group