Java SDK API Samples

27 minutes to read

All PAM360 APIs can be accessed through the Java SDK based on the provided user role in PAM360, empowering the development of custom applications to perform required operations efficiently.

Sample codes for all supported API methods within the PAM360 Java SDK are provided here for reference along with the relevant SDK exceptions.

You can also refer to the to the Java document to learn more about in detail.

Sample Codes for REST API using Java SDK

1. Resource Operations

Class - Resource

Constructor - Resource(PAMService service, APIRequestHandler rest)

Description - Creates a resource entity class instance containing resource related functions with the PAMService.

Method

Description

createResource

	public boolean createResource() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		ResourceModel resourceModel=new ResourceModel();
		resourceModel.setResourceName("CHTOW-08F-165");
		resourceModel.setDomainName("manageengine.com");
		resourceModel.setDnsName("acme.com");
		resourceModel.setResourceType("Windows");
		resourceModel.setNotes("For System Administration");
		resourceModel.setResourceLocation("Noida");
		resourceModel.setResourceDescription("added via SDK");
		resourceModel.setResourceDepartment("System Administration");
		resourceModel.setResourcePasswordPolicy("Strong");
		resourceModel.setAccountName("aut-2k23");
		resourceModel.setPassword("GD*yuhf@gDht%");
		resourceModel.setAccountPasswordPolicy("Strong");
		if(resource.createResource(resourceModel)!=null){
			return true;
		}
		return false;
	}
	

To create a new resource in the PAM360 repository with the provided attributes.

deleteResource

	public boolean deleteResource() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return resource.deleteResource("CHTOW-08F-165");
   	 }
	

To delete a resource from the PAM360 repository with the provided resource ID or resource name as input.

editResource

	public boolean editResource() throws  SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ResourceModel resourceModel = new ResourceModel();
		resourceModel.setResourceName("DLWO-0L8-0H5"); 
		resourceModel.setResourceLocation("Noida");
		return resource.editResource("resource1", resourceModel);
	}
	

To edit a resource in the PAM360 repository with the provided attributes.

getAccountsOfResource

	public boolean getAccountsOfResource() throws  SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		List list=resource.getAccounts("CHTOW-08F-165");
		if(list==null){
			return false;
		}
		return true;
	}
	

To fetch the list of accounts under a resource with the provided resource ID or resource name as input.

getAssociatedGroups

	public boolean getAssociatedGroups() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		JSONObject associateGroups=resource.getassociatedResourceGroups("CHTOW-08F-165");
		if(associateGroups==null){
			return false;
		}
		return true;
	}
	

To fetch the list of resource groups associated with a resource using the resource name.

getID

	public boolean getID() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		long id=0;
		id=resource.getResourceID("CHTOW-08F-165");
		if(id==0){
			return false;
		}
		return true;
   	}
	

To fetch the resource ID of a resource using the resource name.

getResourceAndAccountId

	public boolean getResourceAndAccountId() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ResourceAccountID ids = resource.getResourceAndAccountID("DLWO-0L8-0H5","sysadmin");
		if(ids==null){
			return false;
		}
		return true;
	}
	

To fetch the account ID and the relevant resource ID using the resource name and account name.

getSharedResources

	public boolean getSharedResources() throws SDKRegistrationException, SDKConnectionException, SDKOperationFailedException {
		List list=resource.getSharedResources();
		if(list==null){
			return false;
		}
		return true;
	}
	

To fetch the list of resources that are shared or owned by the user.

sharetoUserGroup

	public boolean sharetoUserGroup() throws  SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return resource.shareResourceToUsergroup("DLWO-0L8-0H5", sdkEnumConstants.AccessPermission.MODIFY,"System Administration");
	}
	

To share a resource to a user using the resource name and username as the input.

shareResourceToUser

	public boolean shareResourceToUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return resource.sharerResourceToUser("DLWO-0L8-0H5","guest", sdkEnumConstants.AccessPermission.MODIFY);
	}
	

To share a resource to the user groups using the resource name and user group names as the input.

move_resource_to_trash

   public boolean trashResource() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        return resource.trashResource(301L); 
 }

To move a resource owned by the user to trash.

