From d3314bf310dc99c3d19a2e18c5b631f33000132e Mon Sep 17 00:00:00 2001 From: simonredfern Date: Wed, 26 Nov 2025 14:53:27 +0100 Subject: [PATCH] Refactor: http_status_code param --- .../main/scala/code/api/util/APIUtil.scala | 4 ++-- .../main/scala/code/api/util/OBPParam.scala | 2 +- .../scala/code/api/v5_1_0/APIMethods510.scala | 6 +++--- .../scala/code/metrics/MappedMetrics.scala | 20 +++++++++---------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/obp-api/src/main/scala/code/api/util/APIUtil.scala b/obp-api/src/main/scala/code/api/util/APIUtil.scala index 420d62c33..f4af4b3f6 100644 --- a/obp-api/src/main/scala/code/api/util/APIUtil.scala +++ b/obp-api/src/main/scala/code/api/util/APIUtil.scala @@ -1234,7 +1234,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ functionName <- getHttpParamValuesByName(httpParams, "function_name") customerId <- getHttpParamValuesByName(httpParams, "customer_id") lockedStatus <- getHttpParamValuesByName(httpParams, "locked_status") - httpCode <- getHttpParamValuesByName(httpParams, "http_code") + httpStatusCode <- getHttpParamValuesByName(httpParams, "http_status_code") }yield{ /** * sortBy is currently disabled as it would open up a security hole: @@ -1252,7 +1252,7 @@ object APIUtil extends MdcLoggable with CustomJsonFormats{ //This guarantee the order List(limit, offset, ordering, sortBy, fromDate, toDate, anon, status, consumerId, azp, iss, consentId, userId, providerProviderId, url, appName, implementedByPartialFunction, implementedInVersion, - verb, correlationId, duration, httpCode, excludeAppNames, excludeUrlPattern, excludeImplementedByPartialfunctions, + verb, correlationId, duration, httpStatusCode, excludeAppNames, excludeUrlPattern, excludeImplementedByPartialfunctions, includeAppNames, includeUrlPattern, includeImplementedByPartialfunctions, connectorName,functionName, bankId, accountId, customerId, lockedStatus, deletedStatus ).filter(_ != OBPEmpty()) diff --git a/obp-api/src/main/scala/code/api/util/OBPParam.scala b/obp-api/src/main/scala/code/api/util/OBPParam.scala index f0dfdbe4f..d0ba9aa7a 100644 --- a/obp-api/src/main/scala/code/api/util/OBPParam.scala +++ b/obp-api/src/main/scala/code/api/util/OBPParam.scala @@ -45,7 +45,7 @@ case class OBPVerb(value: String) extends OBPQueryParam case class OBPAnon(value: Boolean) extends OBPQueryParam case class OBPCorrelationId(value: String) extends OBPQueryParam case class OBPDuration(value: Long) extends OBPQueryParam -case class OBPHttpCode(value: Int) extends OBPQueryParam +case class OBPHttpStatusCode(value: Int) extends OBPQueryParam case class OBPExcludeUrlPatterns(values: List[String]) extends OBPQueryParam case class OBPIncludeUrlPatterns(values: List[String]) extends OBPQueryParam case class OBPExcludeImplementedByPartialFunctions(value: List[String]) extends OBPQueryParam diff --git a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala index 4a0ac5aa4..93a2a7f49 100644 --- a/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala +++ b/obp-api/src/main/scala/code/api/v5_1_0/APIMethods510.scala @@ -2723,7 +2723,7 @@ trait APIMethods510 { | |14 include_implemented_by_partial_functions (if null ignore).eg: &include_implemented_by_partial_functions=getMetrics,getConnectorMetrics,getAggregateMetrics | - |15 http_code (if null ignore) - Filter by HTTP status code. eg: http_code=200 returns only successful calls, http_code=500 returns server errors + |15 http_status_code (if null ignore) - Filter by HTTP status code. eg: http_status_code=200 returns only successful calls, http_status_code=500 returns server errors | |${userAuthenticationMessage(true)} | @@ -2822,7 +2822,7 @@ trait APIMethods510 { | "implemented_in_version", | "consumer_id", | "verb", - | "http_code" + | "http_status_code" | |6 direction (defaults to date desc) eg: direction=desc | @@ -2850,7 +2850,7 @@ trait APIMethods510 { | |16 duration (if null ignore) - Returns calls where duration > specified value (in milliseconds). Use this to find slow API calls. eg: duration=5000 returns calls taking more than 5 seconds | - |17 http_code (if null ignore) - Returns calls with specific HTTP status code. eg: http_code=200 returns only successful calls, http_code=500 returns server errors + |17 http_status_code (if null ignore) - Returns calls with specific HTTP status code. eg: http_status_code=200 returns only successful calls, http_status_code=500 returns server errors | """.stripMargin, EmptyBody, diff --git a/obp-api/src/main/scala/code/metrics/MappedMetrics.scala b/obp-api/src/main/scala/code/metrics/MappedMetrics.scala index b23e3629d..355844a21 100644 --- a/obp-api/src/main/scala/code/metrics/MappedMetrics.scala +++ b/obp-api/src/main/scala/code/metrics/MappedMetrics.scala @@ -238,7 +238,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ case Some(s) if s == "implemented_by_partial_function" => OrderBy(MappedMetric.implementedByPartialFunction, direction) case Some(s) if s == "correlation_id" => OrderBy(MappedMetric.correlationId, direction) case Some(s) if s == "duration" => OrderBy(MappedMetric.duration, direction) - case Some(s) if s == "http_code" => OrderBy(MappedMetric.httpCode, direction) + case Some(s) if s == "http_status_code" => OrderBy(MappedMetric.httpCode, direction) case _ => OrderBy(MappedMetric.date, Descending) } } @@ -256,7 +256,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ val verb = queryParams.collect { case OBPVerb(value) => By(MappedMetric.verb, value) }.headOption val correlationId = queryParams.collect { case OBPCorrelationId(value) => By(MappedMetric.correlationId, value) }.headOption val duration = queryParams.collect { case OBPDuration(value) => By_>(MappedMetric.duration, value) }.headOption - val httpCode = queryParams.collect { case OBPHttpCode(value) => By(MappedMetric.httpCode, value) }.headOption + val httpStatusCode = queryParams.collect { case OBPHttpStatusCode(value) => By(MappedMetric.httpCode, value) }.headOption val anon = queryParams.collect { case OBPAnon(true) => By(MappedMetric.userId, "null") case OBPAnon(false) => NotBy(MappedMetric.userId, "null") @@ -282,7 +282,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ limit.toSeq, correlationId.toSeq, duration.toSeq, - httpCode.toSeq, + httpStatusCode.toSeq, anon.toSeq, excludeAppNames.toSeq.flatten ).flatten @@ -367,7 +367,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ val anon = queryParams.collect { case OBPAnon(value) => value }.headOption val correlationId = queryParams.collect { case OBPCorrelationId(value) => value }.headOption val duration = queryParams.collect { case OBPDuration(value) => value }.headOption - val httpCode = queryParams.collect { case OBPHttpCode(value) => value }.headOption + val httpStatusCode = queryParams.collect { case OBPHttpStatusCode(value) => value }.headOption val excludeUrlPatterns = queryParams.collect { case OBPExcludeUrlPatterns(value) => value }.headOption val includeUrlPatterns = queryParams.collect { case OBPIncludeUrlPatterns(value) => value }.headOption val excludeImplementedByPartialFunctions = queryParams.collect { case OBPExcludeImplementedByPartialFunctions(value) => value }.headOption @@ -404,7 +404,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ AND (${falseOrTrue(anon.isDefined && anon.equals(Some(true)))} or userid = 'null') AND (${falseOrTrue(anon.isDefined && anon.equals(Some(false)))} or userid != 'null') AND (${trueOrFalse(correlationId.isEmpty)} or correlationId = ${sqlFriendly(correlationId)}) - AND (${trueOrFalse(httpCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpCode)}) + AND (${trueOrFalse(httpStatusCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpStatusCode)}) AND (${trueOrFalse(includeUrlPatterns.isEmpty) } or (url LIKE ($includeUrlPatternsQueriesSql))) AND (${trueOrFalse(includeAppNames.isEmpty) } or (appname in ($includeAppNamesList))) AND (${trueOrFalse(includeImplementedByPartialFunctions.isEmpty) } or implementedbypartialfunction in ($includeImplementedByPartialFunctionsList)) @@ -424,7 +424,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ AND (${falseOrTrue(anon.isDefined && anon.equals(Some(true)))} or userid = 'null') AND (${falseOrTrue(anon.isDefined && anon.equals(Some(false)))} or userid != 'null') AND (${trueOrFalse(correlationId.isEmpty)} or correlationId = ${sqlFriendly(correlationId)}) - AND (${trueOrFalse(httpCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpCode)}) + AND (${trueOrFalse(httpStatusCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpStatusCode)}) AND (${trueOrFalse(excludeUrlPatterns.isEmpty) } or (url NOT LIKE ($excludeUrlPatternsQueries))) AND (${trueOrFalse(excludeAppNames.isEmpty) } or appname not in ($excludeAppNamesList)) AND (${trueOrFalse(excludeImplementedByPartialFunctions.isEmpty) } or implementedbypartialfunction not in ($excludeImplementedByPartialFunctionsList)) @@ -480,7 +480,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ val anon = queryParams.collect { case OBPAnon(value) => value }.headOption val correlationId = queryParams.collect { case OBPCorrelationId(value) => value }.headOption val duration = queryParams.collect { case OBPDuration(value) => value }.headOption - val httpCode = queryParams.collect { case OBPHttpCode(value) => value }.headOption + val httpStatusCode = queryParams.collect { case OBPHttpStatusCode(value) => value }.headOption val excludeUrlPatterns = queryParams.collect { case OBPExcludeUrlPatterns(value) => value }.headOption val excludeImplementedByPartialFunctions = queryParams.collect { case OBPExcludeImplementedByPartialFunctions(value) => value }.headOption val limit = queryParams.collect { case OBPLimit(value) => value }.headOption.getOrElse(10) @@ -514,7 +514,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ AND (${trueOrFalse(verb.isEmpty)} or verb = ${verb.getOrElse("null")}) AND (${falseOrTrue(anon.isDefined && anon.equals(Some(true)))} or userid = null) AND (${falseOrTrue(anon.isDefined && anon.equals(Some(false)))} or userid != null) - AND (${trueOrFalse(httpCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpCode)}) + AND (${trueOrFalse(httpStatusCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpStatusCode)}) AND (${trueOrFalse(excludeUrlPatterns.isEmpty)} or (url NOT LIKE ($excludeUrlPatternsQueries))) AND (${trueOrFalse(excludeAppNames.isEmpty)} or appname not in ($excludeAppNamesNumberList)) AND (${trueOrFalse(excludeImplementedByPartialFunctions.isEmpty)} or implementedbypartialfunction not in ($excludeImplementedByPartialFunctionsNumberList)) @@ -563,7 +563,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ val anon = queryParams.collect { case OBPAnon(value) => value }.headOption val correlationId = queryParams.collect { case OBPCorrelationId(value) => value }.headOption val duration = queryParams.collect { case OBPDuration(value) => value }.headOption - val httpCode = queryParams.collect { case OBPHttpCode(value) => value }.headOption + val httpStatusCode = queryParams.collect { case OBPHttpStatusCode(value) => value }.headOption val excludeUrlPatterns = queryParams.collect { case OBPExcludeUrlPatterns(value) => value }.headOption val excludeImplementedByPartialFunctions = queryParams.collect { case OBPExcludeImplementedByPartialFunctions(value) => value }.headOption val limit = queryParams.collect { case OBPLimit(value) => value }.headOption.getOrElse("500") @@ -599,7 +599,7 @@ object MappedMetrics extends APIMetrics with MdcLoggable{ AND (${trueOrFalse(verb.isEmpty)} or verb = ${sqlFriendly(verb)}) AND (${falseOrTrue(anon.isDefined && anon.equals(Some(true)))} or userid = null) AND (${falseOrTrue(anon.isDefined && anon.equals(Some(false)))} or userid != null) - AND (${trueOrFalse(httpCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpCode)}) + AND (${trueOrFalse(httpStatusCode.isEmpty)} or httpcode = ${sqlFriendlyInt(httpStatusCode)}) AND (${trueOrFalse(excludeUrlPatterns.isEmpty) } or (url NOT LIKE ($excludeUrlPatternsQueries))) AND (${trueOrFalse(excludeAppNames.isEmpty) } or appname not in ($excludeAppNamesList)) AND (${trueOrFalse(excludeImplementedByPartialFunctions.isEmpty) } or implementedbypartialfunction not in ($excludeImplementedByPartialFunctionsList))