33import co .elastic .clients .elasticsearch .ElasticsearchClient ;
44import co .elastic .clients .elasticsearch ._types .ElasticsearchVersionInfo ;
55import co .elastic .clients .elasticsearch .core .InfoResponse ;
6+
67import com .fasterxml .jackson .core .JsonProcessingException ;
78import com .fasterxml .jackson .databind .ObjectMapper ;
89import org .phoebus .alarm .logging .AlarmLoggingService ;
2526import java .util .logging .Level ;
2627import java .util .logging .Logger ;
2728
29+ import io .swagger .v3 .oas .annotations .Operation ;
30+ import io .swagger .v3 .oas .annotations .tags .Tag ;
31+ import io .swagger .v3 .oas .annotations .media .Schema ;
32+ import io .swagger .v3 .oas .annotations .Parameter ;
33+ import io .swagger .v3 .oas .annotations .Parameters ;
34+
2835/**
2936 * A REST service for querying the alarm message history
3037 *
3138 * @author Kunal Shroff
3239 */
3340@ RestController
3441@ SuppressWarnings ("unused" )
42+ @ Tag (name = "Search controller" )
3543public class SearchController {
3644
3745 static final Logger logger = Logger .getLogger (SearchController .class .getName ());
@@ -44,6 +52,7 @@ public class SearchController {
4452 /**
4553 * @return Information about the alarm logging service
4654 */
55+ @ Operation (summary = "Get Service Info" )
4756 @ GetMapping
4857 public String info () {
4958
@@ -74,22 +83,41 @@ public String info() {
7483 }
7584 }
7685
86+ @ Operation (summary = "Search alarms" )
87+ @ Parameters ({
88+ @ Parameter (name = "pv" , description = "PV name" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
89+ @ Parameter (name = "severity" , description = "Alarm severity" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
90+ @ Parameter (name = "message" , description = "Alarm message" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
91+ @ Parameter (name = "current_severity" , description = "PV severity" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
92+ @ Parameter (name = "current_message" , description = "PV message" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
93+ @ Parameter (name = "user" , description = "User" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
94+ @ Parameter (name = "host" , description = "Host" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
95+ @ Parameter (name = "command" , description = "Command" , schema = @ Schema (type = "string" ), required = false , example = "*" ),
96+ @ Parameter (name = "start" , description = "Start time" , schema = @ Schema (type = "string" ), required = false , example = "2024-06-12" ),
97+ @ Parameter (name = "end" , description = "End time" , schema = @ Schema (type = "string" ), required = false , example = "2024-06-14" ),
98+ })
7799 @ RequestMapping (value = "/search/alarm" , method = RequestMethod .GET )
78- public List <AlarmLogMessage > search (@ RequestParam Map <String , String > allRequestParams ) {
100+ public List <AlarmLogMessage > search (@ Parameter ( hidden = true ) @ RequestParam Map <String , String > allRequestParams ) {
79101 List <AlarmLogMessage > result = AlarmLogSearchUtil .search (ElasticClientHelper .getInstance ().getClient (), allRequestParams );
80102 return result ;
81103 }
82104
105+ @ Operation (summary = "Search alarms by PV name" )
83106 @ RequestMapping (value = "/search/alarm/pv/{pv}" , method = RequestMethod .GET )
84- public List <AlarmLogMessage > searchPv (@ PathVariable String pv ) {
107+ public List <AlarmLogMessage > searchPv (@ Parameter ( description = "PV name" ) @ PathVariable String pv ) {
85108 Map <String , String > searchParameters = new HashMap <>();
86109 searchParameters .put ("pv" , pv );
87110 List <AlarmLogMessage > result = AlarmLogSearchUtil .search (ElasticClientHelper .getInstance ().getClient (), searchParameters );
88111 return result ;
89112 }
90113
114+ @ Operation (summary = "Search alarm config" )
115+ @ Schema (name = "config" , example = "/Accelerator/compteur" , required = true )
116+ @ Parameters ({
117+ @ Parameter (name = "config" , description = "Config path" , schema = @ Schema (type = "string" ), required = false , example = "/Accelerator/pvname" ),
118+ })
91119 @ RequestMapping (value = "/search/alarm/config" , method = RequestMethod .GET )
92- public List <AlarmLogMessage > searchConfig (@ RequestParam Map <String , String > allRequestParams ) {
120+ public List <AlarmLogMessage > searchConfig (@ Parameter ( hidden = true ) @ RequestParam Map <String , String > allRequestParams ) {
93121 if (allRequestParams == null ||
94122 allRequestParams .isEmpty () ||
95123 !allRequestParams .containsKey ("config" ) ||
0 commit comments