fetch_all_trashed_resources

   public boolean getTrashResourceDetails() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        List<TrashDetails> trashDetails = trash.getTrashedResources();
        return trashDetails != null &&  !trashDetails.isEmpty();
 }

To fetch the owned resources of a user that are trashed in PAM360.

restore_resources_from_trash

   public boolean fetchAndRestoreResource() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        return trash.restoreResources(Arrays.asList("resource")); 
 }

To restore the resources owned by the user from the trash in PAM360.

configure_remote_password_reset_mssql

       public boolean configureRemotePasswordReset() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        ConfigureRemotePasswordResetModel configureRemotePasswordResetModel = new ConfigureRemotePasswordResetModel();
configureRemotePasswordResetModel.setMssqlAuthentication(sdkEnumConstants.MSSQLAuthenticationType.MSSQL_SERVER);
        configureRemotePasswordResetModel.setMssqlPort("1433");
        configureRemotePasswordResetModel.setWinAuthResourceName("test");
        configureRemotePasswordResetModel.setWinAuthAccountName("administrator");
        configureRemotePasswordResetModel.setMssqlAccount("test1");
        configureRemotePasswordResetModel.setresources(Arrays.asList("301","302"));
configureRemotePasswordResetModel.setConnectionMode(sdkEnumConstants.ConnectionMode.NON_SSL);
configureRemotePasswordResetModel.setResourceType(sdkEnumConstants.ResourceType.MSSQL);
        configureRemotePasswordResetModel.setMssqlInstanceName("sample");
        resource.configureRemotePasswordReset(configureRemotePasswordResetModel);
        return true;
 }

To configure remote password reset for MS SQL resources available in PAM360.


2. Access Control Operations

Class - AccessControl

Constructor - AccessControl(PAMService service, APIRequestHandler rest)

Description - Creates an access control entity class instance containing access control related functions.

Method

Description

approvePasswordRequests

	public boolean approvePasswordRequests() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		return accessControl.approvePasswordRequests("aut-2k23","DLWO-0L8-0H5","guest");
   	}
	

To approve a password access request raised by an user using the resource name and the requested username.

checkInAsAdmin

	public boolean checkInAsAdmin() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		return accessControl.checkInasAdmin("DLWO-0L8-0H5","aut-2k23","guest");
	}
	

To check in a password requested for an account as an administrator using the resource name, account name, and requester name.

checkInAsUser

	public boolean checkInAsUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		return accessControl.checkInasUser("DLWO-0L8-0H5","aut-2k23"); 
   	}
	

To check in a password requested for an account as a user using the resource name and the account name.

checkOut

	public boolean checkOut() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		String response=accessControl.checkOut("DLWO-0L8-0H5","aut-2k23","For automation purpose.");
		if(response==null){
			return false;
		}
		return true;
	}
	

To check out the password requested for an account post approval using the resource name and a reason.

getPasswordRequests

	public boolean getPasswordRequests() throws SDKConnectionException, SDKOperationFailedException {
		List list=accessControl.getPasswordRequests();
		if(list==null){
			return false;
		}
		return true;
	}
	

To fetch the list of password access requests awaiting approval.

rejectPasswordRequests

	public boolean rejectPasswordRequests() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		return accessControl.rejectPasswordRequest("aut-2k23","DLWO-0L8-0H5","guest");
	}
	

To reject the password access request raised by a user using the resource name and the requested username.

requestPasswordApproval

	public boolean requestPasswordApproval() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		String response=accessControl.requestPasswordApproval("aut-2k23","DLWO-0L8-0H5","For automation testing");
		if(response==null){
			return false;
		}
		return true;
	}
	

To request password access to an account using the account name with the request reason.


3. Account Operations

Class - Account

Constructor - Account(PAMService service, APIRequestHandler rest)

Description - Creates an account entity class instance containing accounts related operations.

Method

Description

createAccount

	public boolean createAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
		List accountModels=new ArrayList<>();
		AccountModel accountModel1 = new AccountModel();
		accountModel1.setAccountName("sysadmin");
		accountModel1.setPassword("GD*yuhf@gDht%");
		accountModel1.addCustomField("Test", "Value");
		accountModels.add(accountModel1);
		AccountModel accountModel2 = new AccountModel();
		accountModel2.setAccountName("aut-2k23");
		accountModel2.setPassword("BgfUgDD5#@h&");
		accountModel2.addCustomField("Test", "Value");
		accountModels.add(accountModel2);
		JSONObject data=account.createAccount("DLWO-0L8-0H5", accountModels);
		if(data==null){
			return false;
		}
		return true;
	}
	

