forked from ISPsystem/isp-maintenance
Compare commits
No commits in common. "d4de07c34056ba759b6f9b6925260ca1dd65b50a" and "f773898b71b192753f89f8a5f8405b78e3011a39" have entirely different histories.
d4de07c340
...
f773898b71
@ -1,10 +0,0 @@
|
|||||||
# █▀▄▀█ █▀▀ ▀█▀ ▄▀█ ▀
|
|
||||||
# █░▀░█ ██▄ ░█░ █▀█ ▄
|
|
||||||
# -- -- -- -- -- -- -
|
|
||||||
__author__ = "MOIS3Y"
|
|
||||||
__credits__ = ["Stepan Zhukovsky"]
|
|
||||||
__license__ = "MIT"
|
|
||||||
__version__ = "0.1.0"
|
|
||||||
__maintainer__ = "Stepan Zhukovsky"
|
|
||||||
__email__ = "stepan@zhukovsky.me"
|
|
||||||
__status__ = "Development"
|
|
@ -1,99 +1,12 @@
|
|||||||
import click
|
import click
|
||||||
|
|
||||||
from mgrctl.apps.dci6.auth import __version__
|
|
||||||
from mgrctl.api.dci6 import AuthAPI
|
@click.group(help='access command for lazy example')
|
||||||
from mgrctl.utils.api_users import UserAPI
|
@click.option('--debug/--no-debug', default=False)
|
||||||
|
def cli(debug):
|
||||||
|
click.echo(f"Debug mode is {'on' if debug else 'off'}")
|
||||||
|
|
||||||
|
|
||||||
user_cursor = UserAPI(callback_class=AuthAPI)
|
@cli.command()
|
||||||
|
def enable():
|
||||||
|
click.echo('Access granted')
|
||||||
@click.group(help='auth cmd for auth in DCImanager 6')
|
|
||||||
@click.version_option(
|
|
||||||
version=__version__,
|
|
||||||
package_name='mgrctl.apps.dci6.auth',
|
|
||||||
message=__version__
|
|
||||||
)
|
|
||||||
def cli():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@cli.group(help='Manage users')
|
|
||||||
def user():
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
@user.command(help='List users')
|
|
||||||
@click.option(
|
|
||||||
'--all',
|
|
||||||
is_flag=True,
|
|
||||||
required=False,
|
|
||||||
help='Show all users'
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
'--admins',
|
|
||||||
is_flag=True,
|
|
||||||
required=False,
|
|
||||||
help='Show all active admins',
|
|
||||||
)
|
|
||||||
def ls(all, admins):
|
|
||||||
if all:
|
|
||||||
users = user_cursor.get_users(role='all')
|
|
||||||
elif admins:
|
|
||||||
users = user_cursor.get_users(role='admin')
|
|
||||||
else:
|
|
||||||
users = user_cursor.get_users(role='all')
|
|
||||||
# print users:
|
|
||||||
user_cursor.echo_users(users)
|
|
||||||
|
|
||||||
|
|
||||||
@user.command(
|
|
||||||
help='Generate an access key and return auth link(s)',
|
|
||||||
no_args_is_help=True
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
'--id',
|
|
||||||
'_id',
|
|
||||||
required=False,
|
|
||||||
type=int,
|
|
||||||
help='User id'
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
'--count',
|
|
||||||
required=False,
|
|
||||||
type=int,
|
|
||||||
help='Number of access keys generated',
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
'--random',
|
|
||||||
is_flag=True,
|
|
||||||
required=False,
|
|
||||||
help='Generate access key for the first available admin'
|
|
||||||
)
|
|
||||||
@click.option(
|
|
||||||
'--interactive',
|
|
||||||
is_flag=True,
|
|
||||||
required=False,
|
|
||||||
help='Interactive mode, ignores other keys'
|
|
||||||
)
|
|
||||||
def access(_id, count, interactive, random):
|
|
||||||
if _id and not count:
|
|
||||||
keys = user_cursor.get_access_keys(user=_id, count=1)
|
|
||||||
elif _id and count:
|
|
||||||
keys = user_cursor.get_access_keys(user=_id, count=count)
|
|
||||||
elif random:
|
|
||||||
admin = user_cursor.get_first_random_admin()
|
|
||||||
keys = user_cursor.get_access_keys(user=admin.get('id', 3))
|
|
||||||
elif interactive:
|
|
||||||
user_cursor.gen_access_links_interactive()
|
|
||||||
return # exit from func
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
links = user_cursor.gen_access_links(keys)
|
|
||||||
user_cursor.echo_access_links(links)
|
|
||||||
|
|
||||||
|
|
||||||
@user.command(help='Generate API token for mgrctl user')
|
|
||||||
def token():
|
|
||||||
token = user_cursor.gen_api_token()
|
|
||||||
user_cursor.echo_api_token(token)
|
|
||||||
|
@ -7,7 +7,7 @@ from mgrctl.settings.general import INSTALLED_APPS
|
|||||||
@click.group(
|
@click.group(
|
||||||
cls=LazyGroup,
|
cls=LazyGroup,
|
||||||
lazy_subcommands=INSTALLED_APPS['dci6'],
|
lazy_subcommands=INSTALLED_APPS['dci6'],
|
||||||
help='dci6 command for DCI6manager management',
|
help='dci6 command for lazy example',
|
||||||
)
|
)
|
||||||
def cli():
|
def cli():
|
||||||
pass
|
pass
|
||||||
|
@ -8,7 +8,7 @@ from mgrctl.apps.vm6 import __version__
|
|||||||
@click.group(
|
@click.group(
|
||||||
cls=LazyGroup,
|
cls=LazyGroup,
|
||||||
lazy_subcommands=INSTALLED_APPS['vm6'],
|
lazy_subcommands=INSTALLED_APPS['vm6'],
|
||||||
help='vm6 command for VM6manager management',
|
help='vm6 command for lazy example',
|
||||||
)
|
)
|
||||||
@click.version_option(
|
@click.version_option(
|
||||||
version=__version__,
|
version=__version__,
|
||||||
|
@ -17,7 +17,7 @@ from mgrctl.cli.lazy_group import LazyGroup
|
|||||||
'vm6': 'mgrctl.apps.vm6.commands.cli',
|
'vm6': 'mgrctl.apps.vm6.commands.cli',
|
||||||
'dci6': 'mgrctl.apps.dci6.commands.cli',
|
'dci6': 'mgrctl.apps.dci6.commands.cli',
|
||||||
},
|
},
|
||||||
help='main CLI command for mgrctl app',
|
help='main CLI command for lazy example',
|
||||||
)
|
)
|
||||||
@click.version_option(
|
@click.version_option(
|
||||||
version=__version__,
|
version=__version__,
|
||||||
|
Loading…
Reference in New Issue
Block a user