fn list(client: &Client, api_url_base: &str) -> std::collections::HashMap<String, Jail> {
	let mut jails = HashMap::new();
	let response = client
		.get(&(api_url_base.to_owned() + "jail"))
		.send()
		.unwrap();

	let obj = json::parse(&response.text().unwrap()).unwrap();

	for jail_obj in obj.members() {
		jails.insert(
			jail_obj["id"].to_string(),
			Jail {
				jail_ip: jail_obj["ip4_addr"].to_string(),
				admin_url: None,
				icon_url: None,
			},
		);
	}

	let response = client
		.get(&(api_url_base.to_owned() + "plugin"))
		.send()
		.unwrap();

	let obj = json::parse(&response.text().unwrap()).unwrap();

	for plugin_obj in obj.members() {
		let name = plugin_obj["name"].to_string();

		if let json::JsonValue::Array(admin_urls) = &plugin_obj["admin_portals"] {
			jails.entry(name.clone()).and_modify(|jail| {
				jail.admin_url = Some(admin_urls[0].to_string());
				jail.icon_url = Some(
					plugin_obj["plugin_repository"]
						.to_string()
						.trim_end_matches(".git")
						.replace("github.com", "raw.githubusercontent.com")
						+ &format!(
							"/master/icons/{}.png",
							name.replace("plexmediaserver", "plex")
						),
				);
			});
		}
	}

	for (_, jail) in jails.iter_mut() {
		if jail.icon_url == None {
			jail.icon_url = Some(ICON_FREEBSD.into());
		}
	}

	jails
}
/// Retrieves information about jails, returning a map of jail name to Jail struct.
Retrieves information about jails, returning a map of jail name to Jail struct.
Retrieves information about jails returning a map of jail name to Jail struct .
fn list(client: &Client, api_url_base: &str) -> std::collections::HashMap<String, Jail> {
	let mut jails = HashMap::new();
	let response = client
		.get(&(api_url_base.to_owned() + "jail"))
		.send()
		.unwrap();
	let obj = json::parse(&response.text().unwrap()).unwrap();
	for jail_obj in obj.members() {
		jails.insert(
			jail_obj["id"].to_string(),
			Jail {
				jail_ip: jail_obj["ip4_addr"].to_string(),
				admin_url: None,
				icon_url: None,
			},
		);
	}
	let response = client
		.get(&(api_url_base.to_owned() + "plugin"))
		.send()
		.unwrap();
	let obj = json::parse(&response.text().unwrap()).unwrap();
	for plugin_obj in obj.members() {
		let name = plugin_obj["name"].to_string();
		if let json::JsonValue::Array(admin_urls) = &plugin_obj["admin_portals"] {
			jails.entry(name.clone()).and_modify(|jail| {
				jail.admin_url = Some(admin_urls[0].to_string());
				jail.icon_url = Some(
					plugin_obj["plugin_repository"]
						.to_string()
						.trim_end_matches(".git")
						.replace("github.com", "raw.githubusercontent.com")
						+ &format!(
							"/master/icons/{}.png",
							name.replace("plexmediaserver", "plex")
						),
				);
			});
		}
	}
	for (_, jail) in jails.iter_mut() {
		if jail.icon_url == None {
			jail.icon_url = Some(ICON_FREEBSD.into());
		}
	}
	jails
}
fn list ( client : & Client , api_url_base : & str ) -> std :: collections :: HashMap < String , Jail > { let mut jails = HashMap :: new ( ) ; let response = client . get ( & ( api_url_base . to_owned ( ) + " " ) ) . send ( ) . unwrap ( ) ; let obj = json :: parse ( & response . text ( ) . unwrap ( ) ) . unwrap ( ) ; for jail_obj in obj . members ( ) { jails . insert ( jail_obj [ " " ] . to_string ( ) , Jail { jail_ip : jail_obj [ " " ] . to_string ( ) , admin_url : None , icon_url : None , } , ) ; } let response = client . get ( & ( api_url_base . to_owned ( ) + " " ) ) . send ( ) . unwrap ( ) ; let obj = json :: parse ( & response . text ( ) . unwrap ( ) ) . unwrap ( ) ; for plugin_obj in obj . members ( ) { let name = plugin_obj [ " " ] . to_string ( ) ; if let json :: JsonValue :: Array ( admin_urls ) = & plugin_obj [ " " ] { jails . entry ( name . clone ( ) ) . and_modify ( | jail | { jail . admin_url = Some ( admin_urls [ 0 ] . to_string ( ) ) ; jail . icon_url = Some ( plugin_obj [ " " ] . to_string ( ) . trim_end_matches ( " " ) . replace ( " " , " " ) + & format ! ( " " name replace ( " " " " ) ) , ) ; } ) ; } } for ( _ , jail ) in jails . iter_mut ( ) { if jail . icon_url == None { jail . icon_url = Some ( ICON_FREEBSD . into ( ) ) ; } } jails }
Retrieves information about jails, returning a map of jail name to Jail struct.
Retrieves information about jails returning a map of jail name to Jail struct .
client
&Client
api_url_base
&str