UAPI Functions - Batch::strict

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

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

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

 cPanel Template Toolkit

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

 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.

 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 (Home >> Advanced >> API Shell) to directly test cPanel API calls.

 

Parameters

 Parameter 

Type

Description

Possible values

Example

command

 string 

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-0, command-1, command-2

It is not necessary to increment thecommand 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

 Return 

Type

Description

Possible values

Example

 

 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. 

 

 

  • 7 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....