Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
24c9aa30
Unverified
Commit
24c9aa30
authored
Jan 01, 2025
by
Antoine Kaufmann
Browse files
symphony/cli: add member list and add commands
parent
8265acfe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
1 deletion
+33
-1
symphony/cli/simbricks/cli/commands/namespaces.py
symphony/cli/simbricks/cli/commands/namespaces.py
+21
-1
symphony/cli/simbricks/cli/utils.py
symphony/cli/simbricks/cli/utils.py
+12
-0
No files found.
symphony/cli/simbricks/cli/commands/namespaces.py
View file @
24c9aa30
...
...
@@ -22,7 +22,7 @@
from
typer
import
Typer
from
..state
import
state
from
..utils
import
async_cli
,
print_namespace_table
from
..utils
import
async_cli
,
print_namespace_table
,
print_members_table
app
=
Typer
(
help
=
"Managing SimBricks namespaces."
)
...
...
@@ -83,3 +83,23 @@ async def delete(ident: int):
client
=
state
.
ns_client
await
client
.
delete_ns
(
ident
)
print
(
f
"Deleted namespace with id
{
ident
}
."
)
@
app
.
command
()
@
async_cli
()
async
def
members
():
"""List all members."""
client
=
state
.
ns_client
members
=
await
client
.
get_members
()
print_members_table
(
members
)
@
app
.
command
()
@
async_cli
()
async
def
member_add
(
user
:
str
,
role
:
str
):
"""Add member to namespace."""
client
=
state
.
ns_client
members
=
await
client
.
add_member
(
role
,
user
)
print
(
f
"Added user
{
user
}
with role
{
role
}
."
)
\ No newline at end of file
symphony/cli/simbricks/cli/utils.py
View file @
24c9aa30
...
...
@@ -99,3 +99,15 @@ def print_runner_table(runners):
console
=
Console
()
console
.
print
(
table
)
def
print_members_table
(
members
:
dict
[
str
,
list
[
dict
]]):
table
=
Table
()
table
.
add_column
(
"Role"
)
table
.
add_column
(
"User"
)
table
.
add_column
(
"First"
)
table
.
add_column
(
"Last"
)
for
r
,
ms
in
members
.
items
():
for
m
in
ms
:
table
.
add_row
(
r
,
m
[
'username'
],
m
[
'first_name'
],
m
[
'last_name'
])
console
=
Console
()
console
.
print
(
table
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment