# flake8: noqa: E501 # Copyright (C) 2025 Cetmix OÜ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). from odoo import _ # Default Python code used in Webhook Authenticator DEFAULT_WEBHOOK_AUTHENTICATOR_CODE = _( """# Please refer to the 'Help' tab and documentation for more information. # # You can return authenticator result in the 'result' variable which is a dictionary: # result = {"allowed": , "http_code": , "message": } # default value is {"allowed": False} """ ) # Default Python code help used in Webhook Authenticator DEFAULT_WEBHOOK_AUTHENTICATOR_CODE_HELP = _( """

Help for Webhook Authenticator Python Code

The Python code for the webhook authenticator must return the result variable, which is a dictionary.
Allowed keys:

  • allowed (bool, required): Authentication result. True if allowed, False otherwise.
  • http_code (int, optional): HTTP status code to return if authentication fails (default is 403).
  • message (str, optional): Error message to show to the client.
Examples:
# Allow all requests
result = {"allowed": True}

# Deny with custom code and message
result = {"allowed": False, "http_code": 401, "message": "Unauthorized request"}
        

Available variables:
""" ) # Default Python code used in Webhook DEFAULT_WEBHOOK_CODE = _( """# Please refer to the 'Help' tab and documentation for more information. # # You can return webhook result in the 'result' variable which is a dictionary: # result = {"exit_code": , "message": Help for Webhook Python Code

The webhook Python code must set the result variable, which is a dictionary.
Allowed keys:

  • exit_code (int, optional, default=0): Exit code (0 means success, other values indicate failure).
  • message (str, optional): Message to return in the HTTP response and log.
Example:
# Simple successful result
result = {"exit_code": 0, "message": "Webhook processed successfully"}

# Failure example
result = {"exit_code": 1, "message": "Something went wrong"}
        

Available variables:
""" )