To create a new account in a resource with the provided account attributes and the resource name.

deleteAccount

	public boolean deleteAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return account.deleteAccount("DLWO-0L8-0H5","guest");
	}
	

To delete an account in the resource with the provided resource name and account name as input.

editAccount

	public boolean editAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
            AccountModel accountModel = new AccountModel();
            accountModel.setAccountName("kmp-2k19");
            accountModel.setDisablePasswordResets(false);
            return account.editAccount("DLWO-0L8-0H5","sysadmin",accountModel);
    	}
	

To edit an account in a resource with the provided account attributes and the resource name.

getAccountDetails

	public boolean getAccountDetails() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		AccountDetails accountDetails=account.getDetails("DLWO-0L8-0H5","aut-2k23");
		if(accountDetails==null){
			return false;
		}
		return true;
	}
	

To fetch the details of an account in a resource

shareToUser

	public boolean shareToUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return account.shareAccountToUser("CHTOW-08F-165", "aut-2k23" ,"guest", sdkEnumConstants.AccessPermission.MODIFY);
	}
	

To share an account to a user using the resource name, account name, and username as the input.

shareToUsergroup

	public boolean shareToUsergroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return account.shareAccountToUserGroup("CHTOW-08F-165","aut-2k23","System Administration", sdkEnumConstants.AccessPermission.MODIFY);
	}
	

To share a resource to the user groups using the resource name, account name, and user group names as the input.

move_account_to_trash

    public boolean trashAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        return account.trashAccount("resource1","account2"); 
 }

To move the account owned by the user to trash in PAM360.

fetch_all_trashed_accounts

  public boolean getTrashAccountDetails() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        List<TrashDetails> trashDetails = trash.getTrashedAccounts();
        return trashDetails != null && !trashDetails.isEmpty();
 }

To fetch the owned accounts of a user that are trashed in PAM360.

restore_accounts_from_trash

    public boolean fetchAndRestoreAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        return trash.restoreAccounts("resourceName",Arrays.asList("account"));
 }

To restore the accounts owned by the user from the trash in PAM360.


4. Password Operations

Class - Password

Constructor - Password(PAMService service, APIRequestHandler rest)

Description - Creates a password entity class instance containing the password related operations.

Method

Description

changePasswordOfAccount

	public boolean changePasswordOfAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return password.changePasswordOfAccount("DLWO-0L8-0H5","sysadmin","GH*ikHij%6g$",sdkEnumConstants.ResetType.LOCAL);
   	}
	

To change the password of an account using the resource name and account name.

generatePassword

	public boolean generatePassword() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		String pass=password.generate("Strong");
		if(pass==null){
			return false;
		}
		return true;
	}
	

To generate a new password based on the provided policy.

getPasswordOfAccount

	public boolean getPasswordOfAccount() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		String pass=password.getPasswordOfAccount("CHTOW-08F-165","aut-2k23");
		if(pass==null){
			return false;
		}
		return true;
	}
	

To fetch the password of an account using the provided resource name and account name.

getPasswordPolicies

	public boolean getPasswordPolicies() throws SDKConnectionException, SDKOperationFailedException {
		JSONObject policies=password.getPasswordPolicies();
		if(policies==null){
			return false;
		}
		return true;
	}
	

To fetch all the available password policies in the organization.

validatePassword

	public boolean validatePassword() throws SDKInvalidArgumentException, SDKConnectionException, SDKOperationFailedException {
		String pass="GD*yuhf@gDht%"; 
		sdkEnumConstants.PasswordPolicy passwordPolicy= sdkEnumConstants.PasswordPolicy.Strong;
		return password.validatePassword(pass,passwordPolicy);
	}
	

To validate the password policy for the provided password.

reset_passwords_accessed_by_user

    public boolean resetOwnedAndSharedPasswords() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
        return user.resetOwnedAndSharedPasswords(2L, new JSONArray(Arrays.asList("email1@example.com", "email2@example.com"))); 
 }

To reset all the passwords that are owned by a user and those shared with them in PAM360.


