tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
private ResponseEntity<String> deleteOrphanGroupEntriesForIAMSvcAcc(String token, IAMServiceAccountGroup iamServiceAccountGroup) {
		// Trying to remove the orphan entries if exists
		String iamUniqueSvcAccountName = iamServiceAccountGroup.getAwsAccountId() + "_" + iamServiceAccountGroup.getIamSvcAccName();
		String path = new StringBuilder(IAMServiceAccountConstants.IAM_SVCC_ACC_PATH).append(iamUniqueSvcAccountName).toString();
		Map<String,String> params = new HashMap<>();
		params.put("type", "groups");
		params.put("name",iamServiceAccountGroup.getGroupname());
		params.put("path",path);
		params.put("access","delete");
		Response metadataResponse = ControllerUtil.updateMetadata(params,token);
		if(metadataResponse !=null && (HttpStatus.NO_CONTENT.equals(metadataResponse.getHttpstatus()) || HttpStatus.OK.equals(metadataResponse.getHttpstatus()))){
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, "Remove Group from IAM service account").
					put(LogMessage.MESSAGE, String.format ("Group [%s] is successfully removed from IAM service account [%s]", iamServiceAccountGroup.getGroupname(), iamUniqueSvcAccountName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"Message\":\"Group not available or deleted from AD, removed the group assignment and permissions \"}");
		}else{
			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"messages\":[\"Group configuration failed.Try again \"]}");
		}
	}
/**
	 * Method to delete orphan group entries if exists for IAM service account
	 * @param token
	 * @param iamServiceAccountGroup
	 * @return
	 */
Method to delete orphan group entries if exists for IAM service account
@param token
@param iamServiceAccountGroup
@return
Method to delete orphan group entries if exists for IAM service account @param token @param iamServiceAccountGroup @return
private ResponseEntity<String> deleteOrphanGroupEntriesForIAMSvcAcc(String token, IAMServiceAccountGroup iamServiceAccountGroup) {
		String iamUniqueSvcAccountName = iamServiceAccountGroup.getAwsAccountId() + "_" + iamServiceAccountGroup.getIamSvcAccName();
		String path = new StringBuilder(IAMServiceAccountConstants.IAM_SVCC_ACC_PATH).append(iamUniqueSvcAccountName).toString();
		Map<String,String> params = new HashMap<>();
		params.put("type", "groups");
		params.put("name",iamServiceAccountGroup.getGroupname());
		params.put("path",path);
		params.put("access","delete");
		Response metadataResponse = ControllerUtil.updateMetadata(params,token);
		if(metadataResponse !=null && (HttpStatus.NO_CONTENT.equals(metadataResponse.getHttpstatus()) || HttpStatus.OK.equals(metadataResponse.getHttpstatus()))){
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, "Remove Group from IAM service account").
					put(LogMessage.MESSAGE, String.format ("Group [%s] is successfully removed from IAM service account [%s]", iamServiceAccountGroup.getGroupname(), iamUniqueSvcAccountName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.UNPROCESSABLE_ENTITY).body("{\"Message\":\"Group not available or deleted from AD, removed the group assignment and permissions \"}");
		}else{
			return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"messages\":[\"Group configuration failed.Try again \"]}");
		}
	}
private ResponseEntity < String > deleteOrphanGroupEntriesForIAMSvcAcc ( String token , IAMServiceAccountGroup iamServiceAccountGroup ) { String iamUniqueSvcAccountName = iamServiceAccountGroup . getAwsAccountId ( ) + "_" + iamServiceAccountGroup . getIamSvcAccName ( ) ; String path = new StringBuilder ( IAMServiceAccountConstants . IAM_SVCC_ACC_PATH ) . append ( iamUniqueSvcAccountName ) . toString ( ) ; Map < String , String > params = new HashMap < > ( ) ; params . put ( "type" , "groups" ) ; params . put ( "name" , iamServiceAccountGroup . getGroupname ( ) ) ; params . put ( "path" , path ) ; params . put ( "access" , "delete" ) ; Response metadataResponse = ControllerUtil . updateMetadata ( params , token ) ; if ( metadataResponse != null && ( HttpStatus . NO_CONTENT . equals ( metadataResponse . getHttpstatus ( ) ) || HttpStatus . OK . equals ( metadataResponse . getHttpstatus ( ) ) ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , "Remove Group from IAM service account" ) . put ( LogMessage . MESSAGE , String . format ( "Group [%s] is successfully removed from IAM service account [%s]" , iamServiceAccountGroup . getGroupname ( ) , iamUniqueSvcAccountName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . UNPROCESSABLE_ENTITY ) . body ( "{\"Message\":\"Group not available or deleted from AD, removed the group assignment and permissions \"}" ) ; } else { return ResponseEntity . status ( HttpStatus . INTERNAL_SERVER_ERROR ) . body ( "{\"messages\":[\"Group configuration failed.Try again \"]}" ) ; } }
Method to delete orphan group entries if exists for IAM service account
 @param token
 @param iamServiceAccountGroup
 @return
Method to delete orphan group entries if exists for IAM service account @param token @param iamServiceAccountGroup @return
// Trying to remove the orphan entries if exists