"""Module that contains functions for EPV ingestion in Graph DB."""

from selinon import run_flow, run_flow_selective
import logging
import os
from f8a_jobs.utils import requires_auth
from f8a_utils.gh_utils import GithubUtils
from f8a_utils.tree_generator import GolangDependencyTreeGenerator
import time
from f8a_jobs import user_cache
from f8a_utils.versions import is_pkg_public


logger = logging.getLogger(__name__)

_INVOKE_API_WORKERS = os.environ.get('INVOKE_API_WORKERS', 'True') == 'True'
_DISABLE_UNKNOWN_PACKAGE_FLOW = os.environ.get('DISABLE_UNKNOWN_PACKAGE_FLOW', 'False') == 'True'
_SUPPORTED_ECOSYSTEMS = {'npm', 'maven', 'pypi', 'golang'}


def ingest_epv_into_graph(epv_details):
    """Handle implementation of API for triggering ingestion flow.

    :param epv_details: A dictionary object having list of packages/version as a nested object.
    Ex:
    {
          "ecosystem": "<ecosystem_name>",     (*required)
          "packages": [
            {
              "package": "<package_name_1>",   (*required)
              "version": "<package_version_1>" (*required)
            }, {
              "package": "<package_name_2>",   (*required)
              "version": "<package_version_2>" (*required)
            }
          ],
          "force": false,              (optional)
          "force_graph_sync": true,    (optional)
          "recursive_limit": 0         (optional)
          "source": "<Consumer_of_API>"(optional)
        }
    """