5. User Operations

Class - User

Constructor - User(PAMService service, APIRequestHandler rest)

Description - Creates a user entity class instance containing the user related operations.

Method

Description

adduserToUserGroup

	public boolean adduserToUserGroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return user.addUserToGroup("samand-1765","Automation Members"); 
	}
	

To add a user to a user group using the username and the user group name.

createUser

	public boolean createUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		UserModel userModel = new UserModel();
		userModel.setUserName("samand-1765");
		userModel.setFirstName("Sam");
		userModel.setLastName("Anderson"); 
		userModel.setEmail("samander@zykler.com"); 
		userModel.setDepartment("Automation"); 
		userModel.setLanguage("english"); 
		userModel.setEnableBrowserExtensionAccess(false);
		userModel.setEnableMobileAccess(false);
		userModel.setEnableWebAccess(true);
		userModel.setEnableApiAccess(false);
		userModel.setEnableSdkAccess(true);
		userModel.setRole("Password User");
		userModel.setPolicy("Low"); 
		userModel.setLocation("Noida"); 
		userModel.setSuperAdmin(false);
		userModel.setCheckHostName(false);
		userModel.setApiTokenExpiryDate("2024-10-20"); 
		userModel.setEnableTwoFactorAuthentication(false);
		userModel.setPassword("SyubvEyui"); 
		if(user.createUser(userModel)!=null){
		return true;
		}
		return false;
	}
	

To create a new user account for PAM360 access with the provided user attributes as the input.

deleteUser

	public boolean deleteUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return user.deleteUser("guest"); 
	}
	

To delete a user account using the username.

editUser

	public boolean editUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		UserModel userModel=new UserModel();
		userModel.setRole("Administrator");
		userModel.setEnableApiAccess(true);
		if(user.editUser("samand-1765",userModel)!=null){
			return true;
		}
		return false;
	}
	

To edit the PAM360 user account with the provided user attributes as the input.

getUserId

	public boolean getUserId() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		long id=user.getUserID("samand-1765");
		if(id==0){
			return false;
		}
		return true;
	}
	

To fetch the user ID of a PAM360 user account using the username.

getUsergroupId

	public boolean getUsergroupId() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		long groupId=user.getusergroupID("Automation Members");
		if(groupId==0){
			return false;
		}
		return true;
	}
	

To fetch the user group ID of a user group using the user group name.

lockUser

	public boolean lockUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return user.lockUser("samand-1765");
    	}
	

To lock a user account using the username.

removeFromUsergroup

	public boolean removeFromUsergroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ArrayList usernames = new ArrayList();
		usernames.add("john");
		usernames.add("guest");
		JSONObject json = user.removeFromUserGroup(usernames, "System Administration");
		if (json == null || json.isEmpty()) {
			return false;
	}
	

To remove users from a user group using the usernames and the user group name.

unlockUser

	public boolean unlockUser() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return user.unlockUser("guest"); 
	}
	

To unlock a user account using the username.

deleteUserGroup

	public boolean deleteUserGroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ArrayList usergroupNames=new ArrayList<>();
		usergroupNames.add("Automation Members");
		usergroupNames.add("System Administration");
		JSONObject ans=user.deleteuserGroup(usergroupNames);
		if(ans==null){
			return false;
		}
		return true;
	}
	

To delete the user groups using the user group names.

resetMFA

	public boolean resetMFA() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		String userName="john";  
		return user.resetMFA(userName);
	}
	

To reset the Multi-Factor Authentication of a user.

regenerateRestToken

	public JSONObject regenerateRestToken() throws SDKConnectionException, SDKOperationFailedException {
		JSONObject data=user.regenerateRestToken();
		System.out.println(data);
		return data;
	}
	

To regenrate the authentication token for oneself.


6. Resource Group Operations

Class - ResourceGroup

Constructor - ResourceGroup(PAMService service, APIRequestHandler rest)

Description - Creates a resource group class instance containing the resource group related operations.

Method

Description

associateResources

	public boolean associateResources() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ArrayList resourceNames=new ArrayList();
		resourceNames.add("aut-2k23");
		resourceNames.add("kuber-76BH");
		return resourceGroup.associateResources(resourceNames,"Human Resources VM","newuser");
    	}
	

