Limit data sent on /_yui/instances

Don't send ssh key and user-data when listing all hosts, to save on data
This commit is contained in:
snow flurry 2022-09-24 20:03:20 -07:00
parent 794c6a925b
commit cecc8e7b2c
2 changed files with 10 additions and 1 deletions

View file

@ -10,7 +10,9 @@ pub struct Model {
pub id: u32,
pub hostname: String,
pub mac_address: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub ssh_keys: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub user_data: Option<Vec<u8>>,
}

View file

@ -10,6 +10,7 @@ use crate::Instances;
use rocket::serde::json::Json;
use rocket_db_pools::Connection;
use sea_orm::ActiveValue::{NotSet, Set};
use sea_orm::QuerySelect;
use sea_orm::{
ActiveModelTrait, ColumnTrait, EntityTrait, ModelTrait, PaginatorTrait, QueryFilter,
};
@ -97,7 +98,13 @@ pub async fn get_instances(
db: Connection<Instances>,
_api: APIUser,
) -> Result<Json<InstanceResponse>, APIError> {
match instance_info::Entity::find().all(&*db).await {
match instance_info::Entity::find()
.column(instance_info::Column::Id)
.column(instance_info::Column::MacAddress)
.column(instance_info::Column::Hostname)
.all(&*db)
.await
{
Ok(v) => Ok(Json(InstanceResponse::new(v))),
Err(err) => Err(api_err!(
InternalServerError,