community: remove premium protocols and streaming surface
This commit is contained in:
@@ -26,6 +26,7 @@ use crate::{
|
||||
capabilities::get_capabilities,
|
||||
machine_auth::{issue_agent_token, issue_one_time_agent_token},
|
||||
observability::{get_agent_usage, get_log, get_operation_usage, get_usage, list_logs},
|
||||
streaming::list_protocol_capabilities,
|
||||
operations::{
|
||||
archive_operation, create_operation, create_version, delete_operation,
|
||||
export_operation, generate_draft, get_operation, get_operation_version,
|
||||
@@ -33,10 +34,6 @@ use crate::{
|
||||
upload_output_json,
|
||||
},
|
||||
secrets::{create_secret, delete_secret, get_secret, list_secrets, rotate_secret},
|
||||
streaming::{
|
||||
cancel_async_job, get_async_job, get_async_job_result, get_stream_session,
|
||||
list_async_jobs, list_protocol_capabilities, list_stream_sessions, stop_stream_session,
|
||||
},
|
||||
workspaces::{create_workspace, get_workspace, list_workspaces, update_workspace},
|
||||
},
|
||||
state::AppState,
|
||||
@@ -131,17 +128,7 @@ pub fn build_app(state: AppState) -> Router {
|
||||
.route("/usage", get(get_usage))
|
||||
.route("/usage/operations/{operation_id}", get(get_operation_usage))
|
||||
.route("/usage/agents/{agent_id}", get(get_agent_usage))
|
||||
.route("/protocol-capabilities", get(list_protocol_capabilities))
|
||||
.route("/stream-sessions", get(list_stream_sessions))
|
||||
.route("/stream-sessions/{session_id}", get(get_stream_session))
|
||||
.route(
|
||||
"/stream-sessions/{session_id}/stop",
|
||||
post(stop_stream_session),
|
||||
)
|
||||
.route("/async-jobs", get(list_async_jobs))
|
||||
.route("/async-jobs/{job_id}", get(get_async_job))
|
||||
.route("/async-jobs/{job_id}/cancel", post(cancel_async_job))
|
||||
.route("/async-jobs/{job_id}/result", get(get_async_job_result));
|
||||
.route("/protocol-capabilities", get(list_protocol_capabilities));
|
||||
|
||||
let workspace_root_router = Router::new()
|
||||
.route("/capabilities", get(get_capabilities))
|
||||
|
||||
@@ -1,28 +1,15 @@
|
||||
use axum::{
|
||||
Json,
|
||||
extract::{Path, Query, State},
|
||||
extract::{Path, State},
|
||||
};
|
||||
use serde_json::{Value, json};
|
||||
|
||||
use crate::{
|
||||
error::ApiError,
|
||||
routes::access::WorkspacePath,
|
||||
service::{AsyncJobsQuery, StreamSessionsQuery},
|
||||
state::AppState,
|
||||
};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct WorkspaceStreamSessionPath {
|
||||
pub workspace_id: String,
|
||||
pub session_id: String,
|
||||
}
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct WorkspaceAsyncJobPath {
|
||||
pub workspace_id: String,
|
||||
pub job_id: String,
|
||||
}
|
||||
|
||||
pub async fn list_protocol_capabilities(
|
||||
Path(_path): Path<WorkspacePath>,
|
||||
State(state): State<AppState>,
|
||||
@@ -31,107 +18,3 @@ pub async fn list_protocol_capabilities(
|
||||
"items": state.service.list_protocol_capabilities().await
|
||||
})))
|
||||
}
|
||||
|
||||
pub async fn list_stream_sessions(
|
||||
Path(path): Path<WorkspacePath>,
|
||||
Query(query): Query<StreamSessionsQuery>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let page = state
|
||||
.service
|
||||
.list_stream_sessions(&path.workspace_id.as_str().into(), query.clone())
|
||||
.await?;
|
||||
Ok(Json(json!({
|
||||
"items": page.items,
|
||||
"page": query.page.unwrap_or(1),
|
||||
"page_size": query.page_size.unwrap_or(20),
|
||||
"total": page.total,
|
||||
})))
|
||||
}
|
||||
|
||||
pub async fn get_stream_session(
|
||||
Path(path): Path<WorkspaceStreamSessionPath>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let session = state
|
||||
.service
|
||||
.get_stream_session(
|
||||
&path.workspace_id.as_str().into(),
|
||||
&path.session_id.as_str().into(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(json!(session)))
|
||||
}
|
||||
|
||||
pub async fn stop_stream_session(
|
||||
Path(path): Path<WorkspaceStreamSessionPath>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let session = state
|
||||
.service
|
||||
.stop_stream_session(
|
||||
&path.workspace_id.as_str().into(),
|
||||
&path.session_id.as_str().into(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(json!(session)))
|
||||
}
|
||||
|
||||
pub async fn list_async_jobs(
|
||||
Path(path): Path<WorkspacePath>,
|
||||
Query(query): Query<AsyncJobsQuery>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let page = state
|
||||
.service
|
||||
.list_async_jobs(&path.workspace_id.as_str().into(), query.clone())
|
||||
.await?;
|
||||
Ok(Json(json!({
|
||||
"items": page.items,
|
||||
"page": query.page.unwrap_or(1),
|
||||
"page_size": query.page_size.unwrap_or(20),
|
||||
"total": page.total,
|
||||
})))
|
||||
}
|
||||
|
||||
pub async fn get_async_job(
|
||||
Path(path): Path<WorkspaceAsyncJobPath>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let job = state
|
||||
.service
|
||||
.get_async_job(
|
||||
&path.workspace_id.as_str().into(),
|
||||
&path.job_id.as_str().into(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(json!(job)))
|
||||
}
|
||||
|
||||
pub async fn cancel_async_job(
|
||||
Path(path): Path<WorkspaceAsyncJobPath>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let job = state
|
||||
.service
|
||||
.cancel_async_job(
|
||||
&path.workspace_id.as_str().into(),
|
||||
&path.job_id.as_str().into(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(json!(job)))
|
||||
}
|
||||
|
||||
pub async fn get_async_job_result(
|
||||
Path(path): Path<WorkspaceAsyncJobPath>,
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Value>, ApiError> {
|
||||
let result = state
|
||||
.service
|
||||
.get_async_job_result(
|
||||
&path.workspace_id.as_str().into(),
|
||||
&path.job_id.as_str().into(),
|
||||
)
|
||||
.await?;
|
||||
Ok(Json(json!(result)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user