use model::{CreateStatus, Instance, Subnet};

pub mod args;
pub mod config;
pub mod model;
pub mod net;

pub use trust_dns_proto;

#[tarpc::service]
pub trait Nazrin {
    /// Creates a new instance.
    async fn new_instance(build_args: args::NewInstance) -> Result<uuid::Uuid, String>;
    /// Poll for the current status of an instance being created.
    async fn poll_new_instance(task_id: uuid::Uuid) -> Option<CreateStatus>;
    /// Deletes an existing instance.
    ///
    /// This should involve deleting all related disks and clearing
    /// the lease information from the subnet data, if any.
    async fn delete_instance(name: String) -> Result<(), String>;
    /// Gets a list of existing instances.
    async fn get_instances(with_status: bool) -> Result<Vec<Instance>, String>;
    /// Cleans up unusable entries in the database.
    async fn garbage_collect() -> Result<(), String>;
    /// Creates a new subnet.
    ///
    /// Unlike instances, subnets shouldn't perform any changes to the
    /// interfaces they reference. This should be used primarily for
    /// ease-of-use and bookkeeping (e.g., assigning dynamic leases).
    async fn new_subnet(build_args: Subnet) -> Result<Subnet, String>;
    /// Modifies an existing subnet.
    async fn modify_subnet(edit_args: Subnet) -> Result<Subnet, String>;
    /// Gets a list of existing subnets.
    async fn get_subnets() -> Result<Vec<Subnet>, String>;
    /// Deletes an existing subnet.
    async fn delete_subnet(interface: String) -> Result<(), String>;
}