# -*- coding: utf-8 -*-
import logging
from ...utils import util
from ..report import ReportFormat

logger = logging.getLogger(__name__)


class Reports(object):

    def __init__(self, session, api_version, urls_map):
        self.session = session
        self.asset_api_version = api_version
        self.urls_map = urls_map

    def __get_obj(self, **data):
        uri = self.asset_api_version + self.urls_map.report
        resp = self.session.post(uri, data)
        response = resp.text
        return {"response": response,
                "status": resp.status_code
                }

    def __get_obj_get(self, **data):
        uri = self.asset_api_version + self.urls_map.report
        resp = self.session.get(uri, data)
        response = resp.text
        return {"response": response,
                "status": resp.status_code
                }

    def list_report(self, **kwargs):
        kwargs["action"] = "list"
        return self.__get_obj(**kwargs)

    def scan_report(self, **kwargs):
        kwargs["action"] = "launch"
        kwargs["report_type"] = "Scan"
        return self.__get_obj(**kwargs)

    def map_report(self, **kwargs):
        kwargs["action"] = "launch"
        kwargs["report_type"] = "Map"
        return self.__get_obj(**kwargs)

    def remediation_report(self, **kwargs):
        kwargs["action"] = "launch"
        kwargs["report_type"] = "Remediation"
        return self.__get_obj(**kwargs)

    def compliance_report(self, **kwargs):
        kwargs["action"] = "launch"
        kwargs["report_type"] = "Compliance"
        return self.__get_obj(**kwargs)

    def compliance_policy_report(self, **kwargs):
        kwargs["action"] = "launch"
        kwargs["report_type"] = "Policy"
        return self.__get_obj(**kwargs)
