-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(organization): adds command to invite user
- Loading branch information
1 parent
baa823d
commit b99fb5f
Showing
6 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Copyright 2023 Rapyuta Robotics | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import click | ||
from click_help_colors import HelpColorsCommand | ||
from email_validator import EmailNotValidError, validate_email | ||
|
||
from riocli.constants import Colors, Symbols | ||
from riocli.organization.utils import invite_user_to_org | ||
from riocli.utils.context import get_root_context | ||
|
||
|
||
@click.command( | ||
'invite-user', | ||
cls=HelpColorsCommand, | ||
help_headers_color=Colors.YELLOW, | ||
help_options_color=Colors.GREEN, | ||
) | ||
@click.argument('user-email', type=str) | ||
@click.pass_context | ||
def invite_user(ctx: click.Context, user_email: str) -> None: | ||
""" | ||
Invite a new user to the current organization | ||
""" | ||
ctx = get_root_context(ctx) | ||
|
||
try: | ||
validate_email(user_email) | ||
except EmailNotValidError as e: | ||
click.secho('{} {} is not a valid email address'.format(Symbols.ERROR, user_email), fg=Colors.RED) | ||
raise SystemExit(1) from e | ||
|
||
try: | ||
invite_user_to_org(ctx.obj.data['organization_id'], user_email) | ||
click.secho('{} User invited successfully.'.format(Symbols.SUCCESS), fg=Colors.GREEN) | ||
except Exception as e: | ||
click.secho('{} Failed to invite user: {}'.format(Symbols.ERROR, e), fg=Colors.RED) | ||
raise SystemExit(1) from e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters