View Source

The following example demonstrates how to delete resellers, Power Users, and their associations. A PHP file called {{Delete_Reseller_Power_User_And_Their_Associations.php}} can be found here:

* for Windows: {{<installdir>\apisamples}}
* for Linux: {{<installdir>/apisamples}}

Read more in [Access example API functions].

The PHP script finds and deletes objects in the system and prints the following result messages on the screen:
* "Successfully retrieved all the users" / "No user found with the specified ID" / "Failed to get the specified user"
* "Successfully retrieved all the agents" / "No Agents are owned by the specified user" / "Failed to get the specified agent"
* "Successfully retrieved all the volumes" / "No Volumes are exclusively assigned to the specified user" / "Failed to get all volumes"
* "Successfully retrieved all the diskSafes" / "No Disksafes are associated with the agents owned by the user" / "Failed to get all Disk Safes"
* "Successfully retrieved all the policies" / "No Policies are associated with the disksafe assigned to the agents owned by the user" / "Failed to get all the policies"
* "Failed to delete user" / "User deleted successfully"
* "Failed to delete all policie(s)" / "All policie(s) deleted successfully"
* "Failed to delete all Disk Safe(s)" / "All Disk Safe(s) deleted successfully"
* "Failed to delete all agent(s)" / "All agent(s) deleted successfully"
* "Failed to delete all Volume(s)" / "All Volume(s) deleted successfully"

h4. Sequence of Automated Actions

The following steps can be accomplished by using this script:

# Get a user with the specified ID. If the ID does not exist, then exit or store the user ID.
# Get Agent IDs which have the specified user ID as their owner. Store all of these Server IDs.
# Get Disk Safes which have the specified Agent ID. Store the Disk Safe IDs.
# Get policies which contain Disk Safe IDs in the Disk Safe IDs list. Then store the Policy IDs.
# Delete all Policies using the Policy IDs stored in the above step.
# Delete all Disk Safes using the Disk Safe IDs stored in the above step.
# Delete the Agent using the stored Agent ID.
# Delete the Volume using the stored Volume ID.
# Delete the User using the stored User ID.




h4. How to Fulfill Appropriate Actions in the Server Backup User Interface

Below, you can find the steps to take in the program user interface in order to perform the same actions as the script. We also provide you with screen-shots illustrating the scripts for every step.

----
{toc:location=top|maxLevel=5|minLevel=5|type=flat|separator=pipe|style=border:1}
----
h5. Defining Server Configuration Parameters
{code}
date_default_timezone_set('America/Chicago');


########====CDP Server Configuration Start====########
#set CDP server host name
$HOST="127.0.0.1";
#set CDP server to access API
$PORT="9443";
#set CDP user
$USER="admin";
#set CDP user password
$PASS="admin";
########====CDP Server Configuration End====########



########====SetUser ID to be deleted Start====########
$ID = "dcad5f7c-27d0-46d0-86b2-24741b6bf25f";
########====SetUser ID to be deleted End====########

{code}

!Enterprise_login form_English.png!

h5. Retrieving a User

{code}
########====Get User Start====########

try{
$userClient = new soapclient("https://$HOST:$PORT/User?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
)
);
# get all the Users
$allUsers=$userClient->getUsers();
echo "Successfully retrived all the users \n";

foreach($allUsers->return as $tmp) {
// check to see if the specified user id matches the any of the retrived user ids
if (isset($tmp->id) && $tmp->id == $ID){
// if it matches store the id
$selectedUserID = $tmp->id;
break;
}
}

// if nothing matches then exit the program
if (!isset($selectedUserID)){
echo " No user found with the specified ID $ID \n" ;
exit(1);
}
}
catch (SoapFault $exception)
{
echo "Failed to get the specified user \n";
echo $exception;
exit(1);
}

########====Get User End====########

{code}



1.1 Get the User with the specified ID.

To find a User by username, follow the instructions below.


{info:title=Note}While the script searches by User ID, we search by username in the Backup Manager interface. {info}
!Main menu_Users_English.png!

1.2 Click on "Basic List Filter" located in the Users sub-menu.




!users-filter.png!

1.3 Enter a username, select the "Power-User" check-box, and click "Filter".

!Servers menu_Basic List Filter_User Name and Type selected_English.png!

1.4 The found Users are displayed in the list.

!Users list_user found_English.png!



h5. Retrieving Servers
{code}
########====Get Agent Start====########

try{
$agentClient = new soapclient("https://$HOST:$PORT/Agent?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS
)
);
# get all the agents
$allAgents=$agentClient->getAgents();
echo "Successfully retrived all the agents \n";
$selectedAgentIDs = array();
foreach($allAgents->return as $tmp) {
// check to see if the specified agent has the specified user as owner
if (isset($tmp->ownerId) && $tmp->ownerId == $selectedUserID){
// if it matches store the id
array_push($selectedAgentIDs, $tmp->id);
}
}

if (!isset($selectedAgentIDs) || count($selectedAgentIDs) == 0){
echo " No Agents are owned by the specified user \n" ;
}
}
catch (SoapFault $exception)
{
echo "Failed to get the specified agent \n";
echo $exception;
exit(1);
}

########====Get Agent End====########

{code}


Get all Servers which have the specified user ID as their owner.

Select the "Servers" tab to list all associated Servers.


!Users list_User details pane_Servers tab outlined_English.png!



h5. Retrieve Disk Safes

{code}
########====Get Volumes Start====########

try {
$volumeClient = new soapclient("https://$HOST:$PORT/Volume?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'trace'=>1)
);

$allVolumes=$volumeClient->getVolumes();
echo "Successfully retrived all the volumes \n";
$selectedVolumeIDs = array();
foreach($allVolumes->return as $tmp) {
// check if the user is assigned the volume and the user is the only user in the assigned list
if (isset($tmp->userIDs) && count($tmp->userIDs) == 1 && in_array($selectedUserID, $tmp->userIDs)) {
// if the above condition is true put the volume in the volume id in the selectedVolume list
array_push($selectedVolumeIDs, $tmp->id);
}
}
if (!isset($selectedVolumeIDs) || count($selectedVolumeIDs) == 0){
echo " No Volumes are exclusively assigned to the specified user \n" ;
}
}
catch (SoapFault $exception)
{
echo "Failed to get all volumes \n";
echo $exception;
exit(1);
}

########====Get Volumes Start====########



########====Get DiskSafes Start====########

try{

$diskSafeClient = new soapclient("https://$HOST:$PORT/DiskSafe?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS)
);

// retrive all the ids
$allDiskSafes = $diskSafeClient->getDiskSafes();
echo "Successfully retrived all the diskSafes \n";
$selectedDiskSafeIDs = array();
foreach($allDiskSafes->return as $tmp) {
// check if the disksafe has a valid agent set and it's id == the agent to be deleted
if (isset($tmp->agentID) && in_array($tmp->agentID, $selectedAgentIDs)){
// if the condition is true store then store the ids
array_push($selectedDiskSafeIDs, $tmp->id);
}
}
if (!isset($selectedDiskSafeIDs) || count($selectedDiskSafeIDs) == 0){
echo " No Disksafes are associated with the agents owned by the user \n" ;
}

}
catch (SoapFault $exception)
{
echo "Failed to get all diskSafes \n";
echo $exception;
exit(1);
}

########====Get DiskSafes End====########





{code}


1. Select the "Volumes" tab to list all assigned Volumes.

!Users list_User details pane_Volumes tab outlined_English.png!

2. Click on the "Detail" icon in front of the Volume to drill down to the Disk Safes.

!Users list_User details pane_Volumes tab_Detail icon_English.png!


3. In the displayed window, select the "Disk Safes" tab to list the Disk Safes assigned to the selected Volume.

!ds-tab.png!






h5. Retrieving Policies

{code}
########====Get policies Start====########

if (count($selectedDiskSafeIDs) > 0){
try{
$policyClient = new soapclient("https://$HOST:$PORT/Policy2?wsdl",
array(
'login'=>"$USER",
'password'=>"$PASS",
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS,
'trace'=>1
)
);
// get all the policies
$allPolicies = $policyClient->getPolicies();

echo "Successfully retrived all the policies \n";
$selectedPolicyIDs = array();
foreach($allPolicies->return as $tmp) {
// check to see if disksafe id of the policy belongs in the list selectedDiskSafeIDs
if (in_array($tmp->diskSafeID, $selectedDiskSafeIDs)){
// if the condition is true save the policy id
array_push($selectedPolicyIDs, $tmp->id);
}
}
if (!isset($selectedPolicyIDs) || count($selectedPolicyIDs) == 0){
echo " No Policies are associated with the disksafe assigned to the agents owned by the user \n" ;
}

}
catch (SoapFault $exception)
{
echo "Failed to get all the policies \n";
echo $exception;
exit(1);
}
}

########====Get Policies End====########

{code}


