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
7b6f7fd1
Unverified
Commit
7b6f7fd1
authored
Dec 03, 2024
by
Jakob Görgen
Browse files
client + cli : added functions to delete namespaces
parent
f8c67ccc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
symphony/cli/simbricks/cli/commands/namespaces.py
symphony/cli/simbricks/cli/commands/namespaces.py
+10
-0
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+15
-0
No files found.
symphony/cli/simbricks/cli/commands/namespaces.py
View file @
7b6f7fd1
...
...
@@ -89,3 +89,13 @@ async def create(name: str):
ns_id
=
namespace
[
"id"
]
print
(
f
"Creating namespace
{
name
}
in
{
state
.
namespace
}
. New namespace:
{
ns_id
}
"
)
@
app
.
command
()
@
async_cli
()
async
def
delete
(
ident
:
int
):
"""Delete a namespace."""
client
=
state
.
ns_client
()
await
client
.
delete
(
ident
)
print
(
f
"Deleted namespace with id
{
ident
}
."
)
symphony/client/simbricks/client/client.py
View file @
7b6f7fd1
...
...
@@ -91,6 +91,17 @@ class BaseClient:
resp
.
raise_for_status
()
# TODO: handel gracefully
yield
resp
@
contextlib
.
asynccontextmanager
async
def
delete
(
self
,
url
:
str
,
**
kwargs
:
typing
.
Any
)
->
typing
.
AsyncIterator
[
aiohttp
.
ClientResponse
]:
url
=
f
"
{
self
.
_base_url
}{
url
}
"
async
with
self
.
session
()
as
session
:
async
with
session
.
delete
(
url
=
url
,
**
kwargs
)
as
resp
:
# TODO: handel connection error
print
(
await
resp
.
text
())
resp
.
raise_for_status
()
# TODO: handel gracefully
yield
resp
async
def
info
(
self
):
async
with
self
.
get
(
url
=
"/info"
)
as
resp
:
return
await
resp
.
json
()
...
...
@@ -136,6 +147,10 @@ class NSClient:
async
with
self
.
post
(
url
=
"/"
,
json
=
namespace_json
)
as
resp
:
return
await
resp
.
json
()
async
def
delete
(
self
,
ns_id
:
int
):
async
with
self
.
_base_client
.
delete
(
url
=
self
.
_build_ns_prefix
(
f
"/
{
ns_id
}
"
))
as
_
:
return
# retrieve namespace ns_id, useful for retrieving a child the current namespace
async
def
get_ns
(
self
,
ns_id
:
int
):
async
with
self
.
get
(
url
=
f
"/one/
{
ns_id
}
"
)
as
resp
:
...
...
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