def get_users_for_domain(service, domain, query):
    """
    Get all users for a specified domain via Google API.

    :param service: Authenticated directory service object
    :param domain: The domain for users
    :return: List of all users
    """
    results = service.users().list(
        domain=domain,
        maxResults=500,
        query=query,
    ).execute()

    users = results.get('users', [])

    while 'nextPageToken' in results:
        results = service.users().list(
            domain=domain,
            maxResults=500,
            query=query,
            pageToken=results['nextPageToken']
        ).execute()

        users += results.get('users', [])

    return users