Get all policies which contain Disk Safe IDs in the Disk Safe IDs list. Then store all of the Policy IDs.

h5. Deleting the User and its Associations

{code}
########====Delete User Start====########
try {
# finally delete the specified user
$userClient->deleteUserByID(array('userID'=>$selectedUserID));
}
catch (SoapFault $exception)
{
echo "Failed to delete user\n";
echo $exception;
exit(1);
}
echo "User deleted Successfully \n";

########====Delete User End====########{code}
1. Click on the "Delete" (red X) icon under "Actions" for the corresponding User in the list.

!Users list_user found_Delete icon_English.png!

Alternatively, select the check-box(es) in front of the Users and click on the "Delete Selected" button.

!Users list_user found_DeleteSelected button_English.png!


2. Familiarize yourself with the information displayed on the pop-up. Click "Delete".


!Delete User window_Delete button_English.png!

{info:title=Title}

You can choose to remove any object along with the power-user. For that click the "plus" sign to expand the tree, choose an item you need and click the "Delete" button.

!Delete User window_expanded_Delete button_English.png!
{info}

3.&nbsp;Click "OK" in the appeared window with successful result.


!Successfully deleted user_English.png!

h5. Deleting the Server, Disk Safes, and Policies

{code}
########====Delete Policies Start====########
// check to see if there are any policies to be deleted
if (isset($selectedPolicyIDs) && count($selectedPolicyIDs) > 0){
try {
// iterate over the list of policy IDs and delete them
foreach($selectedPolicyIDs as $tmp) {
$policyClient->deletePolicyByID(array('policyID'=>$tmp));
}
}
catch (SoapFault $exception)
{
echo "Failed to delete all policie(s) \n";
echo $exception;
exit(1);
}
echo "All policie(s) deleted successfully \n";
}

########====Delete Policies End====########


########====Delete DiskSafes Start====########
// check to see if there are any disksafes to be deleted
if (isset($selectedDiskSafeIDs) && count($selectedDiskSafeIDs) > 0){
try {
// iterate over the list of disksafe IDs and delete them
foreach($selectedDiskSafeIDs as $tmp) {
$diskSafeClient->deleteDiskSafeByID(array('diskSafeID'=>$tmp));
}
}
catch (SoapFault $exception)
{
echo "Failed to delete all DiskSafe(s) \n";
echo $exception;
exit(1);
}
echo "All DiskSafe(s) deleted successfully \n";
}

########====Delete DiskSafe End====########

########====Delete Agent Start====########
if (isset($selectedAgentIDs) && count($selectedAgentIDs) > 0){
try {
// iterate over the list of agent IDs and delete them
foreach($selectedAgentIDs as $tmp) {
$agentClient->deleteAgentByID(array('id'=>$tmp));
}
}
catch (SoapFault $exception)
{
echo "Failed to delete all Agent(s) \n";
echo $exception;
exit(1);
}
echo "All Agent(s) deleted successfully \n";
}
########====Delete Agent End====########


{code}


1. Click on the "Delete" (red X) icon under "Actions" for the corresponding Server in the list.

!Servers list_server found_Delete icon_English.png!


Alternatively, select the check-box(es) in front of the Servers and click on the "Delete Selected" button.

!Servers list_server found_Delete Selected button_English.png!

2. Familiarize yourself with the information displayed on the pop-up. Check the "Delete disk safes from disk" option. Click "Delete"

!Delete Server window_Delete disk safe checkbox selected_English.png!

3. The Server and its associated Disk Safes and Policies will disappear from the system.

h5. Deleting Volume
{code}
########====Delete Volumes Start====########
if (isset($selectedVolumeIDs) && count($selectedVolumeIDs) > 0){
try {
// iterate over the list of volume IDs and delete them
foreach($selectedVolumeIDs as $tmp) {
$volumeClient->deleteVolumeByID(array('id'=>$tmp));
}
}
catch (SoapFault $exception)
{
echo "Failed to delete all Volume(s) \n";
echo $exception;
exit(1);
}
echo "All Volume(s) deleted successfully \n";
}

########====Delete Volumes End====########{code}

1. Click on the "Delete" (red X) icon under "Actions" for the corresponding Volume in the list.

!Volumes list_Delete icon_English.png!

2. Confirm your request to delete the Volume.

!Delete Volume window_English.png!

3. Click "OK" on the following window appeared. The volume record will disappear from the "Volumes" list.

!Successfully deleted volume_English.png!

{newversion}&nbsp;In a few moments, the volume record disappears from the "Volumes" list.&nbsp;{newversion}