"""
SDK for the Helios Alerts API.

Methods are meant to represent the core functionality in the developer
documentation.  Some may have additional functionality for convenience.

"""
import logging

from helios.core import SDKCore, IndexMixin, ShowMixin, RequestManager


class Alerts(ShowMixin, IndexMixin, SDKCore):
    """
    Helios alerts provide real-time severe weather alerts.

    National Weather Service
        Severe weather alerts for the United States are provided by the
        National Weather Service. These alerts cover events such as Flood
        Warnings, Severe Thunderstorm Warnings, and Special Weather Statements.

    Helios
        Alerts generated by Helios are based on the sensor measurements from
        the Observations API. These alerts represent regional areas with a high
        detection confidence and currently include: Road Wetness Watch, Poor
        Visibility Watch, and Heavy Precip Watch.

    """

    core_api = 'alerts'
    max_threads = 32

    def __init__(self):
        self.request_manager = RequestManager(pool_maxsize=self.max_threads)
        self.logger = logging.getLogger(__name__)

    def index(self, **kwargs):
        """
        Return a list of alerts matching the provided spatial, text, or
        metadata filters.

        The maximum skip value is 4000. If this is reached, truncated results
        will be returned. You will need to refine your query to avoid this.

        Args:
            **kwargs: Any keyword arguments found in the documentation.

        Returns:
             list: GeoJSON feature collections.

        """
        return super(Alerts, self).index(**kwargs)

    def show(self, alert_id):
        """
        Return the attributes for a single alert.

        Args:
            alert_id (str): Alert ID.

        Returns:
            dict: GeoJSON feature.

        """
        return super(Alerts, self).show(alert_id)
