[[remsim-apitool]]
== osmo-remsim-apitool

`osmo-remsim-apitool` is a small python script whic can be used to manually
control `osmo-remsim-server` via its RESTful interface in setups where
no external back-end application is controlling this interface.

For more information about The RESTful inteface, see <<RSRES>>.

=== Usage

Common command line arguments that can be used with any of the commands below:

*-H, --host HOST*::
  Specify the hostname / IP of the `osmo-remsim-server` to connect to. Default: localhost
*-P, --port PORT*::
  Specify the remote TCP port of the RSRES interface of `osmo-remsim-server`. Default: 9997
*-v, --verbose*
  Increase verbosity of output: Show the GET request generated, not just the response.

==== Listing connected clients

The command `osmo-remsim-apitool -c` can be used to list all currently connected clients.

----
$ osmo-remsim-apitool -c
/clients: {'clients': [{'peer': 'C23:0', 'state': 'CONNECTED_CLIENT', 'component_id': {'type_': 'remsimClient', 'name': 'nataraja', 'software': 'remsim-client', 'swVersion': '0.2.2.63-844b'}}]}
----

==== Listing connected bankds

The command `osmo-remsim-apitool -b` can be used to list all currently connected bankds.

----
$ osmo-remsim-apitool -b
/banks: {'banks': [{'peer': 'B1', 'state': 'CONNECTED_BANKD', 'component_id': {'type_': 'remsimBankd', 'name': 'fixme-name', 'software': 'remsim-bankd', 'swVersion': '0.2.2.46-3598'}, 'bankId': 1, 'numberOfSlots': 5}]}
----

==== Listing installed slotmaps

The command `osmo-remsim-apitool -s` can be used to list all currently installed slotmaps.

----
$ osmo-remsim-apitool -s
/slotmaps: {'slotmaps': [{'bank': {'bankId': 1, 'slotNr': 1}, 'client': {'clientId': 23, 'slotNr': 0}, 'state': 'ACTIVE'}]}
----

==== Listing all information

The command `osmo-remsim-apitool -a` can be used to list all information (clients, bankds, slotmaps).

----
$ osmo-remsim-apitool -a
/clients: {'clients': [{'peer': 'C23:0', 'state': 'CONNECTED_CLIENT', 'component_id': {'type_': 'remsimClient', 'name': 'nataraja', 'software': 'remsim-client', 'swVersion': '0.2.2.63-844b'}}]}
/banks: {'banks': [{'peer': 'B1', 'state': 'CONNECTED_BANKD', 'component_id': {'type_': 'remsimBankd', 'name': 'fixme-name', 'software': 'remsim-bankd', 'swVersion': '0.2.2.46-3598'}, 'bankId': 1, 'numberOfSlots': 5}]}
/slotmaps: {'slotmaps': [{'bank': {'bankId': 1, 'slotNr': 1}, 'client': {'clientId': 23, 'slotNr': 0}, 'state': 'ACTIVE'}]}
----

==== Creating a slotmap

The command `osmo-remsim-apitool -m bank_id bankd_slot client_id client_slot` can be used to create a new slotmap.

.Create a slotmap between Bankd 1 Slot a (B1:1) and Client 23 Slot 0 (C23:0)
----
$ osmo-remsim-apitool -m 1 1 23 0
----

==== Deleting a slotmap

The command `osmo-remsim-apitool -d bank_id bank_slot` can be used to create a new slotmap.

.Remove a slotmap for Bankd 1 Slot a (B1:1)
----
$ osmo-remsim-apitool -m 1 1
----

==== Reset all state

The command `osmo-remsim-apitool -r` can be used to reset all state in bankd, including all slotmaps.

----
$ osmo-remsim-apitool -r
----

WARNING: Use with extreme caution, particularly in production environments.
