mostr-zulip-bot/zulip/zulip/examples/create-user
Anders Kaseorg e30b3b094b Modernize legacy Python 2 syntax with pyupgrade.
Generated by `pyupgrade --py3-plus --keep-percent-format` followed by
manual indentation fixes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-04-18 15:04:36 -07:00

31 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python3
import argparse
usage = """create-user --new-email=<email address> --new-password=<password> --new-full-name=<full name> --new-short-name=<short name> [options]
Create a user. You must be a realm admin to use this API, and the user
will be created in your realm.
Example: create-user --new-email=jarthur@example.com --new-password=random17 --new-full-name 'J. Arthur Random' --new-short-name='jarthur'
Specify your Zulip API credentials and server in a ~/.zuliprc file or using the options.
"""
import zulip
parser = zulip.add_default_arguments(argparse.ArgumentParser(usage=usage))
parser.add_argument('--new-email', required=True)
parser.add_argument('--new-password', required=True)
parser.add_argument('--new-full-name', required=True)
parser.add_argument('--new-short-name', required=True)
options = parser.parse_args()
client = zulip.init_from_options(options)
print(client.create_user({
'email': options.new_email,
'password': options.new_password,
'full_name': options.new_full_name,
'short_name': options.new_short_name
}))