[[remsim-server]]
== osmo-remsim-server

=== Running

`osmo-remsim-server` currently has no command-line arguments. It will
bind to INADDR_ANY and offer the following TCP ports:

* Port 9998 for the inbound control connections from `osmo-remsim-client`
  and `osmo-remsim-bankd`
* Port 9997 for the RESTful/JSON Web API (role: HTTP server)

It is intended to make these settings (IP addresses, ports) configurable
in future versions.

==== SYNOPSIS

*osmo-remsim-server* [-h] [-V] [-d LOGOPT]

==== OPTIONS

*-h, --help*::
  Print a short help message about the supported options
*-V, --version*::
  Print the software version number
*-d, --debug LOGOPT*::
  Configure the logging verbosity, see <<remsim_logging>>.

=== Logging

`osmo-remsim-server` currently logs to stderr only; the logging
verbosity is configurable via command line argument only.  However, as
the libosmocore logging framework is used, extending this is an easy
modification.

[[rsres]]
=== RESTful/JSON Web API

`osmo-remsim-server` provides a RESTful/JSON WEB API for application logic
integration.  The purpose of the API is to allow run-time configuration
and monitoring of the entire osmo-remsim system.

The API currently has version 1, and the URL prefix is /api/backend/v1

WARNING: The RESTful/JSON Web API operates in plain-text,
There is no authentication or encryption built into the protocol.  It is
assumed that the protocol is only spoken over trusted, controlled IP
networks, such as inside a VPN or a closed / private corporate network.

==== /api/backend/v1/clients

*GET* obtains a JSON list where each element represents one currently
connected `osmo-remsim-client`.

No other HTTP operation is implemented.

==== /api/backend/v1/clients/:client_id

*GET* obtains a single JSON object representing one specific currently
connected `osmo-remsim-client`.

No other HTTP operation is implemented.

==== /api/backend/v1/banks

*GET* obtains a JSON list where each element represents one currently
connected `osmo-remsim-bankd`.

No other HTTP operation is implemented.

==== /api/backend/v1/banks/:bank_id

*GET* obtains a single JSON object representing one specific currently
connected `osmo-remsim-bankd`.

No other HTTP operation is implemented.

==== /api/backend/v1/slotmaps

*GET* obtains a JSON list where each element represents one provisioned
slot mapping.

*POST* creates a new slot mapping as specified in the JSON syntax
contained in the HTTP body.

No other HTTP operation is implemented.

==== /api/backend/v1/slotmaps/:slotmap_id

*DELETE* deletes a slot mapping by its identifier.  If the mapping is
currently in use, the related bankd is instructed to disconnect the
client from the card.

No other HTTP operation is implemented.

==== /api/backend/v1/global-reset

*POST* performs a global reset of the `osmo-remsim-server` state.  This
means all mappings are removed.

==== Examples
.remsim-server is on 10.2.3.4, one simbank with 5 cards: http://10.2.3.4:9997/api/backend/v1/banks
----
{"banks":[{"peer":"B1","state":"CONNECTED_BANKD","component_id":{"type_":"remsimBankd","name":"fixme-name","software":"remsim-bankd","swVersion":"0.1.0.17-6d8a"},"bankId":1,"numberOfSlots":5}]}
----
.remsim-server is on 10.2.3.4, 4 clients: http://10.2.3.4:9997/api/backend/v1/clients
----
{"clients":[{"peer":"C0:2","state":"CONNECTED_CLIENT","component_id":{"type_":"remsimClient","name":"simtrace2-remsim-client","software":"remsim-client","swVersion":"0.1.0.17-6d8a"}},{"peer":"C0:0","state":"CONNECTED_CLIENT","component_id":{"type_":"remsimClient","name":"simtrace2-remsim-client","software":"remsim-client","swVersion":"0.1.0.17-6d8a"}},{"peer":"C0:3","state":"CONNECTED_CLIENT","component_id":{"type_":"remsimClient","name":"simtrace2-remsim-client","software":"remsim-client","swVersion":"0.1.0.17-6d8a"}},{"peer":"C0:1","state":"CONNECTED_CLIENT","component_id":{"type_":"remsimClient","name":"simtrace2-remsim-client","software":"remsim-client","swVersion":"0.1.0.17-6d8a"}}]}
----
