Пример #1
0
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)
Пример #2
0
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"]]
Пример #3
0
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.")