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)