def fetch_incidents(client: Client, max_results: int, last_run: Dict[(str, int)], first_fetch_time: Optional[int], alert_status: Optional[str], min_severity: str, alert_type: Optional[str]) -> Tuple[(Dict[(str, int)], List[dict])]:
    'This function retrieves new alerts every interval (default is 1 minute).\n\n    This function has to implement the logic of making sure that incidents are\n    fetched only onces and no incidents are missed. By default it\'s invoked by\n    XSOAR every minute. It will use last_run to save the timestamp of the last\n    incident it processed. If last_run is not provided, it should use the\n    integration parameter first_fetch_time to determine when to start fetching\n    the first time.\n\n    :type client: ``Client``\n    :param Client: HelloWorld client to use\n\n    :type max_results: ``int``\n    :param max_results: Maximum numbers of incidents per fetch\n\n    :type last_run: ``Optional[Dict[str, int]]``\n    :param last_run:\n        A dict with a key containing the latest incident created time we got\n        from last fetch\n\n    :type first_fetch_time: ``Optional[int]``\n    :param first_fetch_time:\n        If last_run is None (first time we are fetching), it contains\n        the timestamp in milliseconds on when to start fetching incidents\n\n    :type alert_status: ``Optional[str]``\n    :param alert_status:\n        status of the alert to search for. Options are: \'ACTIVE\'\n        or \'CLOSED\'\n\n    :type min_severity: ``str``\n    :param min_severity:\n        minimum severity of the alert to search for.\n        Options are: "Low", "Medium", "High", "Critical"\n\n    :type alert_type: ``Optional[str]``\n    :param alert_type:\n        type of alerts to search for. There is no list of predefined types\n\n    :return:\n        A tuple containing two elements:\n            next_run (``Dict[str, int]``): Contains the timestamp that will be\n                    used in ``last_run`` on the next fetch.\n            incidents (``List[dict]``): List of incidents that will be created in XSOAR\n\n    :rtype: ``Tuple[Dict[str, int], List[dict]]``\n    '
    last_fetch = last_run.get('last_fetch', None)
    if (last_fetch is None):
        last_fetch = first_fetch_time
    else:
        last_fetch = int(last_fetch)
    latest_created_time = cast(int, last_fetch)
    incidents: List[Dict[(str, Any)]] = []
    severity = ','.join(HELLOWORLD_SEVERITIES[HELLOWORLD_SEVERITIES.index(min_severity):])
    alerts = client.search_alerts(alert_type=alert_type, alert_status=alert_status, max_results=max_results, start_time=last_fetch, severity=severity)
    for alert in alerts:
        incident_created_time = int(alert.get('created', '0'))
        incident_created_time_ms = (incident_created_time * 1000)
        if last_fetch:
            if (incident_created_time <= last_fetch):
                continue
        incident_name = alert['name']
        incident = {'name': incident_name, 'occurred': timestamp_to_datestring(incident_created_time_ms), 'rawJSON': json.dumps(alert), 'severity': convert_to_demisto_severity(alert.get('severity', 'Low'))}
        incidents.append(incident)
        if (incident_created_time > latest_created_time):
            latest_created_time = incident_created_time
    next_run = {'last_fetch': latest_created_time}
    return (next_run, incidents)
This function retrieves new alerts every interval (default is 1 minute).

This function has to implement the logic of making sure that incidents are
fetched only onces and no incidents are missed. By default it's invoked by
XSOAR every minute. It will use last_run to save the timestamp of the last
incident it processed. If last_run is not provided, it should use the
integration parameter first_fetch_time to determine when to start fetching
the first time.

:type client: ``Client``
:param Client: HelloWorld client to use

:type max_results: ``int``
:param max_results: Maximum numbers of incidents per fetch

:type last_run: ``Optional[Dict[str, int]]``
:param last_run:
    A dict with a key containing the latest incident created time we got
    from last fetch

:type first_fetch_time: ``Optional[int]``
:param first_fetch_time:
    If last_run is None (first time we are fetching), it contains
    the timestamp in milliseconds on when to start fetching incidents