To associate resources to a static resource group using the resource ID and resource group ID or resource name and resource group name.

createDynamicGroup

	public boolean createDynamicGroup() throws SDKInvalidArgumentException, SDKConnectionException, SDKOperationFailedException {
		ResourceGroupModel resourceGroupModel=new ResourceGroupModel();
		DynamicGroupCriteria criteria = new DynamicGroupCriteria();
		criteria.add(sdkEnumConstants.DefaultFields.RESOURCENAME.toString(), sdkEnumConstants.Operator.CONTAINS,null, "resource")
		resourceGroupModel.setGroupName("Interns and Trainees' Machines");
		resourceGroupModel.setGroupType(sdkEnumConstants.GroupType.DYNAMIC);
		resourceGroupModel.setDescription("Dynamic group for interns and trainees resources"); 
		resourceGroupModel.setPasswordpolicy(sdkEnumConstants.PasswordPolicy.Low);
		resourceGroupModel.setDynamicGroupCriteria(criteria);
		resourceGroupModel.setMatchAllCriteria(true);
		return resourceGroup.createResourceGroup(resourceGroupModel);
	}
	

To create a dynamic resource group with the provided attributes.

createStaticgroup

	public boolean createStaticgroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ResourceGroupModel resourceGroupModel=new ResourceGroupModel();
		resourceGroupModel.setGroupName("Human Resources VM"); 
		resourceGroupModel.setGroupType(sdkEnumConstants.GroupType.STATIC);
		resourceGroupModel.setDescription("Resource group for Virtual Machines in HR Team"); 
		resourceGroupModel.setPasswordpolicy(sdkEnumConstants.PasswordPolicy.Low);
		return resourceGroup.createResourceGroup(resourceGroupModel);
	}
	

To create a dynamic resource group with the provided attributes.

deleteResourceGroup

	public boolean deleteResourceGroup() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		return resourceGroup.deleteResourceGroup("Interns and Trainees' Machines","newuser"); 
	}
	

To delete a resource group using the resource name.

disassociateResources

	public boolean disassociateResources() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		ArrayList resourceNames=new ArrayList();
		resourceNames.add("aut-2k23");
		return resourceGroup.disassociateResources(resourceNames,"Human Resources VM","newuser");
	}
	

To dissociate resources from a static resource group using the resource ID and resource group ID or resource name and resource group name.

fetchAllResourceGroups

	public boolean fetchAllResourceGroups() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		JSONArray resourcegroupDetails=resourceGroup.fetchAllResourceGroups(1,1, sdkEnumConstants.SearchType.STATIC, sdkEnumConstants.SearchColumn.ALL,"a"); 
		if(resourcegroupDetails==null){
			return false;
		}
		return true;
	}
	

To fetch all the resource groups available in PAM360.

getResourceGroupId

	public boolean getResourceGroupId() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		long id= resourceGroup.getResourceGroupID("Human Resources VM","newuser"); 
		if(id==0){
		return false;
		}
		return true;
	}
	

To fetch the resource group ID using the resource group name.


7. Audit Operations

Class - Audit

Constructor - Audit(PAMService service, APIRequestHandler rest)

Description - Creates an audit entity class instance with the audit related operation.

Method

Description

getauditDetails

	public boolean getauditDetails() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException {
		AuditModel auditModel=new AuditModel();
		auditModel.setAuditId(30);	
		auditModel.setAuditType(sdkEnumConstants.AuditType.USER);
		auditModel.setDate("20-06-2023");
		auditModel.setStartTime(12);
		auditModel.setEndTime(6);
		auditModel.setDuration(sdkEnumConstants.Duration.LAST_7_DAYS);
		List<AuditDetails> list=audit.getAuditDetails(auditModel);
		if(list==null){
			return false;
		}
		return true;
	}
	

To fetch the resource and user audit details from the PAM360 repository.


8. Organization Operations

Class - Organizations

Constructor - Organizations(PAMService service, APIRequestHandler rest)

Description - Creates an organization class instance containing the resource group related operations.

Method

Description

manage_org_access

    public boolean manageUserOrgWithIds() throws SDKConnectionException, SDKInvalidArgumentException, SDKOperationFailedException, SDKRegistrationException {
organizations.manageOrganizationAccessWithIds(Arrays.asList(2L),Arrays.asList(7L,35L),Arrays.asList(7L,35L),2L,sdkEnumConstants.ManagePermission.GRANT);
        return true;
 }

