Page tree
Skip to end of metadata
Go to start of metadata

 

Description

This function combines calls for multiple UAPI functions and performs them in order.

Notes:

  • If a function call in the list fails, the Batch::strict function does not run further function calls in the list.
  • Due to the potential length of calls of this function, we recommend that you use the HTTP POST method for extremely long batch commands.

Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/Batch/strict?command-0=%5B%22SSH%22%2C%22get_port%22%2C%7B%7D%5D&command-1=%5B%22PasswdStrength%22%2C%22get_required_strength%22%2C%7B%22app%22%3A%22webdisk%22%7D%5D


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
//Combines multiple UAPI functions.
$batch = $cpanel->uapi(
    'Batch', 'strict',
    array(
        'command-0'        => '["SSH","get_port",{}]',
        'command-1'        => '["PasswdStrength","get_required_strength",{"app":"webdisk"}]',
        )
);

Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Combines multiple UAPI functions.
my $batch = $cpliveapi->uapi(
    'Batch', 'strict',
    {
        'command-0'        => '["SSH","get_port",{}]',
        'command-1'        => '["PasswdStrength","get_required_strength",{"app":"webdisk"}]',
    }
);

Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!-- Combines multiple UAPI functions. -->
[% execute('Batch', 'strict',{'command-0' => '["SSH","get_port",{}]','command-1' =>'["PasswdStrength","get_required_strength",{"app":"webdisk"}]'},) %]

Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username Batch strict command-0=%5B%22SSH%5C%22%2C%22get_port%5C%22%2C%7B%7D%5D command-1=%5B%22PasswdStrength%22%2C%22get_required_strength%22%2C%7B%22app%22%3A%22webdisk%22%7D%5D 

Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • We introduced this functionality in cPanel & WHM version 56.

 Output (JSON)
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  
      "transformed":1
   },
   "data":[  
      {  
         "messages":null,
         "errors":null,
         "status":1,
         "metadata":{  
         },
         "data":{  
            "port":"22"
         }
      },
      {  
         "messages":null,
         "errors":null,
         "status":1,
         "metadata":{  
         },
         "data":{  
            "strength":0
         }
      }
   ]
}

Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
commandstring

Required

A UAPI function to call.

Important

To submit multiple commands via Template Toolkit or the PHP Library, which require that you submit arguments in a hash, increment the parameter name. For example: command-0command-1command-2

It is not necessary to increment the command parameter label for query string calls of this function.

Any UAPI function.

Include the function's URI-encoded input parameters as a JSON-encoded array after the module and function name.

For example, to call the PasswdStrength::get_required_strength function with an app parameter value of webdisk, assign the following value to a command parameter:

 

%5B%22PasswdStrength%22%2C%22get_required_strength%22%2C%7B%22app%22%3A%22webdisk%22%7D%5D

For reference, the non-URI-encoded version is:

["PasswdStrength","get_required_strength",{"app":"webdisk"}]
 


Returns

ReturnTypeDescriptionPossible valuesExample

array of hashes

An array of hashes that contain function output.

This array includes the result hash.

 

result

hash

The results from a function.

The function returns this hash in the unnamed array of hashes.

Each result hash contains the output data and metadata from one of the command parameter's functions.

For more information about UAPI return data and metadata, read our UAPI - Return Data documentation.