from typing import List, Tuple, Union, Dict
import collections
import logging

import aiohttp

from ..schemas import GenMethodEnum, CountryCode

# Google API key, with access to Street View Static API
# this can be safely committed due to permission restriction
google_api_key = "AIzaSyAqjCYR6Szph0X0H_iD6O1HenFhL9jySOo"
metadata_url = "https://maps.googleapis.com/maps/api/streetview/metadata"

logger = logging.getLogger(__name__)

aiohttp_client = aiohttp.ClientSession()


async def point_has_streetview(lat, lng):
    """
    Returns True if the streetview metadata endpoint says a given point has
    data available, and False otherwise.

    This function calls the streetview metadata endpoint - there is no quota consumed.
    """
    params = {
        "key": google_api_key,
        "location": f"{lat},{lng}",
    }
    async with aiohttp_client.get(metadata_url, params=params) as response:
        body = await response.json()
        return body["status"] == "OK"
