Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ OPTIONS:
The Netshot token [env: NETSHOT_TOKEN]

--netshot-url <netshot-url>
The Netshot API URL [env: NETSHOT_URL=]```
The Netshot API URL [env: NETSHOT_URL=]
```

The query-string format need to be like this (url query string without the `?`):

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ fn main() -> Result<(), Error> {
netshot_client.ping()?;

log::info!("Getting devices list from Netshot");
let netshot_devices = netshot_client.get_devices()?;
let netshot_devices = netshot_client.get_devices(opt.netshot_domain_id)?;

let netshot_disabled_devices: Vec<&netshot::Device> = netshot_devices
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/rest/netbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct Device {
pub primary_ip4: Option<PrimaryIP>,
}

/// Represent the API response from /api/devim/devices call
/// Represent the API response from /api/dcim/devices call
#[derive(Debug, Serialize, Deserialize)]
pub struct NetboxDCIMDeviceList {
count: u32,
Expand Down
8 changes: 5 additions & 3 deletions src/rest/netshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ impl NetshotClient {
}

/// Get devices registered in Netshot
pub fn get_devices(&self) -> Result<Vec<Device>, Error> {
let url = format!("{}{}", self.url, PATH_DEVICES);
pub fn get_devices(&self,
domain_id: u32,
) -> Result<Vec<Device>, Error> {
let url = format!("{}{}?group={}", self.url, PATH_DEVICES, domain_id);
let devices: Vec<Device> = self.client.get(url).send()?.json()?;

log::debug!("Got {} devices from Netshot", devices.len());
Expand Down Expand Up @@ -291,7 +293,7 @@ mod tests {
.create();

let client = NetshotClient::new(url.clone(), String::new(), None, None, None).unwrap();
let devices = client.get_devices().unwrap();
let devices = client.get_devices(1).unwrap();

assert_eq!(devices.len(), 1);

Expand Down