Child pages
  • UAPI Functions - NVData::get
Skip to end of metadata
Go to start of metadata

Description

This function retrieves data from a non-volatile datastore. The system stores these files in the /home/user/.cpanel/nvdata directory, where user represents the account name.

Note:

We deprecated this function in cPanel & WHM version 74. Instead, we recommend that you use the UAPI Functions - Personalization::get function.


Examples 


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/NVData/get?names=testfile


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.
 
// Get the NVData file "testfile".
$get_nvdata = $cpanel->uapi(
    'NVData', 'get',
    array(
        'names'    => 'testfile',
    )
);


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.
 
# Get the NVData file "testfile".
my $get_nvdata = $cpliveapi->uapi(
    'NVData', 'get',
    {
        'names'    => 'testfile',
    }
);


Note:

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

 

 cPanel Template Toolkit
<!--  Get the minimum password strength for webdisk. -->
[% data = execute( 'NVData', 'get', { names => 'testfile'} ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]


Note:

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

 

 Command Line
uapi --user=username NVData get names=testfile


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. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
  "messages": null,
  "errors": null,
  "status": 1,
  "data": [
    {
      "value": "testvalue",
      "name": "testfile"
    }
  ],
  "metadata": {
    "transformed": 1
  }
}


Note:

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

   

Parameters

ParameterTypeDescriptionPossible valuesExample
namesstring

Required

The file or files to retrieve.

A valid file path, relative to the /home/user/.cpanel/nvdata directory, where user represents the cPanel user.

Note:

To retrieve multiple files, separate each file with a pipe (|) character.

testfile

 

Returns

ReturnTypeDescriptionPossible valuesExample
 array of hashesAn array of hashes that contains information about the non-volatile data.This array of hashes includes the name and value returns. 

name

string

The file's name.

The function returns this value in the unnamed hash.

A valid string.testfile

value

string

The file's contents.

The function returns this value in the unnamed hash.

A valid string.
testvalue