"""
    HCL AppScan on Cloud (v2)

    This API allows you to interact with the service. The API allows you to perform many of the operations available in the UI and more.</br>For authentication, use the relevant APIs in the Account section. A successful authentication response includes a bearer token for use in subsequent API calls. Pasting this token in the 'Access token' field above will automatically add the authorization header to any API call that requires a valid session.

    OpenAPI spec version: v2

    Generated by: https://github.com/swagger-api/swagger-codegen.git
"""


import re  # noqa: F401

# python 2 and python 3 compatibility library
from pyasoc.api_client import ApiClient


class ToolsApi:
    """NOTE: This class is auto generated by the swagger code generator program.

    Do not edit the class manually.
    Ref: https://github.com/swagger-api/swagger-codegen
    """

    def __init__(self, api_client=None):
        if api_client is None:
            api_client = ApiClient()
        self.api_client = api_client

    def tools_download(self, **kwargs):
        """Download IAST Agent

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_download(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str type: Agent type (Java or DotNet)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.tools_download_with_http_info(**kwargs)
        else:
            (data) = self.tools_download_with_http_info(**kwargs)
            return data

    def tools_download_with_http_info(self, **kwargs):
        """Download IAST Agent

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_download_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str type: Agent type (Java or DotNet)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["type"]
        all_params.append("async_req")
        all_params.append("_return_http_data_only")
        all_params.append("_preload_content")
        all_params.append("_request_timeout")

        params = locals()
        for key, val in params["kwargs"].items():
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'" " to method tools_download" % key
                )
            params[key] = val
        del params["kwargs"]

        collection_formats = {}

        path_params = {}

        query_params = []
        if "type" in params:
            query_params.append(("type", params["type"]))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/octet-stream"])

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/Tools/IAST/Download",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="file",
            auth_settings=auth_settings,
            async_req=params.get("async_req"),
            _return_http_data_only=params.get("_return_http_data_only"),
            _preload_content=params.get("_preload_content", True),
            _request_timeout=params.get("_request_timeout"),
            collection_formats=collection_formats,
        )

    def tools_download_with_key(self, scan_id, **kwargs):
        """Download IAST agent with access key.

        Note: This operation invalidates the previous key.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_download_with_key(scan_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str scan_id: Scan identifier (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.tools_download_with_key_with_http_info(scan_id, **kwargs)
        else:
            (data) = self.tools_download_with_key_with_http_info(scan_id, **kwargs)
            return data

    def tools_download_with_key_with_http_info(self, scan_id, **kwargs):
        """Download IAST agent with access key.

        Note: This operation invalidates the previous key.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_download_with_key_with_http_info(scan_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str scan_id: Scan identifier (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["scan_id"]
        all_params.append("async_req")
        all_params.append("_return_http_data_only")
        all_params.append("_preload_content")
        all_params.append("_request_timeout")

        params = locals()
        for key, val in params["kwargs"].items():
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tools_download_with_key" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'scan_id' is set
        if self.api_client.client_side_validation and (
            "scan_id" not in params or params["scan_id"] is None
        ):
            raise ValueError(
                "Missing the required parameter `scan_id` when calling `tools_download_with_key`"
            )

        collection_formats = {}

        path_params = {}

        query_params = []
        if "scan_id" in params:
            query_params.append(("scanId", params["scan_id"]))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/octet-stream"])

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/Tools/IAST/DownloadWithKey",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="file",
            auth_settings=auth_settings,
            async_req=params.get("async_req"),
            _return_http_data_only=params.get("_return_http_data_only"),
            _preload_content=params.get("_preload_content", True),
            _request_timeout=params.get("_request_timeout"),
            collection_formats=collection_formats,
        )

    def tools_presence_v2_by_platform(self, platform, **kwargs):
        """Download Presence V2 package

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_presence_v2_by_platform(platform, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str platform: Platform - osx_x64 is not yet supported !! (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.tools_presence_v2_by_platform_with_http_info(platform, **kwargs)
        else:
            (data) = self.tools_presence_v2_by_platform_with_http_info(platform, **kwargs)
            return data

    def tools_presence_v2_by_platform_with_http_info(self, platform, **kwargs):
        """Download Presence V2 package

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_presence_v2_by_platform_with_http_info(platform, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str platform: Platform - osx_x64 is not yet supported !! (required)
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["platform"]
        all_params.append("async_req")
        all_params.append("_return_http_data_only")
        all_params.append("_preload_content")
        all_params.append("_request_timeout")

        params = locals()
        for key, val in params["kwargs"].items():
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tools_presence_v2_by_platform" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'platform' is set
        if self.api_client.client_side_validation and (
            "platform" not in params or params["platform"] is None
        ):
            raise ValueError(
                "Missing the required parameter `platform` when calling `tools_presence_v2_by_platform`"
            )

        collection_formats = {}

        path_params = {}
        if "platform" in params:
            path_params["platform"] = params["platform"]

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/octet-stream"])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(
            "/api/V2/Tools/PresenceV2/{platform}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="file",
            auth_settings=auth_settings,
            async_req=params.get("async_req"),
            _return_http_data_only=params.get("_return_http_data_only"),
            _preload_content=params.get("_preload_content", True),
            _request_timeout=params.get("_request_timeout"),
            collection_formats=collection_formats,
        )

    def tools_traffic_recorder_by_platform(self, platform, **kwargs):
        """Download a Standalone Traffic Recorder - used for recording traffic for dast scans.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_traffic_recorder_by_platform(platform, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str platform: Platform (required)
        :param bool version: If this parameter is provided with value true, only the version id is returned
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.tools_traffic_recorder_by_platform_with_http_info(platform, **kwargs)
        else:
            (data) = self.tools_traffic_recorder_by_platform_with_http_info(platform, **kwargs)
            return data

    def tools_traffic_recorder_by_platform_with_http_info(self, platform, **kwargs):
        """Download a Standalone Traffic Recorder - used for recording traffic for dast scans.

        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.tools_traffic_recorder_by_platform_with_http_info(platform, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str platform: Platform (required)
        :param bool version: If this parameter is provided with value true, only the version id is returned
        :return: file
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["platform", "version"]
        all_params.append("async_req")
        all_params.append("_return_http_data_only")
        all_params.append("_preload_content")
        all_params.append("_request_timeout")

        params = locals()
        for key, val in params["kwargs"].items():
            if key not in all_params:
                raise TypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method tools_traffic_recorder_by_platform" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'platform' is set
        if self.api_client.client_side_validation and (
            "platform" not in params or params["platform"] is None
        ):
            raise ValueError(
                "Missing the required parameter `platform` when calling `tools_traffic_recorder_by_platform`"
            )

        collection_formats = {}

        path_params = {}
        if "platform" in params:
            path_params["platform"] = params["platform"]

        query_params = []
        if "version" in params:
            query_params.append(("version", params["version"]))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(["application/octet-stream"])

        # Authentication setting
        auth_settings = []

        return self.api_client.call_api(
            "/api/V2/Tools/TrafficRecorder/{platform}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="file",
            auth_settings=auth_settings,
            async_req=params.get("async_req"),
            _return_http_data_only=params.get("_return_http_data_only"),
            _preload_content=params.get("_preload_content", True),
            _request_timeout=params.get("_request_timeout"),
            collection_formats=collection_formats,
        )
