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

Description

This function creates a non-volatile datastore. The system creates the datastore in the /home/user/.cpanel/nvdata directory, where user represents the account name.

 

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/NVData/set?names=testfile1%7Ctestfile2&testfile1=some_data&testfile2=more_data

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.
 // Create the NVData file "testfile1" and "testfile2".
my $set_nvdata = $cpanel->uapi(
    'NVData', 'set', 
    array(
        'names' => 'testfile1|testfile2',
        'testfile1' => 'some_data',
        'testfile2'=> 'more_data'
    ) 
);

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.

# Create the NVData file "testfile1" and "testfile2".
my $set_nvdata = $cpliveapi->uapi(
    'NVdata', 'set',
    {
        'names' => 'testfile1|testfile2',
        'testfile1' => 'some_data',
        'testfile2'=> 'more_data'
    }
);

Note:

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

 

 cPanel Template Toolkit
<!--  Create the NVData file "testfile1" and "testfile2". -->
[% data = execute( 'NVdata', 'set', { names => 'testfile|testfile2', 'testfile1' => 'some_data', 'testfile2' => 'more_data'} ); %]
[% FOREACH q = data %]
     <p>
         [% q %]
     </p>
[% END %]

Note:

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

 

 Command Line
uapi --user=username NVData set names=testfile1%7Ctestfile2 testfile1=some_data testfile2=more_data

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": [
    {
      "set": "testfile1"
    },
    {
      "set": "testfile2"
    }
  ]
}


Note:

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

   

Parameters

ParameterTypeDescriptionPossible valuesExample

names

 

string

Required

The name of the non-volatile data file that you wish to create.

 

A pipe-separated list of valid filenames to create.

testfile1|testfile2

file

string

Required

The content that you wish to save in the non-volatile data file.

Note:

This parameter's name is the name of a file that you listed in the  names  parameter's value.

A valid string.

 

some_data

Returns

ParameterTypeDescriptionPossible valuesExample
 array of hashesAn array of hashes that contains information about the non-volatile data.This array of hashes includes the set return. 

set

string

The name of the non-volatile file that you created.

The function returns this value in the unnamed hash.

A valid file name.

testfile1