# -*- coding: utf-8 -*-

"""
ctddocumentation

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""

from ctddocumentation.api_helper import APIHelper
from ctddocumentation.configuration import Server
from ctddocumentation.controllers.base_controller import BaseController
from apimatic_core.request_builder import RequestBuilder
from apimatic_core.response_handler import ResponseHandler
from apimatic_core.types.parameter import Parameter
from ctddocumentation.http.http_method_enum import HttpMethodEnum
from apimatic_core.authentication.multiple.single_auth import Single
from apimatic_core.authentication.multiple.and_auth_group import And
from apimatic_core.authentication.multiple.or_auth_group import Or


class InsightsController(BaseController):

    """A Controller to access Endpoints in the ctddocumentation API."""
    def __init__(self, config):
        super(InsightsController, self).__init__(config)

    def get_insights_summary(self,
                             format,
                             sort,
                             content_type,
                             page=1,
                             per_page=50,
                             site_id__exact=1,
                             ghost__exact=False,
                             special_hint__exact=None,
                             insight_status__exact=None):
        """Does a GET request to /ranger/insights_summary.

        In order to retrieve all the assets associated with a specific
        Insight
        Step 1:
        1. Apply the relevant site number in the site_id__exact field
        2. Click "Try It Out"
        3. From the Response body, select the insight of interest,  e.g.
        Assets Accessed SMB shares
        4. Copy the string of the insight name e.g. "Assets Accessed SMB
        shares"
        5. Find further instructions in 'Get Insight Details by Name' API
        endpoint

        Args:
            format (string): TODO: type description here.
            sort (string): TODO: type description here.
            content_type (ContentTypeEnum): TODO: type description here.
            page (int, optional): The actual page offset
            per_page (int, optional): Number of Insights to pull per page
            site_id__exact (int, optional): The identifier of the Site related
                to the Insight
            ghost__exact (bool, optional): Whether or not this is a ghost
                asset: TRUE = Ghost
            special_hint__exact (SpecialHintExactEnum, optional): TODO: type
                description here.
            insight_status__exact (InsightStatusExact1Enum, optional): The
                status of the Insight associated with this Asset – this is a
                dropdown for choosing the integer type:  0 = Open  1 = Hidden 
                2 = Completed

        Returns:
            void: Response from the API. Successful Operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path('/ranger/insights_summary')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('format')
                         .value(format))
            .query_param(Parameter()
                         .key('sort')
                         .value(sort))
            .header_param(Parameter()
                          .key('Content-Type')
                          .value(content_type))
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('site_id__exact')
                         .value(site_id__exact))
            .query_param(Parameter()
                         .key('ghost__exact')
                         .value(ghost__exact))
            .query_param(Parameter()
                         .key('special_hint__exact')
                         .value(special_hint__exact))
            .query_param(Parameter()
                         .key('insight_status__exact')
                         .value(insight_status__exact))
            .auth(Single('global'))
        ).execute()

    def get_insight_details_by_name(self,
                                    insight_name,
                                    format='insight_page',
                                    page=1,
                                    per_page=10,
                                    site_id__exact=1,
                                    ghost__exact=False,
                                    special_hint__exact=None,
                                    insight_status__exact=None):
        """Does a GET request to /ranger/insight_details/{insight_name}.

        In order to retrieve all the assets associated with a specific
        Insight:
        Step 2 (Step1 is in 'Get Insights Summary' endpoint):
        1. Enter (paste) the insight name from above into the insight_name
        field 
        2. Apply the relevant site number in the site_id__exact field
        3. Click Execute
        4. From the Response Body, Select the FILTER_KEY
        5. Copy the string of the FILTER_KEY 
        6. Find further instructions in /ranger/assets

        Args:
            insight_name (string): TODO: type description here.
            format (string, optional): TODO: type description here. Example:
                insight_page
            page (int, optional): The actual page offset
            per_page (int, optional): Number of Insights to pull per page
            site_id__exact (int, optional): The identifier of the Site related
                to the Insight
            ghost__exact (bool, optional): Whether or not this is a ghost
                asset: TRUE = Ghost
            special_hint__exact (SpecialHintExactEnum, optional): TODO: type
                description here.
            insight_status__exact (InsightStatusExact1Enum, optional): The
                status of the Insight associated with this Asset – this is a
                dropdown for choosing the integer type:  0 = Open  1 = Hidden 
                2 = Completed

        Returns:
            void: Response from the API. Successful Operation

        Raises:
            APIException: When an error occurs while fetching the data from
                the remote API. This exception includes the HTTP Response
                code, an error message, and the HTTP body that was received in
                the request.

        """

        return super().new_api_call_builder.request(
            RequestBuilder().server(Server.DEFAULT)
            .path('/ranger/insight_details/{insight_name}')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('insight_name')
                            .value(insight_name)
                            .should_encode(True))
            .query_param(Parameter()
                         .key('format')
                         .value(format))
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('site_id__exact')
                         .value(site_id__exact))
            .query_param(Parameter()
                         .key('ghost__exact')
                         .value(ghost__exact))
            .query_param(Parameter()
                         .key('special_hint__exact')
                         .value(special_hint__exact))
            .query_param(Parameter()
                         .key('insight_status__exact')
                         .value(insight_status__exact))
            .auth(Single('global'))
        ).execute()
