add method to endpoint
This commit is contained in:
7 files changed
+29
-9
No files matched your search
@@ -5,7 +5,7 @@ mod stats;
|
||||
|
||||
pub use devices::{
|
||||
attach_device_identifier, create_known_device, detach_device_identifier, forget_known_device,
|
||||
list_known_devices, merge_known_device,
|
||||
get_known_device, list_known_devices, merge_known_device,
|
||||
};
|
||||
pub use enroll::{
|
||||
EnrollTokenStatus, IssueEnrollTokenResponse, RevokeAgentResponse, RevokeEnrollTokenResponse,
|
||||
|
||||
@@ -111,6 +111,28 @@ pub async fn list_known_devices(
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_known_device(
|
||||
State(state): State<AppState>,
|
||||
AxumPath(device_id): AxumPath<String>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
match state.store.get_known_device(&device_id).await {
|
||||
Ok(Some(device)) => Ok((StatusCode::OK, Json(known_device_response(device)))),
|
||||
Ok(None) => Err(ApiError::new(
|
||||
StatusCode::NOT_FOUND,
|
||||
"known_device_not_found",
|
||||
"known device not found",
|
||||
)),
|
||||
Err(err) => {
|
||||
warn!(error = %err, "failed to get known device");
|
||||
Err(ApiError::new(
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
"get_known_device_failed",
|
||||
err.to_string(),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn forget_known_device(
|
||||
State(state): State<AppState>,
|
||||
AxumPath(device_id): AxumPath<String>,
|
||||
|
||||
@@ -12,7 +12,7 @@ pub use commands::{list_agents, run_command};
|
||||
pub use control::{
|
||||
EnrollTokenStatus, IssueEnrollTokenResponse, RevokeAgentResponse, RevokeEnrollTokenResponse,
|
||||
StateStatsResponse, attach_device_identifier, create_known_device, detach_device_identifier,
|
||||
enroll, forget_known_device, healthz, issue_enroll_token, list_enroll_tokens,
|
||||
enroll, forget_known_device, get_known_device, healthz, issue_enroll_token, list_enroll_tokens,
|
||||
list_fleet_devices, list_known_devices, merge_known_device, refresh_fleet_devices,
|
||||
revoke_agent, revoke_enroll_token, set_agent_nickname, state_stats, wake_fleet_device,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user