You can find our user documentation at docs.cpanel.net.

Check out our new API beta site!

Child pages
  • UAPI Functions - DirectoryPrivacy::list_directories
Skip to end of metadata
Go to start of metadata

Description

This function returns the privacy status of the subdirectories in a directory.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/DirectoryPrivacy/list_directories?dir=/home/example/example.com


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.
 
// Retrieve a list of subdirectories for the /home/example/example.com directory.
$list_directories = $cpanel->uapi(
    'DirectoryPrivacy', 'list_directories',
    array(
        'dir'    		   => '/home/example/example.com',
  )
);


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.
 
# Retrieve a list of subdirectories for the /home/example/example.com directory.
my $list_direcotries = $cpliveapi->uapi(
    'DirectoryPrivacy', 'list_directories',
    {
        'dir'   		   => '/home/example/example.com',
    }
);


Note:

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

 

 Command Line
uapi --user=username DirectoryPrivacy list_directories dir=/home/example/example.com


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)
{
  "errors": null,
  "metadata": {
    
  },
  "messages": null,
  "status": 1,
  "warnings": null,
  "data": {
    "current": {
      "state": {
        "auth_name": "",
        "passwd_file": "",
        "protected": 0,
        "auth_type": "None"
      },
      "path": "/home/example/example.com"
    },
    "home": {
      "state": {
        "auth_type": "Basic",
        "passwd_file": "/home/example/.htpasswds/passwd",
        "protected": 1,
        "auth_name": "protected"
      },
      "path": "/home/example"
    },
    "parent": {
      "path": "/home/example",
      "state": {
        "auth_type": "Basic",
        "passwd_file": "/home/example/.htpasswds/passwd",
        "protected": 1,
        "auth_name": "protected"
      }
    },
    "children": [
      {
        "state": {
          "auth_type": "None",
          "protected": 0,
          "auth_name": "",
          "passwd_file": ""
        },
        "path": "/home/example/example.com/example"
      }
    ]
  }
}


Note:

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

Parameters

ParameterTypeDescriptionPossible valuesExample
dirstring

Required

The directory for which to return the subdirectories' privacy information.

A valid directory path on the cPanel account./home/example/example.com

Returns

ReturnTypeDescriptionPossible valuesExample
currenthashThe user's current directory and its privacy information.This hash contains the state hash and path return.

state

hash

The current subdirectory's privacy information.

The function returns this value in the current array of hashes.

This hash contains the auth_nameauth_typepasswd_file, and protected returns.

auth_name

string

The authentication resource name.

The function returns this value in the state hash.

A valid string.protected 

auth_type

string

The directory's authentication type.

The function returns this value in the state hash.

  • Basic 
  • None 
Basic 

passwd_file

string

The directory's password file.

The function returns this value in the state hash.

A valid absolute file path./home/example/.htpasswds/example.com/passwd

protected

Boolean

Whether the directory is protected.

The function returns this value in the state hash.

  • 1 — Protected.
  • 0 — Not protected.
1 

path 

string

The current directory's path.

The function returns this value in the current array of hashes.

A valid absolute directory path.

/home/example/example.com 
home hashThe user's home directory and its privacy information.This hash contains the state hash and path return.

state 

hash

The home directory's privacy information.

The function returns this value in the home array of hashes.

This hash contains the auth_nameauth_typepasswd_file, and protected returns.

auth_name

string

The authentication resource name.

The function returns this value in the state hash.

A valid string.protected 

auth_type

string

The home directory's authentication type.

The function returns this value in the state hash.

  • Basic 
  • None 
Basic 

passwd_file

string

The home directory's password file.

The function returns this value in the state hash.

A valid absolute file path./home/example/.htpasswds/example.com/passwd

protected

Boolean

Whether the home directory is protected.

The function returns this value in the state hash.

  • 1 — Protected.
  • 0 — Not protected.
1 

path 

string

The home directory's path.

The function returns this value in the home array of hashes.

A valid absolute directory path./home/example 
parent hashThe parent directory of the current directory and its privacy information.This hash contains the state hash and path return.

state 

hash

The parent directory's privacy information.

The function returns this value in the parent hash.

This hash contains the auth_nameauth_typepasswd_file, and protected returns.

auth_name

string

The authentication resource name.

The function returns this value in the state hash.

A valid string.protected 

auth_type

string

The parent directory's authentication type.

The function returns this value in the state hash.

  • Basic 
  • None 
Basic 

passwd_file

string

The parent directory's password file.

The function returns this value in the state hash.

A valid absolute file path./home/example/.htpasswds/example.com/passwd

protected

Boolean

Whether the subdirectory is protected.

The function returns this value in the state hash.

  • 1 — Protected.
  • 0 — Not protected.
1 

path

string

The parent directory's directory path.

The function returns this value in the parent hash.

A valid absolute directory path./home/example
children array of hashes

A list of subdirectories and their privacy information.

Note:

The function returns this hash for each subdirectory in a directory.

This array of hashes contains the state hash and path returns.

state

hash

The subdirectory's privacy information.

The function returns this value in the children array of hashes.

This hash contains the auth_nameauth_typepasswd_file, and protected returns.

auth_name

string

The authentication resource name.

The function returns this value in the state hash.

A valid string.Protected 'example.com' 

auth_type

string

The subdirectory's authentication type.

The function returns this value in the state hash.

  • Basic 
  • None 
Basic 

passwd_file

string

The subdirectory's password file.

The function returns this value in the state hash.

A valid absolute file path./home/example/.htpasswds/example.com/passwd

protected

Boolean

Whether the subdirectory is protected.

The function returns this value in the state hash.

  • 1 — Protected.
  • 0 — Not protected.
1

path

string

The subdirectory's directory path.

The function returns this value in the children array of hashes.

A valid absolute directory path./home/example/example.com/cgi-bin