class NetworkController {

    @Path("/peer/setproxy")
    @POST
    @Produces(MediaType.TEXT_HTML)
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    @Operation(
        summary = "Set the remote node as a proxy.",
        description = "Set the remote node to use when in roaming and light client modes.",
        security = @SecurityRequirement(name = "admin_api_key"),
        method = "POST",
        tags = {"networking"},
        responses = {
            @ApiResponse(responseCode = "200", description = "Successful execution",
                content = @Content(mediaType = "text/html",
                    schema = @Schema(implementation = PeerDTO.class)))
        }
    )
    @RolesAllowed("admin")
    public Response setAPIProxyPeer(@Parameter(schema = @Schema(implementation = String.class, description = "the IP address or domain name of the peer"))
                                    @FormParam("peer")
                                        String peerAddress) {
        ResponseBuilder response = ResponseBuilder.startTiming();
        Peer peer;
        if (peerAddress == null) {
            peer = service.setForcedPeer(null);
            if (peer == null) {
                return response.error(ApiErrors.MISSING_PARAM, "peer").build();
            }
        } else {
            peer = service.findPeerByAddress(peerAddress);

            if (peer == null) {
                return response.error(ApiErrors.UNKNOWN_VALUE, "peer", peerAddress).build();
            }

            if (peer.getState() != PeerState.CONNECTED) {
                return response.error(ApiErrors.PEER_NOT_CONNECTED).build();
            }
            if (!peer.isOpenAPI()) {
                return response.error(ApiErrors.PEER_NOT_OPEN_API).build();
            }

            service.setForcedPeer(peer);
        }

        return response.bind(peerConverter.convert(peer)).build();
    }

    public  NetworkController(Converter<Peer, PeerDTO> peerConverter, NetworkService service);

}