Child pages
  • WHM API 1 Functions - list_hooks
Skip to end of metadata
Go to start of metadata

 

Description

This function lists the server's script hooks.

Examples


 JSON API
https://hostname.example.com:2087/cpsess##########/json-api/list_hooks?api.version=1
 XML API
https://hostname.example.com:2087/cpsess##########/xml-api/list_hooks?api.version=1
 Command Line
whmapi1 list_hooks


Notes:

  • You must URI-encode values.
  • For more information and additional output options, read our Guide to WHM API 1 documentation or run the whmapi1 --help command.
  • If you run CloudLinux™, you must use the full path of the whmapi1 command:

    /usr/local/cpanel/bin/whmapi1

 Output (JSON)
{
  "data": {
    "categories": [
      {
        "events": [
          {
            "stage_order": [
              "pre",
              "post"
            ],
            "stages": [
              {
                "stage": "post",
                "actions": [
                  {
                    "stage": "post",
                    "blocking": 0,
                    "description": null,
                    "event": "MariaDB-server",
                    "exectype": "script",
                    "hook": "/scripts/postcourier-authlibup",
                    "rollback": null,
                    "check": null,
                    "escalateprivs": 0,
                    "weight": 100,
                    "id": "KQVO65K_8MWe__3JMPETn43S",
                    "category": "RPM::Versions",
                    "enabled": 1
                  }
                ],
                "attributes": {
                  "escalateprivs": 0,
                  "blocking": 0
                },
                "description": ""
              }
            ],
            "event": "MariaDB-server"
          },
        ],
        "category": "RPM::Versions"
      }
    ]
  },
  "metadata": {
    "version": 1,
    "reason": "OK",
    "result": 1,
    "command": "list_hooks"
  }
}

 Output (XML)
<result>
    <data>
        <categories>
            <events>
                <stage_order>pre</stage_order>
                <stage_order>post</stage_order>
                <stages>
                    <stage>post</stage>
                    <actions>
                        <stage>post</stage>
                        <blocking>0</blocking>
                        <description/>
                        <event>courier-authlib</event>
                        <exectype>script</exectype>
                        <hook>/scripts/postcourier-authlibup</hook>
                        <rollback/>
                        <check/>
                        <escalateprivs>0</escalateprivs>
                        <weight>100</weight>
                        <id>KQVO65K_8MWe__3JMPETn43S</id>
                        <category>RPM::Versions</category>
                        <enabled>1</enabled>
                    </actions>
                    <attributes>
                        <escalateprivs>0</escalateprivs>
                        <blocking>0</blocking>
                    </attributes>
                    <description/>
                </stages>
                <event>courier-authlib</event>
            </events>
            <category>RPM::Versions</category>
        </categories>
    </data>
    <metadata>
        <version>1</version>
        <reason>OK</reason>
        <result>1</result>
        <command>list_hooks</command>
    </metadata>
</result>


Note:

Use WHM's API Shell interface (WHM >> Home >> Development >> API Shell) to directly test WHM API calls.

   

Parameters

This function does not accept parameters.

Returns

ParameterTypeDescriptionPossible valuesExample
categoriesarrayAn array of hook categories.This array includes the events hash and the category return. 

events

hash

A hash of events.

The function returns this hash in the categories hash.

This hash includes the stage_order, attributes, and event returns and the stages hash. 

stage_order

string

When the hook script is designed to execute.

The function returns this value in the events hash.

  • pre — The script runs before the function.
  • post — The script runs after the function.

Note:

It is possible for a hook script to have both values.

pre

post

stages

hash

A hash of stage information.

The function returns this value in the events hash.

This hash includes the below. 

stage

string

When the hook script will execute.

The function returns this value in the stages hash.

  • pre — The script runs before the function.
  • post — The script runs after the function.
post

actions

hash

A hash of hook script actions.

The function returns this value in the stages hash.

This hash includes the stage, blocking, description, event, exectype, hook, rollback, check, escalateprivs, weight, id, category, and enabled returns. 

stage

string

When the hook script will execute.

The function returns this value in the actions hash.

  • pre — The script runs before the function.
  • post — The script runs after the function.
post

blocking

Boolean

Whether the script hook has a blocking contest.

The function returns this value in the actions hash.

  • 1 — Blocking contest.
  • 0 — No blocking contest.
0

description

string

The hook script's description.

The function returns this value in the actions hash.

A valid string.null

event

string

The event that triggers the script hook.

The function returns this value in the actions hash.

A valid string.MariaDB-server

exectype

string

The type of function that the script hook launches.

The function returns this value in the actions hash.

A valid string.script

hook

string

The hook script.

The function returns this value in the actions hash.

A valid absolute file path./scripts/postcourier-authlibup

rollback

string

A script that can roll back the hook script.

The function returns this value in the actions hash.

A valid absolute file path.null

check

string

A script that runs after the hook script to check the results.

The function returns this value in the actions hash.

A valid absolute file path.null

escalateprivs

Boolean

Whether the hook script will run with escalated root privileges.

The function returns this value in the actions hash.

  • 1 — Runs with escalated privileges.
  • 0 — Does not run with escalated privileges.
0

weight

integer

The priority of the script hook.

The function returns this value in the actions hash.

A valid positive integer, where lower values run before higher values.100

id

string

The script hook's ID.

The function returns this value in the actions hash.

A valid string.KQVO65K_8MWe__3JMPETn43S

category

string

The script hook's category.

The function returns this value in the actions hash.

A valid string.RPM::Versions

enabled

Boolean

Whether the hook script is enabled.

The function returns this value in the actions hash.

  • 1 — Enabled.
  • 0 — Disabled.
1

attributes

hash

A hash of hook script attributes.

The function returns this value in the stages hash. 

This hash includes the escalateprivs and blocking returns below. 

escalateprivs

Boolean

Whether the hook script will run with escalated root privileges.

The function returns this value in the attributes hash.

  • 1 — Runs with escalated privileges.
  • 0 — Does not run with escalated privileges.
0

blocking

Boolean

Whether the script hook contains a blocking context.

The function returns this value in the attributes hash.

  • 1 — Blocking context.
  • 0 — No blocking context.
0

description

string

The hook script's description.

The function returns this value in the stages hash.

A valid string. 

event

string

The event that triggers the script hook.

The function returns this value in the events hash.

A valid string.MariaDB-server

category

string

The script hook's category.

The function returns this value in the categories hash.

A valid string.RPM::Versions