#pragma once

#include "../../../include/dv-processing/io/network_reader.hpp"

#include <pybind11/pybind11.h>

namespace py = pybind11;

/**
 * @brief Bind io::NetworkReader class to python
 * @param m pybind The module to bind to
 */
void bind_network_reader(py::module &m) {
	using pybind11::operator""_a;

	py::class_<dv::io::NetworkReader, dv::io::InputBase>(m, "NetworkReader",
		"Network capture class. Connect to a network available TCP or UNIX socket server providing a data stream. The "
		"class provides a single data stream per network capture.")
		.def(py::init<const std::filesystem::path &>(), "socketPath"_a,
			"Initialize a network capture class, it will connect to a given UNIX socket with a given file system path.")
		.def(py::init<const std::string_view, const uint16_t>(), "ipAddress"_a, "port"_a,
			"Initialize a network capture class, it will connect to a given TCP port with given IP address.")
		.def(py::init([](const std::string_view ipAddress, const uint16_t port,
						  const std::filesystem::path &certificateChain, const std::filesystem::path &privateKey) {
			return std::make_unique<dv::io::NetworkReader>(
				ipAddress, port, dv::io::encrypt::defaultEncryptionClient(certificateChain, privateKey));
		}),
			"ipAddress"_a, "port"_a, "certificateChain"_a, "privateKey"_a,
			"Initialize an encrypted network capture class, it will connect to a given TCP port with given IP address. "
			"Provide a client certificate chain and private key for the TLS encrypted connection.")
		.def("getStreamDefinition", &dv::io::NetworkReader::getStreamDefinition,
			"Get the stream definition object, which describe the available data stream by this reader.");
}