To request grant or revoke permission for a user to manage the client organization for approval workflow.


9. Report Operations

Class - Reports

Constructor - Reports(PAMService service, APIRequestHandler rest)

Description - Creates a report class instance containing the report related operations.

Method

Description

fetch_all_users_report

    public boolean getAllUserReports() throws SDKConnectionException, SDKOperationFailedException, SDKInvalidArgumentException {
        SearchModel searchModel = new SearchModel();
        searchModel.setLimit(10);
        searchModel.setStartIndex(0);
        searchModel.setSearchValue("admin"); 
        searchModel.setSearchColumn(sdkEnumConstants.ReportsSearchColumn.USER_ID);
        searchModel.setSearchOperator(sdkEnumConstants.SearchOperator.CONTAINS);
        List<ReportDetails> users = report.getUserReportDetails(searchModel);
        return users != null && !users.isEmpty();
 }

To fetch the username and user ID of all the users available in PAM360.

fetch_all_user_groups_report

    public boolean getAllUserGroupReports() throws SDKConnectionException, SDKOperationFailedException, SDKInvalidArgumentException {
        SearchModel searchModel = new SearchModel();
        searchModel.setLimit(2);
        searchModel.setStartIndex(0);
        searchModel.setSearchValue("group1");
searchModel.setSearchColumn(sdkEnumConstants.ReportsSearchColumn.USER_GROUP_NAME);
        searchModel.setSearchOperator(sdkEnumConstants.SearchOperator.CONTAINS);
        List<ReportDetails> userGroupReportDetails = report.getUserGroupReportDetails(searchModel);
        return userGroupReportDetails != null && !userGroupReportDetails.isEmpty();
 }

To fetch the user group name and user group ID of all the user groups available in PAM360.

fetch_all_resources_report

   public boolean getAllResourceReports() throws SDKConnectionException, SDKOperationFailedException, SDKInvalidArgumentException {
        SearchModel searchModel = new SearchModel();
        searchModel.setLimit(3);
        searchModel.setStartIndex(0);
        searchModel.setSearchValue("pmp");
        searchModel.setSearchColumn(sdkEnumConstants.ReportsSearchColumn.RESOURCE_NAME);
        searchModel.setSearchOperator(sdkEnumConstants.SearchOperator.CONTAINS);
        List<ReportDetails> resourceReportDetails = report.getResourceReportDetails(searchModel);
        return resourceReportDetails != null && !resourceReportDetails.isEmpty();
 }

To fetch the resource name and resource ID of all the resources available in PAM360.

fetch_all_resource_groups_report

    public boolean getAllResourceGroupReports() throws SDKConnectionException, SDKOperationFailedException, SDKInvalidArgumentException {
        SearchModel searchModel = new SearchModel();
        searchModel.setLimit(2);
        searchModel.setStartIndex(0);
        searchModel.setSearchValue("Default Group");
 searchModel.setSearchColumn(sdkEnumConstants.ReportsSearchColumn.RESOURCE_GROUP_NAME);
        searchModel.setSearchOperator(sdkEnumConstants.SearchOperator.CONTAINS);
        List<ReportDetails> resourceGroupsReportDetails = report.getResourceGroupsReportDetails(searchModel);
        return resourceGroupsReportDetails != null && !resourceGroupsReportDetails.isEmpty();
 }

To fetch the resource group name and resource group ID of all the resource groups available in PAM360.


Java SDK Exceptions

Whenever the API returns an error response, the response will be an instance of any one of the following exception classes based on the type of exception.

  1. SDKConnectionException - Exception occurs when the PAM360 SDK fails to connect with the PAM360 server.
  2. SDKInvalidArgumentException - Exception occurs when an API input is parsed with an invalid data type.
  3. SDKOperationFailedException - This exception occurs when an intended API operation fails after passing the necessary inputs.
  4. SDKRegistrationException - This occurs when there is an issue while registering the Java application/services with the PAM360 SDK in the PAM360 application.

All other exceptions, such as SDK anomalies and other unexpected behaviors, are thrown under the SDKException class.



Top
Back to Top