"""
    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 BusinessUnitsApi:
    """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 business_units_create_business_unit(self, new_model, **kwargs):
        """Create a new BusinessUnit

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

        :param async_req bool
        :param AppScanSaaSModelsV2NewBusinessUnitModel new_model:  (required)
        :return: AppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.business_units_create_business_unit_with_http_info(new_model, **kwargs)
        else:
            (data) = self.business_units_create_business_unit_with_http_info(new_model, **kwargs)
            return data

    def business_units_create_business_unit_with_http_info(self, new_model, **kwargs):
        """Create a new BusinessUnit

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

        :param async_req bool
        :param AppScanSaaSModelsV2NewBusinessUnitModel new_model:  (required)
        :return: AppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["new_model"]
        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 business_units_create_business_unit" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'new_model' is set
        if self.api_client.client_side_validation and (
            "new_model" not in params or params["new_model"] is None
        ):
            raise ValueError(
                "Missing the required parameter `new_model` when calling `business_units_create_business_unit`"
            )

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "new_model" in params:
            body_params = params["new_model"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "text/csv"]
        )

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(
            ["application/json", "text/json", "application/x-www-form-urlencoded"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/BusinessUnits",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AppScanSaaSModelsV2BusinessUnitModel",
            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 business_units_delete_business_unit_by_id(self, id, **kwargs):
        """Delete BusinessUnit

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

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

    def business_units_delete_business_unit_by_id_with_http_info(self, id, **kwargs):
        """Delete BusinessUnit

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

        :param async_req bool
        :param str id:  (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["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 business_units_delete_business_unit_by_id" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ("id" not in params or params["id"] is None):
            raise ValueError(
                "Missing the required parameter `id` when calling `business_units_delete_business_unit_by_id`"
            )

        collection_formats = {}

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

        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/json", "text/json", "text/csv"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/BusinessUnits/{id}",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="object",
            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 business_units_get_business_unit_by_id(self, id, **kwargs):
        """Get BusinessUnit by Id

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

        :param async_req bool
        :param str id: BusinessUnit Id (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.business_units_get_business_unit_by_id_with_http_info(id, **kwargs)
        else:
            (data) = self.business_units_get_business_unit_by_id_with_http_info(id, **kwargs)
            return data

    def business_units_get_business_unit_by_id_with_http_info(self, id, **kwargs):
        """Get BusinessUnit by Id

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

        :param async_req bool
        :param str id: BusinessUnit Id (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["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 business_units_get_business_unit_by_id" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ("id" not in params or params["id"] is None):
            raise ValueError(
                "Missing the required parameter `id` when calling `business_units_get_business_unit_by_id`"
            )

        collection_formats = {}

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

        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/json", "text/json", "text/csv"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/BusinessUnits/{id}",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="object",
            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 business_units_get_business_units(self, **kwargs):
        """Get all BusinessUnits

        This action returns all the organization's BusinessUnits</br>OData V3 compliant
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.business_units_get_business_units(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int top: The max number of records. (Up to 5000)
        :param int skip: The number of records to skip.
        :param str filter: A function that must evaluate to true for a record to be returned. (e.g. Name eq 'sam' or Name eq 'dan'). To filter an Id Property, open the model and see if its type is \"string\" or \"string($uuid)\". - For string no change is needed. - For \"string($uuid)\" add \"Guid\" immediately before the string (e.g. Id eq Guid'00000000-0000-0000-0000-000000000000')
        :param str select: Specifies a subset of properties to return.
        :param str orderby: Determines what values are used to order a collection of records. (e.g. Name,Id)
        :param str expand: Specifies the related resources to be included in line with retrieved resources.
        :param str inlinecount: Specifies that the response to the request MUST include the count of the number of entities in the collection of entities.
        :return: SystemWebHttpODataPageResultAppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.business_units_get_business_units_with_http_info(**kwargs)
        else:
            (data) = self.business_units_get_business_units_with_http_info(**kwargs)
            return data

    def business_units_get_business_units_with_http_info(self, **kwargs):
        """Get all BusinessUnits

        This action returns all the organization's BusinessUnits</br>OData V3 compliant
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.business_units_get_business_units_with_http_info(async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param int top: The max number of records. (Up to 5000)
        :param int skip: The number of records to skip.
        :param str filter: A function that must evaluate to true for a record to be returned. (e.g. Name eq 'sam' or Name eq 'dan'). To filter an Id Property, open the model and see if its type is \"string\" or \"string($uuid)\". - For string no change is needed. - For \"string($uuid)\" add \"Guid\" immediately before the string (e.g. Id eq Guid'00000000-0000-0000-0000-000000000000')
        :param str select: Specifies a subset of properties to return.
        :param str orderby: Determines what values are used to order a collection of records. (e.g. Name,Id)
        :param str expand: Specifies the related resources to be included in line with retrieved resources.
        :param str inlinecount: Specifies that the response to the request MUST include the count of the number of entities in the collection of entities.
        :return: SystemWebHttpODataPageResultAppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = [
            "top",
            "skip",
            "filter",
            "select",
            "orderby",
            "expand",
            "inlinecount",
        ]
        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 business_units_get_business_units" % key
                )
            params[key] = val
        del params["kwargs"]

        collection_formats = {}

        path_params = {}

        query_params = []
        if "top" in params:
            query_params.append(("$top", params["top"]))
        if "skip" in params:
            query_params.append(("$skip", params["skip"]))
        if "filter" in params:
            query_params.append(("$filter", params["filter"]))
        if "select" in params:
            query_params.append(("$select", params["select"]))
        if "orderby" in params:
            query_params.append(("$orderby", params["orderby"]))
        if "expand" in params:
            query_params.append(("$expand", params["expand"]))
        if "inlinecount" in params:
            query_params.append(("$inlinecount", params["inlinecount"]))

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "text/csv"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/BusinessUnits",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="SystemWebHttpODataPageResultAppScanSaaSModelsV2BusinessUnitModel",
            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 business_units_post_merge_business_units_by_idtokeep_and_idtomerge(
        self, id_to_keep, id_to_merge, **kwargs
    ):
        """Merge Business Units

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

        :param async_req bool
        :param str id_to_keep:  (required)
        :param str id_to_merge:  (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.business_units_post_merge_business_units_by_idtokeep_and_idtomerge_with_http_info(
                id_to_keep, id_to_merge, **kwargs
            )
        else:
            (
                data
            ) = self.business_units_post_merge_business_units_by_idtokeep_and_idtomerge_with_http_info(
                id_to_keep, id_to_merge, **kwargs
            )
            return data

    def business_units_post_merge_business_units_by_idtokeep_and_idtomerge_with_http_info(
        self, id_to_keep, id_to_merge, **kwargs
    ):
        """Merge Business Units

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

        :param async_req bool
        :param str id_to_keep:  (required)
        :param str id_to_merge:  (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["id_to_keep", "id_to_merge"]
        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 business_units_post_merge_business_units_by_idtokeep_and_idtomerge"
                    % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'id_to_keep' is set
        if self.api_client.client_side_validation and (
            "id_to_keep" not in params or params["id_to_keep"] is None
        ):
            raise ValueError(
                "Missing the required parameter `id_to_keep` when calling `business_units_post_merge_business_units_by_idtokeep_and_idtomerge`"
            )
        # verify the required parameter 'id_to_merge' is set
        if self.api_client.client_side_validation and (
            "id_to_merge" not in params or params["id_to_merge"] is None
        ):
            raise ValueError(
                "Missing the required parameter `id_to_merge` when calling `business_units_post_merge_business_units_by_idtokeep_and_idtomerge`"
            )

        collection_formats = {}

        path_params = {}
        if "id_to_keep" in params:
            path_params["idToKeep"] = params["id_to_keep"]
        if "id_to_merge" in params:
            path_params["idToMerge"] = params["id_to_merge"]

        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/json", "text/json", "text/csv"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/v2/BusinessUnits/Merge/{idToKeep}/{idToMerge}",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="object",
            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 business_units_update_business_unit_by_id(self, id, model, **kwargs):
        """Update BusinessUnit

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

        :param async_req bool
        :param str id:  (required)
        :param AppScanSaaSModelsV2UpdateBusinessUnitModel model:  (required)
        :return: AppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.business_units_update_business_unit_by_id_with_http_info(
                id, model, **kwargs
            )
        else:
            (data) = self.business_units_update_business_unit_by_id_with_http_info(
                id, model, **kwargs
            )
            return data

    def business_units_update_business_unit_by_id_with_http_info(self, id, model, **kwargs):
        """Update BusinessUnit

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

        :param async_req bool
        :param str id:  (required)
        :param AppScanSaaSModelsV2UpdateBusinessUnitModel model:  (required)
        :return: AppScanSaaSModelsV2BusinessUnitModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["id", "model"]
        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 business_units_update_business_unit_by_id" % key
                )
            params[key] = val
        del params["kwargs"]
        # verify the required parameter 'id' is set
        if self.api_client.client_side_validation and ("id" not in params or params["id"] is None):
            raise ValueError(
                "Missing the required parameter `id` when calling `business_units_update_business_unit_by_id`"
            )
        # verify the required parameter 'model' is set
        if self.api_client.client_side_validation and (
            "model" not in params or params["model"] is None
        ):
            raise ValueError(
                "Missing the required parameter `model` when calling `business_units_update_business_unit_by_id`"
            )

        collection_formats = {}

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

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "model" in params:
            body_params = params["model"]
        # HTTP header `Accept`
        header_params["Accept"] = self.api_client.select_header_accept(
            ["application/json", "text/json", "text/csv"]
        )

        # HTTP header `Content-Type`
        header_params["Content-Type"] = self.api_client.select_header_content_type(
            ["application/json", "text/json", "application/x-www-form-urlencoded"]
        )

        # Authentication setting
        auth_settings = ["AccessToken"]

        return self.api_client.call_api(
            "/api/V2/BusinessUnits/{id}",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AppScanSaaSModelsV2BusinessUnitModel",
            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,
        )
