-
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(project): adds project features sub-command
The features subcommand will allow toggling features on a project Usage: rio project features [OPTIONS] COMMAND [ARGS]... Toggle features on a project Options: --help Show this message and exit. Commands: vpn Enable or disable VPN on a project VPN is the first feature included in this commmit.
- Loading branch information
1 parent
b5ca2b4
commit 981dc3a
Showing
3 changed files
with
84 additions
and
0 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
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,33 @@ | ||
# 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 HelpColorsGroup | ||
|
||
from riocli.project.features.vpn import vpn | ||
|
||
|
||
@click.group( | ||
invoke_without_command=False, | ||
cls=HelpColorsGroup, | ||
help_headers_color='yellow', | ||
help_options_color='green', | ||
) | ||
def features(): | ||
""" | ||
Toggle features on a project | ||
""" | ||
pass | ||
|
||
|
||
features.add_command(vpn) |
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 riocli.config import new_v2_client | ||
from riocli.project.util import name_to_guid | ||
|
||
|
||
@click.command('vpn') | ||
@click.argument('project-name', type=str) | ||
@click.argument('enable', type=bool) | ||
@name_to_guid | ||
def vpn(project_name: str, project_guid: str, enable: bool) -> None: | ||
""" | ||
Enable or disable VPN on a project | ||
Example: rio project features vpn "my-project" true | ||
""" | ||
client = new_v2_client(with_project=False) | ||
|
||
body = { | ||
"metadata": { | ||
"projectGUID": project_guid | ||
}, | ||
"spec": { | ||
"features": { | ||
"vpn": enable | ||
} | ||
} | ||
} | ||
|
||
try: | ||
r = client.update_project(project_guid, body) | ||
except Exception as e: | ||
click.secho("❌ Failed: {}".format(e), fg='red') | ||
raise SystemExit(1) from e | ||
|
||
click.secho("✅ VPN has been {}".format("enabled" if enable else "disabled"), fg='green') |