"""
    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 DomainsApi:
    """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 domains_delete_domain_by_id(self, id, **kwargs):
        """Delete domain

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

        :param async_req bool
        :param int id: domain 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.domains_delete_domain_by_id_with_http_info(id, **kwargs)
        else:
            (data) = self.domains_delete_domain_by_id_with_http_info(id, **kwargs)
            return data

    def domains_delete_domain_by_id_with_http_info(self, id, **kwargs):
        """Delete domain

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

        :param async_req bool
        :param int id: domain 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 domains_delete_domain_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 `domains_delete_domain_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/Domains/{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 domains_download_file_by_id(self, id, **kwargs):
        """Download domain verification HTML

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

        :param async_req bool
        :param int id: domain 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.domains_download_file_by_id_with_http_info(id, **kwargs)
        else:
            (data) = self.domains_download_file_by_id_with_http_info(id, **kwargs)
            return data

    def domains_download_file_by_id_with_http_info(self, id, **kwargs):
        """Download domain verification HTML

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

        :param async_req bool
        :param int id: domain 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 domains_download_file_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 `domains_download_file_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/Domains/DownloadFile/{id}",
            "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 domains_get_domains_as_page(self, **kwargs):
        """Get domains

        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.domains_get_domains_as_page(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: SystemWebHttpODataPageResultCommonModelsDomainModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.domains_get_domains_as_page_with_http_info(**kwargs)
        else:
            (data) = self.domains_get_domains_as_page_with_http_info(**kwargs)
            return data

    def domains_get_domains_as_page_with_http_info(self, **kwargs):
        """Get domains

        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.domains_get_domains_as_page_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: SystemWebHttpODataPageResultCommonModelsDomainModel
                 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 domains_get_domains_as_page" % 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/Domains",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="SystemWebHttpODataPageResultCommonModelsDomainModel",
            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 domains_resend_mail_by_id(self, id, mail_prefix, **kwargs):
        """Resend domain verification mail

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

        :param async_req bool
        :param int id: domain id (required)
        :param str mail_prefix: mail prefix (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.domains_resend_mail_by_id_with_http_info(id, mail_prefix, **kwargs)
        else:
            (data) = self.domains_resend_mail_by_id_with_http_info(id, mail_prefix, **kwargs)
            return data

    def domains_resend_mail_by_id_with_http_info(self, id, mail_prefix, **kwargs):
        """Resend domain verification mail

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

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

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

        collection_formats = {}

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

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

        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/Domains/ResendMail/{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 domains_update_domain_by_id(self, id, update_model, **kwargs):
        """Update domain

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

        :param async_req bool
        :param int id: Domain Id (required)
        :param CommonModelsUpdateDomainModel update_model:  (required)
        :return: CommonModelsDomainModel
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.domains_update_domain_by_id_with_http_info(id, update_model, **kwargs)
        else:
            (data) = self.domains_update_domain_by_id_with_http_info(id, update_model, **kwargs)
            return data

    def domains_update_domain_by_id_with_http_info(self, id, update_model, **kwargs):
        """Update domain

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

        :param async_req bool
        :param int id: Domain Id (required)
        :param CommonModelsUpdateDomainModel update_model:  (required)
        :return: CommonModelsDomainModel
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["id", "update_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 domains_update_domain_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 `domains_update_domain_by_id`"
            )
        # verify the required parameter 'update_model' is set
        if self.api_client.client_side_validation and (
            "update_model" not in params or params["update_model"] is None
        ):
            raise ValueError(
                "Missing the required parameter `update_model` when calling `domains_update_domain_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 "update_model" in params:
            body_params = params["update_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/Domains/{id}",
            "PUT",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="CommonModelsDomainModel",
            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,
        )
