# -*- 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
from ctddocumentation.models.get_alerts_response import GetAlertsResponse
from ctddocumentation.models.alert import Alert


class AlertsController(BaseController):

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

    def get_alerts(self,
                   page=None,
                   per_page=None,
                   asset_id__exact=None,
                   asset__exact=None,
                   for_asset__exact=None,
                   q__exact=None,
                   primary_asset__exact=None,
                   non_primary_assets__exact=None,
                   virtual_zone__exact=None,
                   alert_id__exact=None,
                   ot_alerts__exact=None,
                   family__exact=None,
                   story_severity__exact=None,
                   id__exact=None,
                   site_id__exact=None,
                   data__exact=None,
                   description__exact=None,
                   type__exact=None,
                   category__exact=None,
                   severity__exact=None,
                   timestamp__exact=None,
                   last_updated__gte=None,
                   relevant__exact=None,
                   resolved__exact=None,
                   resolution__exact=None,
                   protocol__exact=None,
                   score__exact=None,
                   is_qualified__exact=None,
                   network_id__exact=None,
                   resolved_id__exact=None,
                   assigned_id__exact=None,
                   story_id__exact=None,
                   sort=None):
        """Does a GET request to /ranger/alerts.

        Retrieves a list of Alerts in CTD, with optional filters.
        Note - All filters are optional.

        Args:
            page (int, optional): Page offset
            per_page (int, optional): Number of Alerts to pull on each page.
                (The maximum is 500).
            asset_id__exact (string, optional): Resource ID of the Asset
            asset__exact (string, optional): TODO: type description here.
            for_asset__exact (string, optional): TODO: type description here.
            q__exact (string, optional): TODO: type description here.
            primary_asset__exact (string, optional): The resource ID of the
                primary asset that triggered the alert
            non_primary_assets__exact (string, optional): Resource IDs of the
                non-primary assets involved in the alert
            virtual_zone__exact (string, optional): The resource ID of the
                Zone that triggered the alert
            alert_id__exact (string, optional): The resource ID of the Alert. 
                You can add multiple IDs.
            ot_alerts__exact (string, optional): TODO: type description here.
            family__exact (string, optional): Model family of the Asset
                involved in the Alert, for example Policy Violation. Alert
                Families appear in the Advanced Options filter of Alerts.
            story_severity__exact (string, optional): TODO: type description
                here.
            id__exact (int, optional): TODO: type description here.
            site_id__exact (int, optional): ID of the Site on which the Alert
                occurred
            data__exact (string, optional): TODO: type description here.
            description__exact (string, optional): Description of the alert
            type__exact (int, optional): Alert Type, such as Known Threat, New
                Conflict Asset, etc.
            category__exact (int, optional): Alert Category: 0 = Integrity, 1
                = Security
            severity__exact (int, optional): Alert Severity: 0 = Low, 1 =
                Medium, 2 = High, 3 = Critical
            timestamp__exact (string, optional): Timestamp on which the Alert
                occured. **Format:** YYYY-MM-DD**T**HH:MM:SS (in UTC)
                **Example:** 2022-11-01T16:22:05
            last_updated__gte (string, optional): The timestamp when the
                latest change on the Alert was made in the EMC.   **Format:**
                YYYY-MM-DD**T**HH:MM:SS (in UTC)  **Example:**
                2022-11-01T16:22:05
            relevant__exact (bool, optional): TODO: type description here.
            resolved__exact (bool, optional): Whether or not an Alert was
                resolved: True = resolved, False = not resolved
            resolution__exact (int, optional): Type of resolution.
            protocol__exact (string, optional): Protocol used in the alert,
                for example: S7Comm
            score__exact (int, optional): Alert Score calculated for this
                alert, on a score of 1-100
            is_qualified__exact (bool, optional): TODO: type description
                here.
            network_id__exact (int, optional): TODO: type description here.
            resolved_id__exact (int, optional): TODO: type description here.
            assigned_id__exact (int, optional): ID of the User to which the
                Alert was assigned
            story_id__exact (int, optional): ID of the Alert Story to which
                the Alert belongs - can be viewed in the UI by selecting
                "Group By Story"
            sort (SortEnum, optional): By default, results are sorted in
                ascending order of the sort attribute. The sorting prefix "-"
                sorts the results in descending order of the sort attribute.

        Returns:
            GetAlertsResponse: 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/alerts')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('asset_id__exact')
                         .value(asset_id__exact))
            .query_param(Parameter()
                         .key('asset__exact')
                         .value(asset__exact))
            .query_param(Parameter()
                         .key('for_asset__exact')
                         .value(for_asset__exact))
            .query_param(Parameter()
                         .key('q__exact')
                         .value(q__exact))
            .query_param(Parameter()
                         .key('primary_asset__exact')
                         .value(primary_asset__exact))
            .query_param(Parameter()
                         .key('non_primary_assets__exact')
                         .value(non_primary_assets__exact))
            .query_param(Parameter()
                         .key('virtual_zone__exact')
                         .value(virtual_zone__exact))
            .query_param(Parameter()
                         .key('alert_id__exact')
                         .value(alert_id__exact))
            .query_param(Parameter()
                         .key('ot_alerts__exact')
                         .value(ot_alerts__exact))
            .query_param(Parameter()
                         .key('family__exact')
                         .value(family__exact))
            .query_param(Parameter()
                         .key('story_severity__exact')
                         .value(story_severity__exact))
            .query_param(Parameter()
                         .key('id__exact')
                         .value(id__exact))
            .query_param(Parameter()
                         .key('site_id__exact')
                         .value(site_id__exact))
            .query_param(Parameter()
                         .key('data__exact')
                         .value(data__exact))
            .query_param(Parameter()
                         .key('description__exact')
                         .value(description__exact))
            .query_param(Parameter()
                         .key('type__exact')
                         .value(type__exact))
            .query_param(Parameter()
                         .key('category__exact')
                         .value(category__exact))
            .query_param(Parameter()
                         .key('severity__exact')
                         .value(severity__exact))
            .query_param(Parameter()
                         .key('timestamp__exact')
                         .value(timestamp__exact))
            .query_param(Parameter()
                         .key('last_updated__gte')
                         .value(last_updated__gte))
            .query_param(Parameter()
                         .key('relevant__exact')
                         .value(relevant__exact))
            .query_param(Parameter()
                         .key('resolved__exact')
                         .value(resolved__exact))
            .query_param(Parameter()
                         .key('resolution__exact')
                         .value(resolution__exact))
            .query_param(Parameter()
                         .key('protocol__exact')
                         .value(protocol__exact))
            .query_param(Parameter()
                         .key('score__exact')
                         .value(score__exact))
            .query_param(Parameter()
                         .key('is_qualified__exact')
                         .value(is_qualified__exact))
            .query_param(Parameter()
                         .key('network_id__exact')
                         .value(network_id__exact))
            .query_param(Parameter()
                         .key('resolved_id__exact')
                         .value(resolved_id__exact))
            .query_param(Parameter()
                         .key('assigned_id__exact')
                         .value(assigned_id__exact))
            .query_param(Parameter()
                         .key('story_id__exact')
                         .value(story_id__exact))
            .query_param(Parameter()
                         .key('sort')
                         .value(sort))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Single('global'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetAlertsResponse.from_dictionary)
        ).execute()

    def find_alert_by_id(self,
                         resource_id):
        """Does a GET request to /ranger/alerts/{resource_id}.

        Get a single alert.

        Args:
            resource_id (string): Resource ID of the Alert to return

        Returns:
            Alert: 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/alerts/{resource_id}')
            .http_method(HttpMethodEnum.GET)
            .template_param(Parameter()
                            .key('resource_id')
                            .value(resource_id)
                            .should_encode(True))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Single('global'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(Alert.from_dictionary)
        ).execute()
