import requests
import logging
import sys

from pagerduty_api.abstract_client import AbstractClient
from typing import Any, Dict, List

class PagerDutyAnalyticsClient(AbstractClient):
    def __init__(
        self,
        http_session: requests.Session = requests.Session(),
        endpoint: str = 'https://api.pagerduty.com',
        auth_token: str = None,
        logger: logging.Logger = None
    ):
        super().__init__(http_session, endpoint, auth_token, logger)
        self._default_url = f'{self._endpoint}/analytics/metrics/incidents'
        self._default_entity_name = 'data'

    def list_analytics(
        self,
        data: Dict[str, Any] = {}
    ):
        '''
        >>> import os
        >>> client = PagerDutyAnalyticsClient(auth_token=os.environ.get('AUTH_TOKEN'))
        >>> analytics = client.list_analytics()
        Executing HTTP get on https://api.pagerduty.com//analytics/metrics/incidents/services
        >>> len(analytics) >= 1
        True
        '''
        return self.do_analytics_request(
            url=f'{self._default_url}/services',
            entity_name=self._default_entity_name,
            data=data,
            method='post'
        )

    def list_incidents(
        self,
        data: Dict[str, Any] = {}
    ):
        '''
        >>> import os
        >>> client = PagerDutyAnalyticsClient(auth_token=os.environ.get('AUTH_TOKEN'))
        >>> incidents = client.list_incidents()
        Executing HTTP get on https://api.pagerduty.com/incidents
        >>> len(incidents) >= 1
        True
        '''
        
        return self.do_analytics_request(
            url=f'{self._default_url}/all',
            entity_name=self._default_entity_name,
            data=data,
            method='post'
        )

    
#["P6THBO4", "PAOR13M", "PCTB88X", "PYPJAA9", "PG2XNDN", "PQI2LK3", "PNHSHMO", "PEG1GVL", "PRX56PU", "PG65ZZE"]
# feed service ids in batches of 10
# get incident count from here