:type alert_status: ``Optional[str]``
:param alert_status:
    status of the alert to search for. Options are: 'ACTIVE'
    or 'CLOSED'

:type min_severity: ``str``
:param min_severity:
    minimum severity of the alert to search for.
    Options are: "Low", "Medium", "High", "Critical"

:type alert_type: ``Optional[str]``
:param alert_type:
    type of alerts to search for. There is no list of predefined types

:return:
    A tuple containing two elements:
        next_run (``Dict[str, int]``): Contains the timestamp that will be
                used in ``last_run`` on the next fetch.
        incidents (``List[dict]``): List of incidents that will be created in XSOAR

:rtype: ``Tuple[Dict[str, int], List[dict]]``
def fetch_incidents(client: Client, max_results: int, last_run: Dict[(str, int)], first_fetch_time: Optional[int], alert_status: Optional[str], min_severity: str, alert_type: Optional[str]) -> Tuple[(Dict[(str, int)], List[dict])]:
    'This function retrieves new alerts every interval (default is 1 minute).\n\n    This function has to implement the logic of making sure that incidents are\n    fetched only onces and no incidents are missed. By default it\'s invoked by\n    XSOAR every minute. It will use last_run to save the timestamp of the last\n    incident it processed. If last_run is not provided, it should use the\n    integration parameter first_fetch_time to determine when to start fetching\n    the first time.\n\n    :type client: ``Client``\n    :param Client: HelloWorld client to use\n\n    :type max_results: ``int``\n    :param max_results: Maximum numbers of incidents per fetch\n\n    :type last_run: ``Optional[Dict[str, int]]``\n    :param last_run:\n        A dict with a key containing the latest incident created time we got\n        from last fetch\n\n    :type first_fetch_time: ``Optional[int]``\n    :param first_fetch_time:\n        If last_run is None (first time we are fetching), it contains\n        the timestamp in milliseconds on when to start fetching incidents\n\n    :type alert_status: ``Optional[str]``\n    :param alert_status:\n        status of the alert to search for. Options are: \'ACTIVE\'\n        or \'CLOSED\'\n\n    :type min_severity: ``str``\n    :param min_severity:\n        minimum severity of the alert to search for.\n        Options are: "Low", "Medium", "High", "Critical"\n\n    :type alert_type: ``Optional[str]``\n    :param alert_type:\n        type of alerts to search for. There is no list of predefined types\n\n    :return:\n        A tuple containing two elements:\n            next_run (``Dict[str, int]``): Contains the timestamp that will be\n                    used in ``last_run`` on the next fetch.\n            incidents (``List[dict]``): List of incidents that will be created in XSOAR\n\n    :rtype: ``Tuple[Dict[str, int], List[dict]]``\n    '
    last_fetch = last_run.get('last_fetch', None)
    if (last_fetch is None):
        last_fetch = first_fetch_time
    else:
        last_fetch = int(last_fetch)
    latest_created_time = cast(int, last_fetch)
    incidents: List[Dict[(str, Any)]] = []
    severity = ','.join(HELLOWORLD_SEVERITIES[HELLOWORLD_SEVERITIES.index(min_severity):])
    alerts = client.search_alerts(alert_type=alert_type, alert_status=alert_status, max_results=max_results, start_time=last_fetch, severity=severity)
    for alert in alerts:
        incident_created_time = int(alert.get('created', '0'))
        incident_created_time_ms = (incident_created_time * 1000)
        if last_fetch:
            if (incident_created_time <= last_fetch):
                continue
        incident_name = alert['name']
        incident = {'name': incident_name, 'occurred': timestamp_to_datestring(incident_created_time_ms), 'rawJSON': json.dumps(alert), 'severity': convert_to_demisto_severity(alert.get('severity', 'Low'))}
        incidents.append(incident)
        if (incident_created_time > latest_created_time):
            latest_created_time = incident_created_time
    next_run = {'last_fetch': latest_created_time}
    return (next_run, incidents)