def _get_organization(api: APIClient, organization_id: Optional[int] = None) -> dict: if organization_id is None: user_url = get_json(api.get("auth/user"))["url"] organziation_url = get_json(api.get_url(user_url))["organization"] res = api.get_url(organziation_url) else: res = api.get(f"organizations/{organization_id}") return get_json(res)
def get_groups(api: APIClient, group_name: Optional[str]) -> List[str]: if group_name is None: return [] return [g["url"] for g in get_json(api.get("groups", {"name": group_name}))["results"]]
def _check_user_does_not_exists(api: APIClient, username: str) -> None: total_users = get_json(api.get(f"users", {"username": username}))["pagination"]["total"] if total_users: raise click.ClickException(f"User with username {username} already exists.")