nazrin/api/src/lib.rs

38 lines
1.5 KiB
Rust
Raw Normal View History

2023-01-17 04:42:01 +00:00
use model::{CreateStatus, Instance, Subnet};
2022-12-30 06:06:14 +00:00
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.
2023-01-17 04:42:01 +00:00
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>;
2022-12-30 06:06:14 +00:00
/// 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.
2023-01-17 04:42:01 +00:00
async fn get_instances(with_status: bool) -> Result<Vec<Instance>, String>;
2022-12-30 06:06:14 +00:00
/// 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>;
2023-01-17 04:42:01 +00:00
/// Modifies an existing subnet.
async fn modify_subnet(edit_args: Subnet) -> Result<Subnet, String>;
2022-12-30 06:06:14 +00:00
/// 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>;
}