tvaultapi/src/main/java/com/tmobile/cso/vault/api/service/IAMServiceAccountsService.java
private ResponseEntity<String> processRequestAndDeleteIAMSvcAccAccessKey(String token, String uniqueIAMSvcaccName, String awsAccountId, String iamSvcName, String accessKeyId) {
		JsonObject iamMetadataJson = getIAMMetadata(token, uniqueIAMSvcaccName);
		if (null != iamMetadataJson && iamMetadataJson.has("secret") && !iamMetadataJson.get("secret").isJsonNull()) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("Trying to delete the access key and secret for the IAM Service account [%s]", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));

			JsonArray svcSecretArray = null;
			try {
				svcSecretArray = iamMetadataJson.get("secret").getAsJsonArray();
			} catch (IllegalStateException e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
						put(LogMessage.MESSAGE, String.format ("Failed to delete this IAM Service account access key. Invalid metadata for [%s].", uniqueIAMSvcaccName)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete this IAM Service account. Invalid metadata.\"]}");
			}

			if (null != svcSecretArray) {
				if(!checkIfAccessKeyExists(svcSecretArray, accessKeyId)) {
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
							put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
							put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
							put(LogMessage.MESSAGE, String.format ("Failed to delete IAM Service account access key. The given accesKey [%s] is not available in T-Vault with given IAM service account [%s].", accessKeyId, uniqueIAMSvcaccName)).
							put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
							build()));
					return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete IAM Service account accesskey. The given accesKey is not available in T-Vault with given IAM service account.\"]}");
				}

				return deleteIAMSvcAccAccessKeyFromVaultAndIAM(token, awsAccountId, iamSvcName, accessKeyId, iamMetadataJson);
			}
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("Failed to delete IAM Service account access key. Invalid metadata for [%s].", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete IAM Service account access key. Invalid metadata.\"]}");
		}else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("AccessKey information not found in metadata for IAM Service account [%s]", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"AccessKey information not found in metadata for this IAM Service account\"]}");
		}
	}
/**
	 * Method to process the request data and call the IAM service account access key delete
	 * @param token
	 * @param uniqueIAMSvcaccName
	 * @return
	 */
Method to process the request data and call the IAM service account access key delete
@param token
@param uniqueIAMSvcaccName
@return
Method to process the request data and call the IAM service account access key delete @param token @param uniqueIAMSvcaccName @return
private ResponseEntity<String> processRequestAndDeleteIAMSvcAccAccessKey(String token, String uniqueIAMSvcaccName, String awsAccountId, String iamSvcName, String accessKeyId) {
		JsonObject iamMetadataJson = getIAMMetadata(token, uniqueIAMSvcaccName);
		if (null != iamMetadataJson && iamMetadataJson.has("secret") && !iamMetadataJson.get("secret").isJsonNull()) {
			log.debug(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("Trying to delete the access key and secret for the IAM Service account [%s]", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			JsonArray svcSecretArray = null;
			try {
				svcSecretArray = iamMetadataJson.get("secret").getAsJsonArray();
			} catch (IllegalStateException e) {
				log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
						put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
						put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
						put(LogMessage.MESSAGE, String.format ("Failed to delete this IAM Service account access key. Invalid metadata for [%s].", uniqueIAMSvcaccName)).
						put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
						build()));
				return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete this IAM Service account. Invalid metadata.\"]}");
			}
			if (null != svcSecretArray) {
				if(!checkIfAccessKeyExists(svcSecretArray, accessKeyId)) {
					log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
							put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
							put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
							put(LogMessage.MESSAGE, String.format ("Failed to delete IAM Service account access key. The given accesKey [%s] is not available in T-Vault with given IAM service account [%s].", accessKeyId, uniqueIAMSvcaccName)).
							put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
							build()));
					return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete IAM Service account accesskey. The given accesKey is not available in T-Vault with given IAM service account.\"]}");
				}
				return deleteIAMSvcAccAccessKeyFromVaultAndIAM(token, awsAccountId, iamSvcName, accessKeyId, iamMetadataJson);
			}
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("Failed to delete IAM Service account access key. Invalid metadata for [%s].", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"Failed to delete IAM Service account access key. Invalid metadata.\"]}");
		}else {
			log.error(JSONUtil.getJSON(ImmutableMap.<String, String>builder().
					put(LogMessage.USER, ThreadLocalContext.getCurrentMap().get(LogMessage.USER)).
					put(LogMessage.ACTION, IAMServiceAccountConstants.DELETE_IAMSVCACC_ACCESSKEY_MSG).
					put(LogMessage.MESSAGE, String.format ("AccessKey information not found in metadata for IAM Service account [%s]", uniqueIAMSvcaccName)).
					put(LogMessage.APIURL, ThreadLocalContext.getCurrentMap().get(LogMessage.APIURL)).
					build()));
			return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"errors\":[\"AccessKey information not found in metadata for this IAM Service account\"]}");
		}
	}
