"""
    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 WebhooksApi:
    """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 webhooks_create_association_by_id(self, id, association, **kwargs):
        """Create a new association to the specified Webhook

        A global Webhook is associated to the organization and therefore cannot have other associations.<br />              In order to associate a Webhook to an Application or Assetgroup, you should have access to it
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_create_association_by_id(id, association, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param AppScanSaaSModelsV2WebhookAssociation association: New association to create (required)
        :return: AppScanSaaSModelsV2WebhookAssociation
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.webhooks_create_association_by_id_with_http_info(id, association, **kwargs)
        else:
            (data) = self.webhooks_create_association_by_id_with_http_info(
                id, association, **kwargs
            )
            return data

    def webhooks_create_association_by_id_with_http_info(self, id, association, **kwargs):
        """Create a new association to the specified Webhook

        A global Webhook is associated to the organization and therefore cannot have other associations.<br />              In order to associate a Webhook to an Application or Assetgroup, you should have access to it
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_create_association_by_id_with_http_info(id, association, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param AppScanSaaSModelsV2WebhookAssociation association: New association to create (required)
        :return: AppScanSaaSModelsV2WebhookAssociation
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = ["id", "association"]
        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 webhooks_create_association_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 `webhooks_create_association_by_id`"
            )
        # verify the required parameter 'association' is set
        if self.api_client.client_side_validation and (
            "association" not in params or params["association"] is None
        ):
            raise ValueError(
                "Missing the required parameter `association` when calling `webhooks_create_association_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 "association" in params:
            body_params = params["association"]
        # 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/Webhooks/{id}/Associations",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AppScanSaaSModelsV2WebhookAssociation",
            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 webhooks_create_webhook(self, webhook, **kwargs):
        """Create new Webhook

        In order to create a Webhook for the entire Organization (does not belong to a specific AssetGroup), you should have the capability to access cross asset groups resources<br />              If the Webhook is not Global, you will have to associate it to a resource (AssetGroup or Application) after creation.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_create_webhook(webhook, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param AppScanSaaSModelsV2NewWebhook webhook: New Webhook to create (required)
        :return: AppScanSaaSModelsV2Webhook
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.webhooks_create_webhook_with_http_info(webhook, **kwargs)
        else:
            (data) = self.webhooks_create_webhook_with_http_info(webhook, **kwargs)
            return data

    def webhooks_create_webhook_with_http_info(self, webhook, **kwargs):
        """Create new Webhook

        In order to create a Webhook for the entire Organization (does not belong to a specific AssetGroup), you should have the capability to access cross asset groups resources<br />              If the Webhook is not Global, you will have to associate it to a resource (AssetGroup or Application) after creation.
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_create_webhook_with_http_info(webhook, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param AppScanSaaSModelsV2NewWebhook webhook: New Webhook to create (required)
        :return: AppScanSaaSModelsV2Webhook
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

        path_params = {}

        query_params = []

        header_params = {}

        form_params = []
        local_var_files = {}

        body_params = None
        if "webhook" in params:
            body_params = params["webhook"]
        # 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/Webhooks",
            "POST",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AppScanSaaSModelsV2Webhook",
            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 webhooks_delete_association_by_id(self, id, scope, scope_id, **kwargs):
        """Delete an association from the specified Webhook

        In order to remove association you should have access to Scope object (Application or AssetGroup)
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_delete_association_by_id(id, scope, scope_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param str scope: Scope of the association to delete (required)
        :param str scope_id: Scope id (AssetGroup or Application 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.webhooks_delete_association_by_id_with_http_info(
                id, scope, scope_id, **kwargs
            )
        else:
            (data) = self.webhooks_delete_association_by_id_with_http_info(
                id, scope, scope_id, **kwargs
            )
            return data

    def webhooks_delete_association_by_id_with_http_info(self, id, scope, scope_id, **kwargs):
        """Delete an association from the specified Webhook

        In order to remove association you should have access to Scope object (Application or AssetGroup)
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_delete_association_by_id_with_http_info(id, scope, scope_id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param str scope: Scope of the association to delete (required)
        :param str scope_id: Scope id (AssetGroup or Application Id) (required)
        :return: object
                 If the method is called asynchronously,
                 returns the request thread.
        """

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

        collection_formats = {}

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

        query_params = []
        if "scope" in params:
            query_params.append(("scope", params["scope"]))
        if "scope_id" in params:
            query_params.append(("scopeId", params["scope_id"]))

        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/Webhooks/{id}/Associations",
            "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 webhooks_delete_webhook_by_id(self, id, **kwargs):
        """Delete specified Webhook

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

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

    def webhooks_delete_webhook_by_id_with_http_info(self, id, **kwargs):
        """Delete specified Webhook

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

        :param async_req bool
        :param str id: Webhook Id (required)
        :return: AppScanSaaSModelsV2Webhook
                 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 webhooks_delete_webhook_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 `webhooks_delete_webhook_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/Webhooks/{id}",
            "DELETE",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="AppScanSaaSModelsV2Webhook",
            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 webhooks_get_associations_by_id(self, id, **kwargs):
        """Get associations of a Webhook

        A global Webhook is associated to the organization and therefore cannot have other associations.</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.webhooks_get_associations_by_id(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :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.
        :return: list[AppScanSaaSModelsV2WebhookAssociation]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.webhooks_get_associations_by_id_with_http_info(id, **kwargs)
        else:
            (data) = self.webhooks_get_associations_by_id_with_http_info(id, **kwargs)
            return data

    def webhooks_get_associations_by_id_with_http_info(self, id, **kwargs):
        """Get associations of a Webhook

        A global Webhook is associated to the organization and therefore cannot have other associations.</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.webhooks_get_associations_by_id_with_http_info(id, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :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.
        :return: list[AppScanSaaSModelsV2WebhookAssociation]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = [
            "id",
            "top",
            "skip",
            "filter",
            "select",
            "orderby",
            "expand",
        ]
        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 webhooks_get_associations_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 `webhooks_get_associations_by_id`"
            )

        collection_formats = {}

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

        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"]))

        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/Webhooks/{id}/Associations",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="list[AppScanSaaSModelsV2WebhookAssociation]",
            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 webhooks_get_webhooks(self, **kwargs):
        """Get all Webhooks

        This action returns all the web hooks that can be accessed usingthe provided access token</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.webhooks_get_webhooks(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.
        :return: list[AppScanSaaSModelsV2Webhook]
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.webhooks_get_webhooks_with_http_info(**kwargs)
        else:
            (data) = self.webhooks_get_webhooks_with_http_info(**kwargs)
            return data

    def webhooks_get_webhooks_with_http_info(self, **kwargs):
        """Get all Webhooks

        This action returns all the web hooks that can be accessed usingthe provided access token</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.webhooks_get_webhooks_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.
        :return: list[AppScanSaaSModelsV2Webhook]
                 If the method is called asynchronously,
                 returns the request thread.
        """

        all_params = [
            "top",
            "skip",
            "filter",
            "select",
            "orderby",
            "expand",
        ]
        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 webhooks_get_webhooks" % 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"]))

        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/Webhooks",
            "GET",
            path_params,
            query_params,
            header_params,
            body=body_params,
            post_params=form_params,
            files=local_var_files,
            response_type="list[AppScanSaaSModelsV2Webhook]",
            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 webhooks_update_webhook_by_id(self, id, webhook_model, **kwargs):
        """Update specified Webhook

        If a webhook is set to Global, it will affect all the relevant items that belong to the AssetGroup or to the Organization if the Webhook is defined in the organization level
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_update_webhook_by_id(id, webhook_model, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param AppScanSaaSModelsV2UpdateWebhook webhook_model: Webhook properties to update (required)
        :return: AppScanSaaSModelsV2Webhook
                 If the method is called asynchronously,
                 returns the request thread.
        """
        kwargs["_return_http_data_only"] = True
        if kwargs.get("async_req"):
            return self.webhooks_update_webhook_by_id_with_http_info(id, webhook_model, **kwargs)
        else:
            (data) = self.webhooks_update_webhook_by_id_with_http_info(id, webhook_model, **kwargs)
            return data

    def webhooks_update_webhook_by_id_with_http_info(self, id, webhook_model, **kwargs):
        """Update specified Webhook

        If a webhook is set to Global, it will affect all the relevant items that belong to the AssetGroup or to the Organization if the Webhook is defined in the organization level
        This method makes a synchronous HTTP request by default. To make an
        asynchronous HTTP request, please pass async_req=True
        >>> thread = api.webhooks_update_webhook_by_id_with_http_info(id, webhook_model, async_req=True)
        >>> result = thread.get()

        :param async_req bool
        :param str id: Webhook Id (required)
        :param AppScanSaaSModelsV2UpdateWebhook webhook_model: Webhook properties to update (required)
        :return: AppScanSaaSModelsV2Webhook
                 If the method is called asynchronously,
                 returns the request thread.
        """

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