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
d649a21a
Unverified
Commit
d649a21a
authored
Jan 22, 2025
by
Antoine Kaufmann
Browse files
symphony/client: add organization client
parent
a73072a9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletion
+43
-1
symphony/client/simbricks/client/client.py
symphony/client/simbricks/client/client.py
+35
-0
symphony/client/simbricks/client/provider.py
symphony/client/simbricks/client/provider.py
+8
-1
No files found.
symphony/client/simbricks/client/client.py
View file @
d649a21a
...
@@ -168,6 +168,41 @@ class AdminClient:
...
@@ -168,6 +168,41 @@ class AdminClient:
return
await
resp
.
json
()
return
await
resp
.
json
()
class
OrgClient
:
def
__init__
(
self
,
base_client
:
BaseClient
=
BaseClient
()):
self
.
_base_client
=
base_client
def
_prefix
(
self
,
org
:
str
,
url
:
str
)
->
str
:
return
f
"/org/
{
org
}{
url
}
"
async
def
get_members
(
self
,
org
:
str
):
async
with
self
.
_base_client
.
get
(
url
=
self
.
_prefix
(
org
,
f
"/members"
))
as
resp
:
return
await
resp
.
json
()
async
def
invite_member
(
self
,
org
:
str
,
email
:
str
,
first_name
:
str
,
last_name
:
str
):
namespace_json
=
{
"email"
:
email
,
"first_name"
:
first_name
,
"last_name"
:
last_name
,
}
async
with
self
.
_base_client
.
post
(
url
=
self
.
_prefix
(
org
,
"/invite-member"
),
json
=
namespace_json
)
as
resp
:
await
resp
.
json
()
async
def
create_guest
(
self
,
org
:
str
,
email
:
str
,
first_name
:
str
,
last_name
:
str
):
namespace_json
=
{
"email"
:
email
,
"first_name"
:
first_name
,
"last_name"
:
last_name
,
}
async
with
self
.
_base_client
.
post
(
url
=
self
.
_prefix
(
org
,
"/create-guest"
),
json
=
namespace_json
)
as
resp
:
j
=
await
resp
.
json
()
print
(
j
)
return
await
j
[
"magic_link"
]
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
...
...
symphony/client/simbricks/client/provider.py
View file @
d649a21a
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
# 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
,
AdminClient
,
NSClient
,
SimBricksClient
,
RunnerClient
,
ResourceGroupClient
from
.client
import
BaseClient
,
AdminClient
,
OrgClient
,
NSClient
,
SimBricksClient
,
RunnerClient
,
ResourceGroupClient
from
.settings
import
client_settings
from
.settings
import
client_settings
...
@@ -30,6 +30,7 @@ class ClientProvider:
...
@@ -30,6 +30,7 @@ class ClientProvider:
self
.
runner_id
:
int
=
runner_id
self
.
runner_id
:
int
=
runner_id
self
.
_base_client
:
BaseClient
|
None
=
None
self
.
_base_client
:
BaseClient
|
None
=
None
self
.
_admin_client
:
AdminClient
=
None
self
.
_admin_client
:
AdminClient
=
None
self
.
_org_client
:
OrgClient
=
None
self
.
_ns_client
:
NSClient
|
None
=
None
self
.
_ns_client
:
NSClient
|
None
=
None
self
.
_simbricks_client
:
SimBricksClient
|
None
=
None
self
.
_simbricks_client
:
SimBricksClient
|
None
=
None
self
.
_runner_client
:
RunnerClient
|
None
=
None
self
.
_runner_client
:
RunnerClient
|
None
=
None
...
@@ -47,6 +48,12 @@ class ClientProvider:
...
@@ -47,6 +48,12 @@ class ClientProvider:
self
.
_admin_client
=
AdminClient
(
base_client
=
self
.
base_client
)
self
.
_admin_client
=
AdminClient
(
base_client
=
self
.
base_client
)
return
self
.
_admin_client
return
self
.
_admin_client
@
property
def
org_client
(
self
)
->
OrgClient
:
if
self
.
_org_client
is
None
:
self
.
_org_client
=
OrgClient
(
base_client
=
self
.
base_client
)
return
self
.
_org_client
@
property
@
property
def
ns_client
(
self
)
->
NSClient
:
def
ns_client
(
self
)
->
NSClient
:
if
self
.
_ns_client
is
None
:
if
self
.
_ns_client
is
None
:
...
...
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