Description

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

  • 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 


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


$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"}]',
        )
);

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"}]',
    }
);

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

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 

{  
   "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
         }
      }
   ]
}

Parameters

ParameterTypeDescriptionPossible valuesExample
commandstring

Required

A UAPI function to call.

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.