use crate::Client;
use crate::resource::Resource;
pub type ClusterGroup = crate::models::ClusterGroup;
pub type ClusterType = crate::models::ClusterType;
pub type Cluster = crate::models::Cluster;
pub type VmInterface = crate::models::VmInterface;
pub type VirtualMachine = crate::models::VirtualMachine;
pub type ClusterGroupsApi = Resource<crate::models::ClusterGroup>;
pub type ClusterTypesApi = Resource<crate::models::ClusterType>;
pub type ClustersApi = Resource<crate::models::Cluster>;
pub type InterfacesApi = Resource<crate::models::VmInterface>;
pub type VirtualMachinesApi = Resource<crate::models::VirtualMachine>;
#[derive(Clone)]
pub struct VirtualizationApi {
client: Client,
}
impl VirtualizationApi {
pub(crate) fn new(client: Client) -> Self {
Self { client }
}
pub fn cluster_groups(&self) -> ClusterGroupsApi {
Resource::new(self.client.clone(), "virtualization/cluster-groups/")
}
pub fn cluster_types(&self) -> ClusterTypesApi {
Resource::new(self.client.clone(), "virtualization/cluster-types/")
}
pub fn clusters(&self) -> ClustersApi {
Resource::new(self.client.clone(), "virtualization/clusters/")
}
pub fn interfaces(&self) -> InterfacesApi {
Resource::new(self.client.clone(), "virtualization/interfaces/")
}
pub fn virtual_machines(&self) -> VirtualMachinesApi {
Resource::new(self.client.clone(), "virtualization/virtual-machines/")
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::ClientConfig;
fn test_client() -> Client {
let config = ClientConfig::new("https://nautobot.example.com", "token");
Client::new(config).unwrap()
}
fn assert_path<T>(resource: Resource<T>, expected: &str)
where
T: serde::de::DeserializeOwned,
{
let paginator = resource.paginate(None).unwrap();
assert_eq!(paginator.next_url(), Some(expected));
}
#[test]
fn virtualization_accessors_return_expected_paths() {
let api = VirtualizationApi::new(test_client());
assert_path(api.cluster_groups(), "virtualization/cluster-groups/");
assert_path(api.cluster_types(), "virtualization/cluster-types/");
assert_path(api.clusters(), "virtualization/clusters/");
assert_path(api.interfaces(), "virtualization/interfaces/");
assert_path(api.virtual_machines(), "virtualization/virtual-machines/");
}
}