/* REST interface API for OsmoS1GW * * (C) 2025 by sysmocom - s.f.m.c. GmbH * Author: Vadim Yanitskiy * * All rights reserved. * * Released under the terms of GNU General Public License, Version 2 or * (at your option) any later version. * * SPDX-License-Identifier: GPL-2.0-or-later */ module S1GW_REST_Functions { import from HTTP_Adapter all; import from HTTPmsg_Types all; import from S1GW_REST_Types all; /* Get a list of metrics */ function f_REST_MetricsList(charstring metric_type := "all", charstring path := "") runs on http_CT return MetricsList { var HTTPMessage rsp := f_http_transact("/metrics-list?type=" & metric_type & "&path=" & path); return dec_MetricsList(char2oct(rsp.response.body)); } /* Get the PFCP association state */ function f_REST_PfcpAssocState() runs on http_CT return PfcpAssocInfo { var HTTPMessage rsp := f_http_transact("/pfcp/assoc", method := "GET"); return dec_PfcpAssocInfo(char2oct(rsp.response.body)); } /* Initiate the PFCP Association Setup procedure */ function f_REST_PfcpAssocSetup() runs on http_CT return OperationResult { var HTTPMessage rsp := f_http_transact("/pfcp/assoc", method := "POST"); return dec_OperationResult(char2oct(rsp.response.body)); } /* Initiate the PFCP Association Release procedure */ function f_REST_PfcpAssocRelease() runs on http_CT return OperationResult { var HTTPMessage rsp := f_http_transact("/pfcp/assoc", method := "DELETE"); return dec_OperationResult(char2oct(rsp.response.body)); } /* Send a PFCP Heartbeat Request to the peer */ function f_REST_PfcpHeartbeat() runs on http_CT return OperationResult { var HTTPMessage rsp := f_http_transact("/pfcp/heartbeat", method := "POST"); return dec_OperationResult(char2oct(rsp.response.body)); } /* Get a list of eNB connections */ function f_REST_EnbList() runs on http_CT return EnbList { var HTTPMessage rsp := f_http_transact("/enb-list", method := "GET"); return dec_EnbList(char2oct(rsp.response.body)); } /* Get information about a specific eNB */ function f_REST_EnbInfo(ParamEnbId enb_id) runs on http_CT return EnbItem { var charstring p_enb_id := enc_ParamEnbId(enb_id); var HTTPMessage rsp := f_http_transact("/enb/" & p_enb_id, method := "GET"); return dec_EnbItem(char2oct(rsp.response.body)); } /* Get E-RAB list for a specific eNB */ function f_REST_EnbErabList(ParamEnbId enb_id) runs on http_CT return ErabList { var charstring p_enb_id := enc_ParamEnbId(enb_id); var HTTPMessage rsp := f_http_transact("/enb/" & p_enb_id & "/erab-list", method := "GET"); return dec_ErabList(char2oct(rsp.response.body)); } /* Get E-RAB list for all eNBs */ function f_REST_ErabList() runs on http_CT return ErabList { var HTTPMessage rsp := f_http_transact("/erab-list", method := "GET"); return dec_ErabList(char2oct(rsp.response.body)); } /* Get information about a specific E-RAB */ function f_REST_ErabInfo(ParamErabId erab_id) runs on http_CT return ErabItem { var charstring p_erab_id := enc_ParamErabId(erab_id); var HTTPMessage rsp := f_http_transact("/erab/" & p_erab_id, method := "GET"); return dec_ErabItem(char2oct(rsp.response.body)); } }