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
d2314e04
Unverified
Commit
d2314e04
authored
Dec 05, 2024
by
Jakob Görgen
Browse files
client/simbricks/client/client: added admin client
parent
7b6f7fd1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
symphony/client/simbricks/client/__init__.py
symphony/client/simbricks/client/__init__.py
+1
-1
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+29
-2
No files found.
symphony/client/simbricks/client/__init__.py
View file @
d2314e04
...
@@ -20,4 +20,4 @@
...
@@ -20,4 +20,4 @@
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
from
.client
import
BaseClient
,
NSClient
,
SimBricksClient
,
RunnerClient
from
.client
import
BaseClient
,
AdminClient
,
NSClient
,
SimBricksClient
,
RunnerClient
symphony/client/simbricks/client/client.py
View file @
d2314e04
...
@@ -107,11 +107,38 @@ class BaseClient:
...
@@ -107,11 +107,38 @@ class BaseClient:
return
await
resp
.
json
()
return
await
resp
.
json
()
class
AdminClient
:
def
__init__
(
self
,
base_client
:
BaseClient
=
BaseClient
()):
self
.
_base_client
=
base_client
def
_prefix
(
self
,
url
:
str
)
->
str
:
return
f
"/admin
{
url
}
"
async
def
get_ns
(
self
,
ns_id
:
int
):
async
with
self
.
_base_client
.
get
(
url
=
self
.
_prefix
(
f
"/
{
ns_id
}
"
))
as
resp
:
return
await
resp
.
json
()
async
def
get_all_ns
(
self
):
async
with
self
.
_base_client
.
get
(
url
=
self
.
_prefix
(
"/"
))
as
resp
:
return
await
resp
.
json
()
async
def
create_ns
(
self
,
parent_id
:
int
|
None
,
name
:
str
):
namespace_json
=
{
"name"
:
name
}
if
parent_id
:
namespace_json
[
"parent_id"
]
=
parent_id
async
with
self
.
_base_client
.
post
(
url
=
self
.
_prefix
(
"/"
),
json
=
namespace_json
)
as
resp
:
return
await
resp
.
json
()
async
def
delete
(
self
,
ns_id
:
int
):
async
with
self
.
_base_client
.
delete
(
url
=
self
.
_prefix
(
f
"/
{
ns_id
}
"
))
as
resp
:
return
await
resp
.
json
()
class
NSClient
:
class
NSClient
:
def
__init__
(
self
,
base_client
:
BaseClient
=
BaseClient
(),
namespace
:
str
=
""
):
def
__init__
(
self
,
base_client
:
BaseClient
=
BaseClient
(),
namespace
:
str
=
""
):
self
.
_base_client
:
BaseClient
=
base_client
self
.
_base_client
:
BaseClient
=
base_client
self
.
_namespace
=
namespace
self
.
_namespace
=
namespace
self
.
_session
:
aiohttp
.
ClientSession
|
None
=
None
def
_build_ns_prefix
(
self
,
url
:
str
)
->
str
:
def
_build_ns_prefix
(
self
,
url
:
str
)
->
str
:
return
f
"/ns/
{
self
.
_namespace
}
/-
{
url
}
"
return
f
"/ns/
{
self
.
_namespace
}
/-
{
url
}
"
...
@@ -226,7 +253,7 @@ class SimBricksClient:
...
@@ -226,7 +253,7 @@ class SimBricksClient:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/runs/
{
run_id
}
"
)
as
resp
:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/runs/
{
run_id
}
"
)
as
resp
:
return
await
resp
.
json
()
return
await
resp
.
json
()
async
def
get_runs
(
self
)
->
[
dict
]:
async
def
get_runs
(
self
)
->
list
[
dict
]:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/runs"
)
as
resp
:
async
with
self
.
_ns_client
.
get
(
url
=
f
"/runs"
)
as
resp
:
return
await
resp
.
json
()
return
await
resp
.
json
()
...
...
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