# -*- 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_assets_response import GetAssetsResponse
from ctddocumentation.models.find_asset_by_id_response import FindAssetByIDResponse
from ctddocumentation.models.assets_with_insights_response import AssetsWithInsightsResponse
from ctddocumentation.exceptions.api_exception import APIException


class AssetsController(BaseController):

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

    def get_assets(self,
                   format=None,
                   page=None,
                   per_page=None,
                   ipv_4__exact=None,
                   ipv_6__exact=None,
                   mac__icontains=None,
                   vlan__exact=None,
                   address__exact=None,
                   gateway__exact=None,
                   asset_type__exact=None,
                   host_name__exact=None,
                   os__exact=None,
                   model__icontains=None,
                   vendor__icontains=None,
                   state__exact=None,
                   domain_names__exact=None,
                   firmware__exact=None,
                   serial__exact=None,
                   generic__icontains=None,
                   display_name__icontains=None,
                   criticality__exact=None,
                   old_ip__exact=None,
                   protocol__exact=None,
                   last_seen__exact=None,
                   q__icontains=None,
                   alert_id__exact=None,
                   last_updated__gt=None,
                   baseline__exact=None,
                   arp_baselines__exact=None,
                   insight_status__exact=None,
                   insights_insight_name__exact=None,
                   insight_timestamp__gte=None,
                   insight_timestamp__lte=None,
                   baseline_category__exact=None,
                   baseline_access_type__exact=None,
                   insight_name__exact=None,
                   insight_row_key__exact=None,
                   ghost__exact=None,
                   tasks__exact=None,
                   active_queries__exact=None,
                   subnet_tag__exact=None,
                   custom_attributes__exact=None,
                   class_type__exact=None,
                   domain_name__exact=None,
                   involved_in_tags__exact=None,
                   hosted_tags__icontains=None,
                   id__exact=None,
                   site_id__exact=None,
                   timestamp__exact=None,
                   approved__exact=None,
                   valid__exact=None,
                   parsed__exact=None,
                   special_hint__exact=None,
                   risk_level__exact=None,
                   network_id__exact=None,
                   virtual_zone_id__exact=None,
                   subnet_id__exact=None,
                   purdue_level__exact=None):
        """Does a GET request to /ranger/assets.

        Retrieves a list of assets in CTD, with optional filters.
        Note: All filters are optional.

        Args:
            format (Format1Enum, optional): Specifies the type of response
                (list of fields) returned by the query. If not provided, all
                asset properties are returned and could affect performance.
            page (int, optional): The page number to be viewed
            per_page (int, optional): Number of Assets to pull per page
            ipv_4__exact (string, optional): IP address of the asset in IPv4
                format
            ipv_6__exact (string, optional): IP address of the asset in IPv6
                format
            mac__icontains (string, optional): The MAC address of the device
                (free text)
            vlan__exact (string, optional): The VLAN/s of the device
            address__exact (string, optional): The IP address of this device
                in the network
            gateway__exact (string, optional): IP of the Gateway of the
                Asset's network
            asset_type__exact (string, optional): CTD Asset type, for example
                SCADA client, PLC, etc.
            host_name__exact (string, optional): The host name of this Asset
            os__exact (string, optional): The name of the operating system
            model__icontains (string, optional): The Model of this asset (free
                text)
            vendor__icontains (string, optional): The Vendor of this asset
                (free text)
            state__exact (string, optional): Asset state as selected in the
                dropdown:  0 = Training  1 = Maintenance  2 = Guest
            domain_names__exact (string, optional): The exact domain name(s)
                of the Asset
            firmware__exact (string, optional): The exact firmware name of the
                Asset
            serial__exact (string, optional): The exact serial number of the
                Asset
            generic__icontains (string, optional): Custom information (free
                text)
            display_name__icontains (string, optional): The name of the Asset
                (free text)
            criticality__exact (string, optional): Low, Medium, or High. These
                CTD values represent how critical the asset itself is to the
                operation. CTD assigns criticality automatically to certain
                types of assets but enables you to edit the value.
            old_ip__exact (string, optional): Previous IPs used by this Asset
            protocol__exact (string, optional): List of protocols used by this
                Asset when communicating
            last_seen__exact (string, optional): The timestamp of the last
                instance when this device was seen in the network
            q__icontains (string, optional): Free text for the following Asset
                info: Name, IP, Version, Model and MAC
            alert_id__exact (string, optional): The IDs of the alerts
                triggered by this Asset
            last_updated__gt (string, optional): The timestamp when the latest
                change to the Asset was made in the EMC. **Format:**
                YYYY-MM-DD**T**HH:MM:SS (in UTC) **Example:**
                2022-11-01T16:22:05
            baseline__exact (string, optional): Names of Baselines in which
                the Asset appears
            arp_baselines__exact (string, optional): Whether this asset has
                ARP baselines: True = ARP
            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
            insights_insight_name__exact (string, optional): The name of the
                Insight associated with this Asset
            insight_timestamp__gte (string, optional): When this Insight was
                detected; greater (later) than or equal to a specific
                timestamp
            insight_timestamp__lte (string, optional): When this Insight was
                detected; less (earlier) than or equal to a specific
                timestamp
            baseline_category__exact (string, optional): The category of the
                Baseline of this Asset
            baseline_access_type__exact (string, optional): The access type of
                the Baseline of this asset
            insight_name__exact (string, optional): The name of the Insight
                associated with this Asset
            insight_row_key__exact (string, optional): The row key of the
                related Insight
            ghost__exact (bool, optional): Whether or not this is a ghost
                asset: TRUE = Ghost
            tasks__exact (string, optional): Resource ID of the Active Tasks
                running on this Asset
            active_queries__exact (string, optional): Resource ID of the
                Active Queries running on this Asset
            subnet_tag__exact (string, optional): The device’s network
                location
            custom_attributes__exact (string, optional): The values of the
                (user-defined) Custom Attributes for this Asset
            class_type__exact (string, optional): The class type of this Asset
                (IT, OT, IoT)
            domain_name__exact (string, optional): The domain name of the
                Asset
            involved_in_tags__exact (string, optional): TODO: type description
                here.
            hosted_tags__icontains (string, optional): Artifact name (free
                text)
            id__exact (int, optional): The device’s unique identifier in the
                system
            site_id__exact (int, optional): The identifier of the Site in
                which the device resides
            timestamp__exact (string, optional): The timestamp of when this
                Asset was detected
            approved__exact (bool, optional): If the Asset was approved
            valid__exact (bool, optional): If the Asset is valid: TRUE=valid
            parsed__exact (bool, optional): Whether or not parsed information
                (numerical or textual value from the protocols) was
                incorporated by CTD into the Asset’s baseline
            special_hint__exact (SpecialHintExactEnum, optional): TODO: type
                description here.
            risk_level__exact (int, optional): The CTD level of risk for this
                device, based on its vulnerabilities, insights, alerts,
                policies, asset criticality, and network location
            network_id__exact (int, optional): The ID of the network in which
                this device is located
            virtual_zone_id__exact (int, optional): The group of related
                assets this device belongs to (e.g. PLC Modbus)
            subnet_id__exact (int, optional): The device’s network location
            purdue_level__exact (string, optional): The Purdue model level of
                this specific device (0-6).  This value is automatically
                determined based on the various characteristics of the asset
                and its purpose. Can be adjusted to reflect the true asset
                behavior. Also note that interim Purdue levels can also be
                used, e.g. 1.5, 2.5, 3.5

        Returns:
            GetAssetsResponse: 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/assets')
            .http_method(HttpMethodEnum.GET)
            .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('ipv4__exact')
                         .value(ipv_4__exact))
            .query_param(Parameter()
                         .key('ipv6__exact')
                         .value(ipv_6__exact))
            .query_param(Parameter()
                         .key('mac__icontains')
                         .value(mac__icontains))
            .query_param(Parameter()
                         .key('vlan__exact')
                         .value(vlan__exact))
            .query_param(Parameter()
                         .key('address__exact')
                         .value(address__exact))
            .query_param(Parameter()
                         .key('gateway__exact')
                         .value(gateway__exact))
            .query_param(Parameter()
                         .key('asset_type__exact')
                         .value(asset_type__exact))
            .query_param(Parameter()
                         .key('host_name__exact')
                         .value(host_name__exact))
            .query_param(Parameter()
                         .key('os__exact')
                         .value(os__exact))
            .query_param(Parameter()
                         .key('model__icontains')
                         .value(model__icontains))
            .query_param(Parameter()
                         .key('vendor__icontains')
                         .value(vendor__icontains))
            .query_param(Parameter()
                         .key('state__exact')
                         .value(state__exact))
            .query_param(Parameter()
                         .key('domain_names__exact')
                         .value(domain_names__exact))
            .query_param(Parameter()
                         .key('firmware__exact')
                         .value(firmware__exact))
            .query_param(Parameter()
                         .key('serial__exact')
                         .value(serial__exact))
            .query_param(Parameter()
                         .key('generic__icontains')
                         .value(generic__icontains))
            .query_param(Parameter()
                         .key('display_name__icontains')
                         .value(display_name__icontains))
            .query_param(Parameter()
                         .key('criticality__exact')
                         .value(criticality__exact))
            .query_param(Parameter()
                         .key('old_ip__exact')
                         .value(old_ip__exact))
            .query_param(Parameter()
                         .key('protocol__exact')
                         .value(protocol__exact))
            .query_param(Parameter()
                         .key('last_seen__exact')
                         .value(last_seen__exact))
            .query_param(Parameter()
                         .key('q__icontains')
                         .value(q__icontains))
            .query_param(Parameter()
                         .key('alert_id__exact')
                         .value(alert_id__exact))
            .query_param(Parameter()
                         .key('last_updated__gt')
                         .value(last_updated__gt))
            .query_param(Parameter()
                         .key('baseline__exact')
                         .value(baseline__exact))
            .query_param(Parameter()
                         .key('arp_baselines__exact')
                         .value(arp_baselines__exact))
            .query_param(Parameter()
                         .key('insight_status__exact')
                         .value(insight_status__exact))
            .query_param(Parameter()
                         .key('insights_insight_name__exact')
                         .value(insights_insight_name__exact))
            .query_param(Parameter()
                         .key('insight_timestamp__gte')
                         .value(insight_timestamp__gte))
            .query_param(Parameter()
                         .key('insight_timestamp__lte')
                         .value(insight_timestamp__lte))
            .query_param(Parameter()
                         .key('baseline_category__exact')
                         .value(baseline_category__exact))
            .query_param(Parameter()
                         .key('baseline_access_type__exact')
                         .value(baseline_access_type__exact))
            .query_param(Parameter()
                         .key('insight_name__exact')
                         .value(insight_name__exact))
            .query_param(Parameter()
                         .key('insight_row_key__exact')
                         .value(insight_row_key__exact))
            .query_param(Parameter()
                         .key('ghost__exact')
                         .value(ghost__exact))
            .query_param(Parameter()
                         .key('tasks__exact')
                         .value(tasks__exact))
            .query_param(Parameter()
                         .key('active_queries__exact')
                         .value(active_queries__exact))
            .query_param(Parameter()
                         .key('subnet_tag__exact')
                         .value(subnet_tag__exact))
            .query_param(Parameter()
                         .key('custom_attributes__exact')
                         .value(custom_attributes__exact))
            .query_param(Parameter()
                         .key('class_type__exact')
                         .value(class_type__exact))
            .query_param(Parameter()
                         .key('domain_name__exact')
                         .value(domain_name__exact))
            .query_param(Parameter()
                         .key('involved_in_tags__exact')
                         .value(involved_in_tags__exact))
            .query_param(Parameter()
                         .key('hosted_tags__icontains')
                         .value(hosted_tags__icontains))
            .query_param(Parameter()
                         .key('id__exact')
                         .value(id__exact))
            .query_param(Parameter()
                         .key('site_id__exact')
                         .value(site_id__exact))
            .query_param(Parameter()
                         .key('timestamp__exact')
                         .value(timestamp__exact))
            .query_param(Parameter()
                         .key('approved__exact')
                         .value(approved__exact))
            .query_param(Parameter()
                         .key('valid__exact')
                         .value(valid__exact))
            .query_param(Parameter()
                         .key('parsed__exact')
                         .value(parsed__exact))
            .query_param(Parameter()
                         .key('special_hint__exact')
                         .value(special_hint__exact))
            .query_param(Parameter()
                         .key('risk_level__exact')
                         .value(risk_level__exact))
            .query_param(Parameter()
                         .key('network_id__exact')
                         .value(network_id__exact))
            .query_param(Parameter()
                         .key('virtual_zone_id__exact')
                         .value(virtual_zone_id__exact))
            .query_param(Parameter()
                         .key('subnet_id__exact')
                         .value(subnet_id__exact))
            .query_param(Parameter()
                         .key('purdue_level__exact')
                         .value(purdue_level__exact))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Single('global'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(GetAssetsResponse.from_dictionary)
        ).execute()

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

        Find Asset By ID

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

        Returns:
            FindAssetByIDResponse: 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/assets/{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(FindAssetByIDResponse.from_dictionary)
            .local_error('400', 'Invalid ID supplied', APIException)
            .local_error('404', 'Asset not found', APIException)
        ).execute()

    def get_assetswith_insights(self,
                                page=None,
                                per_page=None,
                                name__exact=None,
                                ghost__exact=None,
                                risk_level__exact=None,
                                site_name__exact=None,
                                network_id__exact=None,
                                ipv_4__exact=None,
                                ipv_6__exact=None,
                                mac__icontains=None,
                                asset_type__exact=None,
                                os__exact=None,
                                model__icontains=None,
                                vendor__icontains=None,
                                firmware__exact=None,
                                criticality__exact=None,
                                insight_cve_id__exact=None,
                                insight_cvss__exact=None,
                                insight_title__contains=None,
                                insight_published__exact=None,
                                insight_modified__exact=None,
                                insight_status__exact=None,
                                insight_identified_on__exact=None,
                                insight_last_updated__exact=None,
                                insight_comment__contains=None):
        """Does a GET request to /ranger/assets_with_insights.

        Returns Assets with the top 10 highest score Insights. 
        **Note:** The used lookups are optional

        Args:
            page (int, optional): The actual page offset
            per_page (int, optional): The max number of items to be included
                in the results
            name__exact (string, optional): Name of the Asset
            ghost__exact (bool, optional): Indicates if the asset has only
                incoming communication, that is, an asset that has never
                replied
            risk_level__exact (int, optional): Calculation of how vulnerable
                this Asset is to attacks
            site_name__exact (string, optional): Name of the Site to which the
                Asset belongs
            network_id__exact (int, optional): ID of the network to which the
                Asset belongs
            ipv_4__exact (string, optional): An IPv4 address that related to
                the Asset
            ipv_6__exact (string, optional): An IPv6 address that related to
                the Asset
            mac__icontains (string, optional): The MAC address of the device
                (free text)
            asset_type__exact (string, optional): CTD Asset type, for example
                SCADA client, PLC, etc.
            os__exact (string, optional): The name of the operating system
                that runs on the Asset
            model__icontains (string, optional): The name of the Asset's
                model
            vendor__icontains (string, optional): The Asset's vendor name
            firmware__exact (string, optional): The Asset's firmware
            criticality__exact (int, optional): How critical the Asset is to
                the overall operation. **Options:** 1 - Low 2 - Medium 3 -
                High
            insight_cve_id__exact (string, optional): The ID number of the CVE
                connected to the Insight
            insight_cvss__exact (float, optional): The CVE's score
            insight_title__contains (string, optional): The CVE's title
            insight_published__exact (string, optional): The full date when
                the CVE's was published: **Format:** YYYY-MM-DD HH:MM:SS
                **Example:** 2016-11-15 06:20:05
            insight_modified__exact (string, optional): The full date of the
                latest modification made to the CVE by the global provider.
                **Format:** YYYY-MM-DD HH:MM:SS **Example:** 2016-11-15
                06:20:05
            insight_status__exact (int, optional): A number that represents
                the CVE's status.   **Options:**   0 - Open  1- Hidden  2 -
                Completed
            insight_identified_on__exact (string, optional): Timestamp when
                the CVE was identified. **Format:** YYYY-MM-DD**T**HH:MM:SS
                (in UTC) **Example:** 2022-11-01T16:22:05
            insight_last_updated__exact (string, optional): Timestamp when the
                latest change to the CVE was made in the EMC. **Format:**
                YYYY-MM-DD**T**HH:MM:SS+00:00 (in UTC) **Example:**
                2022-11-01T16:22:05+00:00
            insight_comment__contains (string, optional): Last comment
                provided by a user

        Returns:
            AssetsWithInsightsResponse: 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/assets_with_insights')
            .http_method(HttpMethodEnum.GET)
            .query_param(Parameter()
                         .key('page')
                         .value(page))
            .query_param(Parameter()
                         .key('per_page')
                         .value(per_page))
            .query_param(Parameter()
                         .key('name__exact')
                         .value(name__exact))
            .query_param(Parameter()
                         .key('ghost__exact')
                         .value(ghost__exact))
            .query_param(Parameter()
                         .key('risk_level__exact')
                         .value(risk_level__exact))
            .query_param(Parameter()
                         .key('site_name__exact')
                         .value(site_name__exact))
            .query_param(Parameter()
                         .key('network_id__exact')
                         .value(network_id__exact))
            .query_param(Parameter()
                         .key('ipv4__exact')
                         .value(ipv_4__exact))
            .query_param(Parameter()
                         .key('ipv6__exact')
                         .value(ipv_6__exact))
            .query_param(Parameter()
                         .key('mac__icontains')
                         .value(mac__icontains))
            .query_param(Parameter()
                         .key('asset_type__exact')
                         .value(asset_type__exact))
            .query_param(Parameter()
                         .key('os__exact')
                         .value(os__exact))
            .query_param(Parameter()
                         .key('model__icontains')
                         .value(model__icontains))
            .query_param(Parameter()
                         .key('vendor__icontains')
                         .value(vendor__icontains))
            .query_param(Parameter()
                         .key('firmware__exact')
                         .value(firmware__exact))
            .query_param(Parameter()
                         .key('criticality__exact')
                         .value(criticality__exact))
            .query_param(Parameter()
                         .key('insight_cve_id__exact')
                         .value(insight_cve_id__exact))
            .query_param(Parameter()
                         .key('insight_cvss__exact')
                         .value(insight_cvss__exact))
            .query_param(Parameter()
                         .key('insight_title__contains')
                         .value(insight_title__contains))
            .query_param(Parameter()
                         .key('insight_published__exact')
                         .value(insight_published__exact))
            .query_param(Parameter()
                         .key('insight_modified__exact')
                         .value(insight_modified__exact))
            .query_param(Parameter()
                         .key('insight_status__exact')
                         .value(insight_status__exact))
            .query_param(Parameter()
                         .key('insight_identified_on__exact')
                         .value(insight_identified_on__exact))
            .query_param(Parameter()
                         .key('insight_last_updated__exact')
                         .value(insight_last_updated__exact))
            .query_param(Parameter()
                         .key('insight_comment__contains')
                         .value(insight_comment__contains))
            .header_param(Parameter()
                          .key('accept')
                          .value('application/json'))
            .auth(Single('global'))
        ).response(
            ResponseHandler()
            .deserializer(APIHelper.json_deserialize)
            .deserialize_into(AssetsWithInsightsResponse.from_dictionary)
        ).execute()
