import requests
import json


def get_role_description_from_galaxy_response(response: requests.Response) -> str:
    """
    Extract description for a role from galaxy response

    Args:
        response (requests.Response): response from ansible galaxy (json body)

    Returns:
        str: description
    """
    # Parse json response
    try:
        data = json.loads(response.text)
    except:
        data = {}

    # description is in .data.repository.description
    return data.get("data", {}).get("repository", {}).get("description", None)