From c0f6cae8d61328328b6989b5d938b9ee053bdd93 Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Fri, 21 Feb 2025 10:56:08 +0100 Subject: [PATCH 1/2] fix create org --- arlas/cli/org.py | 2 +- arlas/cli/service.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arlas/cli/org.py b/arlas/cli/org.py index ad0dafd..506a1cf 100644 --- a/arlas/cli/org.py +++ b/arlas/cli/org.py @@ -25,7 +25,7 @@ def create_organisation(organisation: str = typer.Argument(default="", help="Org if organisation: print(Service.create_organisation(config, organisation).get("id")) else: - print(Service.create_organisation_from_user_domain(config, organisation).get("id")) + print(Service.create_organisation_from_user_domain(config).get("id")) @org.command(help="Delete the organisation", name="delete", epilog=variables["help_epilog"]) diff --git a/arlas/cli/service.py b/arlas/cli/service.py index 3628014..4e535e7 100644 --- a/arlas/cli/service.py +++ b/arlas/cli/service.py @@ -115,7 +115,7 @@ def create_organisation(arlas: str, org: str): return Service.__arlas__(arlas, "/".join(["organisations", org]), post="{}", service=Services.iam) @staticmethod - def create_organisation_from_user_domain(arlas: str, org: str): + def create_organisation_from_user_domain(arlas: str): return Service.__arlas__(arlas, "organisations", post="{}", service=Services.iam) @staticmethod From 9a5bb4cb6e243b2570a3d81e90474f7616d9c03d Mon Sep 17 00:00:00 2001 From: Sylvain Gaudan Date: Fri, 21 Feb 2025 15:45:54 +0100 Subject: [PATCH 2/2] fix add remove group to user --- arlas/cli/org.py | 8 ++++---- arlas/cli/service.py | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/arlas/cli/org.py b/arlas/cli/org.py index 506a1cf..a2e8593 100644 --- a/arlas/cli/org.py +++ b/arlas/cli/org.py @@ -144,15 +144,15 @@ def add_user_to_group(org_id: str = typer.Argument(help="Organisation's identifi user_id: str = typer.Argument(help="User identifier"), group_id: str = typer.Argument(help="Group identifier")): config = variables["arlas"] - print(Service.add_permission_to_group_in_organisation(config, org_id, user_id, group_id)) + print(Service.add_user_to_organisation_group(config, org_id, user_id, group_id)) -@org.command(help="Remove a user from a group within the organisation", name="delete_user_from_group", epilog=variables["help_epilog"]) -def delete_user_from_group(org_id: str = typer.Argument(help="Organisation's identifier"), +@org.command(help="Remove a user from a group within the organisation", name="remove_user_from_group", epilog=variables["help_epilog"]) +def remove_user_from_group(org_id: str = typer.Argument(help="Organisation's identifier"), user_id: str = typer.Argument(help="User identifier"), group_id: str = typer.Argument(help="Group identifier")): config = variables["arlas"] - print(Service.delete_permission_from_group_in_organisation(config, org_id, user_id, group_id)) + print(Service.remove_user_from_organisation_group(config, org_id, user_id, group_id)) @org.command(help="Add and return an new API Key with permissions associated to provided groups. Use the key id and key secret with the arlas-api-key-id and arlas-api-key-secret headers.", name="add-apikey", diff --git a/arlas/cli/service.py b/arlas/cli/service.py index 4e535e7..07aee0e 100644 --- a/arlas/cli/service.py +++ b/arlas/cli/service.py @@ -189,6 +189,14 @@ def add_permission_to_group_in_organisation(arlas: str, oid: str, role_id: str, def delete_permission_from_group_in_organisation(arlas: str, oid: str, role_id: str, permission_id: str): return Service.__arlas__(arlas, "/".join(["organisations", oid, "roles", role_id, "permissions", permission_id]), delete=True, service=Services.iam) + @staticmethod + def add_user_to_organisation_group(arlas: str, oid: str, uid: str, role_id: str): + return Service.__arlas__(arlas, "/".join(["organisations", oid, "users", uid, "roles", role_id]), post="{}", service=Services.iam) + + @staticmethod + def remove_user_from_organisation_group(arlas: str, oid: str, uid: str, role_id: str): + return Service.__arlas__(arlas, "/".join(["organisations", oid, "users", uid, "roles", role_id]), delete=True, service=Services.iam) + @staticmethod def add_role_in_organisation(arlas: str, oid: str, role_name: str, role_description: str): return Service.__arlas__(arlas, "/".join(["organisations", oid, "roles"]), post=json.dumps({"name": role_name, "description": role_description}), service=Services.iam)