private ResponseEntity < String > processRequestAndDeleteIAMSvcAccAccessKey ( String token , String uniqueIAMSvcaccName , String awsAccountId , String iamSvcName , String accessKeyId ) { JsonObject iamMetadataJson = getIAMMetadata ( token , uniqueIAMSvcaccName ) ; if ( null != iamMetadataJson && iamMetadataJson . has ( "secret" ) && ! iamMetadataJson . get ( "secret" ) . isJsonNull ( ) ) { log . debug ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Trying to delete the access key and secret for the IAM Service account [%s]" , uniqueIAMSvcaccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; JsonArray svcSecretArray = null ; try { svcSecretArray = iamMetadataJson . get ( "secret" ) . getAsJsonArray ( ) ; } catch ( IllegalStateException e ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Failed to delete this IAM Service account access key. Invalid metadata for [%s]." , uniqueIAMSvcaccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Failed to delete this IAM Service account. Invalid metadata.\"]}" ) ; } if ( null != svcSecretArray ) { if ( ! checkIfAccessKeyExists ( svcSecretArray , accessKeyId ) ) { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Failed to delete IAM Service account access key. The given accesKey [%s] is not available in T-Vault with given IAM service account [%s]." , accessKeyId , uniqueIAMSvcaccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Failed to delete IAM Service account accesskey. The given accesKey is not available in T-Vault with given IAM service account.\"]}" ) ; } return deleteIAMSvcAccAccessKeyFromVaultAndIAM ( token , awsAccountId , iamSvcName , accessKeyId , iamMetadataJson ) ; } log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "Failed to delete IAM Service account access key. Invalid metadata for [%s]." , uniqueIAMSvcaccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"Failed to delete IAM Service account access key. Invalid metadata.\"]}" ) ; } else { log . error ( JSONUtil . getJSON ( ImmutableMap . < String , String > builder ( ) . put ( LogMessage . USER , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . USER ) ) . put ( LogMessage . ACTION , IAMServiceAccountConstants . DELETE_IAMSVCACC_ACCESSKEY_MSG ) . put ( LogMessage . MESSAGE , String . format ( "AccessKey information not found in metadata for IAM Service account [%s]" , uniqueIAMSvcaccName ) ) . put ( LogMessage . APIURL , ThreadLocalContext . getCurrentMap ( ) . get ( LogMessage . APIURL ) ) . build ( ) ) ) ; return ResponseEntity . status ( HttpStatus . BAD_REQUEST ) . body ( "{\"errors\":[\"AccessKey information not found in metadata for this IAM Service account\"]}" ) ; } }
Method to process the request data and call the IAM service account access key delete
 @param token
 @param uniqueIAMSvcaccName
 @return
Method to process the request data and call the IAM service account access key delete @param token @param uniqueIAMSvcaccName @return