class InventoryUtil {

	public static  Map<String,List<LambdaVH>> fetchLambdaInfo(BasicSessionCredentials temporaryCredentials, String skipRegions,String accountId,String accountName){

		Map<String,List<LambdaVH>> functions = new LinkedHashMap<>();
		String expPrefix = InventoryConstants.ERROR_PREFIX_CODE+accountId + "\",\"Message\": \"Exception in fetching info for resource in specific region\" ,\"type\": \"Lambda\" , \"region\":\"" ;
		for(Region region : RegionUtils.getRegions()){
			try{
				if(!skipRegions.contains(region.getName())){
					AWSLambda lamdaClient = AWSLambdaClientBuilder.standard().
						 	withCredentials(new AWSStaticCredentialsProvider(temporaryCredentials)).withRegion(region.getName()).build();
					ListFunctionsResult listFnRslt ;
					List<FunctionConfiguration> functionsTemp ;
					List<LambdaVH> lambdaList = new ArrayList<>();
					String nextMarker = null;
					do{
						listFnRslt = lamdaClient.listFunctions(new ListFunctionsRequest().withMarker(nextMarker));
						functionsTemp = listFnRslt.getFunctions();
						if( !functionsTemp.isEmpty() ) {
							functionsTemp.forEach( function -> {
								Map<String,String> tags = lamdaClient.listTags(new ListTagsRequest().withResource(function.getFunctionArn())).getTags();
								LambdaVH  lambda = new LambdaVH(function, tags);
								lambdaList.add(lambda);
							});
						}
						nextMarker = listFnRslt.getNextMarker();
					}while(nextMarker!=null);

					if( !lambdaList.isEmpty() ) {
						log.debug(InventoryConstants.ACCOUNT + accountId +" Type : Lambda " +region.getName() + " >> "+lambdaList.size());
						functions.put(accountId+delimiter+accountName+delimiter+region.getName(),lambdaList);
					}
				}
			}catch(Exception e){
				if(region.isServiceSupported(AWSLambda.ENDPOINT_PREFIX)){
					log.warn(expPrefix+ region.getName()+InventoryConstants.ERROR_CAUSE +e.getMessage()+"\"}");
					ErrorManageUtil.uploadError(accountId,region.getName(),"lambda",e.getMessage());
				}
			}
		}
		return functions ;
	}

	private  InventoryUtil();

}