UAPI Functions - NVData::set

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

 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'
    )
);

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

 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 %]

 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.

 Output (JSON)

{
  "messages": null,
  "errors": null,
  "status": 1,
  "metadata": {
    "transformed": 1
  },
  "data": [
    {
      "set": "testfile1"
    },
    {
      "set": "testfile2"
    }
  ]
}

 

Note:

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

 

Parameters

 Parameter 

 Type 

Description

Possible values

Example

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 datafile.

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

 Parameter 

Type

Description

Possible values

 Example 

 

 array of hashes 

 An array of hashes that contains information about the non-volatile data. 

 This array of hashes includes theset 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

 

  • 14 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....