/* JSON message definitions for ES12
 *
 * Author: Philipp Maier <pmaier@sysmocom.de> / sysmocom - s.f.m.c. GmbH
 *
 * 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 es12_Types_JSON {

import from esx_header_Types_JSON all;

/* GSMA SGP.22, section 6.5.2.13 */
type record JSON_ES12_RegisterEventRequest {
	JSON_ESx_RequestHeader header,
	charstring eid,
	charstring rspServerAddress,
	charstring eventId,
	boolean forwardingIndicator
};

/* GSMA SGP.22, section 6.5.2.14 */
type record JSON_ES12_DeleteEventRequest {
	JSON_ESx_RequestHeader header,
	charstring eid,
	charstring eventId
};

/* Common response */
type record JSON_ES12_DeleteOrRegisterEventResponse {
	JSON_ESx_ResponseHeader header
};


/* Definition for JSON ES12 requests */
type union JSON_ES12_Request {
	JSON_ES12_RegisterEventRequest registerEventRequest,
	JSON_ES12_DeleteEventRequest deleteEventRequest
} with {
	variant "JSON : as value"
}

external function enc_JSON_ES12_Request(in JSON_ES12_Request msg)
	 return octetstring
with {
	extension "prototype (convert) encode(JSON)";
	extension "printing(pretty)";
	extension "errorbehavior(ALL:ERROR)"
}
external function dec_JSON_ES12_Request(in octetstring stream)
	 return JSON_ES12_Request
with {
	extension "prototype (convert) decode(JSON)"
	extension "errorbehavior(ALL:ERROR)"
}


/* Definition for JSON ES12 responses */
external function enc_JSON_ES12_DeleteOrRegisterEventResponse(in JSON_ES12_DeleteOrRegisterEventResponse msg)
	 return octetstring
with {
	extension "prototype (convert) encode(JSON)";
	extension "printing(pretty)";
	extension "errorbehavior(ALL:ERROR)"
}
external function dec_JSON_ES12_DeleteOrRegisterEventResponse(in octetstring stream)
	 return JSON_ES12_DeleteOrRegisterEventResponse
with {
	extension "prototype (convert) decode(JSON)"
	extension "errorbehavior(ALL:ERROR)"
}


template (value) JSON_ES12_Request
ts_registerEventRequest := {
	registerEventRequest := {
		header := ts_requestHeader,
		eid := "000102030405060708090A0B0C0D0E0F",
		rspServerAddress := "smdp.example.com",
		eventId := "abcdefgh",
		forwardingIndicator := false
	}
}
template (present) JSON_ES12_Request
tr_registerEventRequest := {
	registerEventRequest := {
		header := tr_requestHeader,
		eid := ?,
		rspServerAddress := ?,
		eventId := ?,
		forwardingIndicator := ?
	}
}

template (value) JSON_ES12_Request
ts_deleteEventRequest := {
	deleteEventRequest := {
		header := ts_requestHeader,
		eid := "000102030405060708090A0B0C0D0E0F",
		eventId := "abcdefgh"
	}
}
template (present) JSON_ES12_Request
tr_deleteEventRequest := {
	deleteEventRequest := {
		header := tr_requestHeader,
		eid := ?,
		eventId := ?
	}
}

template (value) JSON_ES12_DeleteOrRegisterEventResponse
ts_deleteOrRegisterEventResponse := {
	header := ts_responseHeader
}
template (present) JSON_ES12_DeleteOrRegisterEventResponse
tr_deleteOrRegisterEventResponse := {
	header := tr_responseHeader
}


} with {
	encode "JSON";
}
