MCPcopy Create free account
hub / github.com/ZingerLittleBee/ServerBee / build_server_response

Function build_server_response

crates/server/src/router/api/server.rs:245–302  ·  view source on GitHub ↗
(
    s: server::Model,
    agent_manager: &AgentManager,
    outstanding_enrollment: Option<OutstandingEnrollmentSummary>,
)

Source from the content-addressed store, hash-verified

243}
244
245#[derive(Debug, Deserialize, utoipa::IntoParams)]
246pub struct AuthorityHistoryQuery {
247 pub server_id: String,
248 #[serde(default = "default_authority_history_limit")]
249 pub limit: u64,
250}
251
252fn default_authority_history_limit() -> u64 {
253 100
254}
255
256#[derive(Debug, Serialize, utoipa::ToSchema)]
257pub struct AuthorityEventResponse {
258 pub id: String,
259 pub server_id: String,
260 pub server_name: String,
261 pub actor_kind: String,
262 pub actor_id: Option<String>,
263 pub request_source: String,
264 pub offer_id: Option<String>,
265 pub transition: String,
266 pub mode: Option<String>,
267 pub offer_outcome: Option<String>,
268 pub authority_before: String,
269 pub authority_after: String,
270 pub created_at: DateTime<Utc>,
271}
272
273fn runtime_capability_fields(
274 agent_manager: &AgentManager,
275 server_id: &str,
276) -> (Option<i32>, Option<i32>) {
277 (
278 agent_manager
279 .get_agent_local_capabilities(server_id)
280 .map(|caps| caps as i32),
281 agent_manager
282 .get_effective_capabilities(server_id)
283 .map(|caps| caps as i32),
284 )
285}
286
287fn build_server_response(
288 s: server::Model,
289 agent_manager: &AgentManager,
290 agent_authority: AgentAuthorityStateSummary,
291) -> ServerResponse {
292 let (agent_local_capabilities, effective_capabilities) =
293 runtime_capability_fields(agent_manager, &s.id);
294
295 let temporary = agent_manager
296 .get_temporary_grants(&s.id)
297 .into_iter()
298 .map(Into::into)
299 .collect();
300
301 let has_token = agent_authority.status == AgentAuthorityStatus::Claimed;
302 let outstanding_enrollment = agent_authority.outstanding_offer.clone();

Callers 3

list_serversFunction · 0.85
get_serverFunction · 0.85
update_serverFunction · 0.85

Calls 3

collectMethod · 0.80
get_temporary_grantsMethod · 0.80

Tested by

no test coverage detected