# coding: utf-8

"""
    Defect Dojo API

    To use the API you need be authorized.  # noqa: E501

    The version of the OpenAPI document: v2
    Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

import re  # noqa: F401

# python 2 and python 3 compatibility library
import six

from openapi_client.api_client import ApiClient
from openapi_client.exceptions import (
    ApiTypeError,
    ApiValueError
)


class ImportScanApi(object):
    """NOTE: This class is auto generated by OpenAPI Generator
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

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

    def import_scan_create(self, scan_type, engagement, **kwargs):  # noqa: E501
        """import_scan_create  # noqa: E501

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

        :param async_req bool: execute request asynchronously
        :param str scan_type: (required)
        :param int engagement: (required)
        :param date scan_date:
        :param str minimum_severity:
        :param bool active:
        :param bool verified:
        :param str test_type:
        :param file file:
        :param int lead:
        :param list[str] tags:
        :param bool close_old_findings:
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: ImportScan
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs['_return_http_data_only'] = True
        return self.import_scan_create_with_http_info(scan_type, engagement, **kwargs)  # noqa: E501

    def import_scan_create_with_http_info(self, scan_type, engagement, **kwargs):  # noqa: E501
        """import_scan_create  # noqa: E501

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

        :param async_req bool: execute request asynchronously
        :param str scan_type: (required)
        :param int engagement: (required)
        :param date scan_date:
        :param str minimum_severity:
        :param bool active:
        :param bool verified:
        :param str test_type:
        :param file file:
        :param int lead:
        :param list[str] tags:
        :param bool close_old_findings:
        :param _return_http_data_only: response data without head status code
                                       and headers
        :param _preload_content: if False, the urllib3.HTTPResponse object will
                                 be returned without reading/decoding response
                                 data. Default is True.
        :param _request_timeout: timeout setting for this request. If one
                                 number provided, it will be total request
                                 timeout. It can also be a pair (tuple) of
                                 (connection, read) timeouts.
        :return: tuple(ImportScan, status_code(int), headers(HTTPHeaderDict))
                 If the method is called asynchronously,
                 returns the request thread.
        """

        local_var_params = locals()

        all_params = ['scan_type', 'engagement', 'scan_date', 'minimum_severity', 'active', 'verified', 'test_type', 'file', 'lead', 'tags', 'close_old_findings']  # noqa: E501
        all_params.append('async_req')
        all_params.append('_return_http_data_only')
        all_params.append('_preload_content')
        all_params.append('_request_timeout')

        for key, val in six.iteritems(local_var_params['kwargs']):
            if key not in all_params:
                raise ApiTypeError(
                    "Got an unexpected keyword argument '%s'"
                    " to method import_scan_create" % key
                )
            local_var_params[key] = val
        del local_var_params['kwargs']
        # verify the required parameter 'scan_type' is set
        if ('scan_type' not in local_var_params or
                local_var_params['scan_type'] is None):
            raise ApiValueError("Missing the required parameter `scan_type` when calling `import_scan_create`")  # noqa: E501
        # verify the required parameter 'engagement' is set
        if ('engagement' not in local_var_params or
                local_var_params['engagement'] is None):
            raise ApiValueError("Missing the required parameter `engagement` when calling `import_scan_create`")  # noqa: E501

        if ('test_type' in local_var_params and
                len(local_var_params['test_type']) < 1):
            raise ApiValueError("Invalid value for parameter `test_type` when calling `import_scan_create`, length must be greater than or equal to `1`")  # noqa: E501
        if ('tags' in local_var_params and
                len(local_var_params['tags']) < 1):
            raise ApiValueError("Invalid value for parameter `tags` when calling `import_scan_create`, length must be greater than or equal to `1`")  # noqa: E501
        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}
        if 'scan_date' in local_var_params:
            form_params.append(('scan_date', local_var_params['scan_date']))  # noqa: E501
        if 'minimum_severity' in local_var_params:
            form_params.append(('minimum_severity', local_var_params['minimum_severity']))  # noqa: E501
        if 'active' in local_var_params:
            form_params.append(('active', local_var_params['active']))  # noqa: E501
        if 'verified' in local_var_params:
            form_params.append(('verified', local_var_params['verified']))  # noqa: E501
        if 'scan_type' in local_var_params:
            form_params.append(('scan_type', local_var_params['scan_type']))  # noqa: E501
        if 'test_type' in local_var_params:
            form_params.append(('test_type', local_var_params['test_type']))  # noqa: E501
        if 'file' in local_var_params:
            local_var_files['file'] = local_var_params['file']  # noqa: E501
        if 'engagement' in local_var_params:
            form_params.append(('engagement', local_var_params['engagement']))  # noqa: E501
        if 'lead' in local_var_params:
            form_params.append(('lead', local_var_params['lead']))  # noqa: E501
        if 'tags' in local_var_params:
            form_params.append(('tags', local_var_params['tags']))  # noqa: E501
            collection_formats['tags'] = 'csv'  # noqa: E501
        if 'close_old_findings' in local_var_params:
            form_params.append(('close_old_findings', local_var_params['close_old_findings']))  # noqa: E501

        body_params = None
        # HTTP header `Accept`
        header_params['Accept'] = self.api_client.select_header_accept(
            ['application/json'])  # noqa: E501

        # HTTP header `Content-Type`
        header_params['Content-Type'] = self.api_client.select_header_content_type(  # noqa: E501
            ['multipart/form-data'])  # noqa: E501

        # Authentication setting
        auth_settings = ['api_key']  # noqa: E501

        return self.api_client.call_api(
            '/import-scan/', 'POST',
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type='ImportScan',  # noqa: E501
            auth_settings=auth_settings,
            async_req=local_var_params.get('async_req'),
            _return_http_data_only=local_var_params.get('_return_http_data_only'),  # noqa: E501
            _preload_content=local_var_params.get('_preload_content', True),
            _request_timeout=local_var_params.get('_request_timeout'),
            collection_formats=collection_formats)
