from typing import Dict
from typing import Any
from typing import List
from typing import Tuple


def get_asset_custom_context_for_ssl_cert(resp: Dict[str, Any], simple_context: Dict[str, Any],
                                          keys_with_hierarchy: List[str]) -> Tuple[Dict[str, Any], List[str]]:
    """
    Modifying the lists and reducing the levels of keys for SSL Cert asset type from the fetched response.

    :param resp: Response fetched from the API call
    :param simple_context: Simplified context after reducing heirarchy and excluding keys.
    :param keys_with_hierarchy: List of keys to be reduced from the main asset key.
    :return: simple_context, keys_with_hierarchy: Custom context prepared for the SSL Cert details
     from the fetched response and appended list of keys that can be used to reduce the level of context.
    """

    if resp.get('asset', {}).get('issuer'):
        simple_context['issuer'] = resp.get('asset', {}).get('issuer', '')
        keys_with_hierarchy.append('issuer')

    if resp.get('asset', {}).get('subject'):
        simple_context['subject'] = resp.get('asset', {}).get('subject', '')
        keys_with_hierarchy.append('subject')

    if resp.get('asset', {}).get('issuerAlternativeNames'):
        simple_context['issuerAlternativeNames'] = \
            ', '.join(resp.get('asset', {}).get('issuerAlternativeNames', []))

    if resp.get('asset', {}).get('subjectAlternativeNames'):
        simple_context['subjectAlternativeNames'] = \
            ', '.join(resp.get('asset', {}).get('subjectAlternativeNames', []))

    return simple_context, keys_with_hierarchy