Skip to content

Commit

Permalink
Fixed remote ingestion url
Browse files Browse the repository at this point in the history
  • Loading branch information
diptanu committed Aug 15, 2024
1 parent 07d0d79 commit b5b1cbf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -871,16 +871,16 @@ pub struct SqlQueryResponse {
pub rows: Vec<serde_json::Value>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct IngestRemoteFile {
pub id: Option<String>,
pub url: String,
pub mime_type: String,
#[serde(default)]
pub labels: HashMap<String, serde_json::Value>,
pub extraction_graph_names: Vec<String>,
}

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, ToSchema)]
pub struct IngestRemoteFileResponse {
pub content_id: String,
}
Expand Down
18 changes: 15 additions & 3 deletions src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ pub struct NamespaceEndpointState {
link_extraction_graphs,
extraction_graph_links,
upload_file,
ingest_remote_file,
add_graph_to_content,
list_tasks,
index_search,
Expand All @@ -115,7 +116,8 @@ pub struct NamespaceEndpointState {
Feature, FeatureType, GetContentMetadataResponse, ListTasksResponse, Task, ExtractionGraph,
Content, ContentMetadata, ListContentResponse, GetNamespaceResponse, ExtractionPolicyResponse, ListTasks,
ListExtractionGraphResponse, ExtractionGraphLink, ExtractionGraphRequest, ExtractionGraphResponse,
AddGraphToContent, NewContentStreamResponse, ExtractionGraphAnalytics, TaskAnalytics
AddGraphToContent, NewContentStreamResponse, ExtractionGraphAnalytics, TaskAnalytics,
IngestRemoteFileResponse, IngestRemoteFile
)
),
tags(
Expand Down Expand Up @@ -737,9 +739,19 @@ async fn extraction_graph_links(
Ok(Json(res))
}

/// Ingest a file by it's URL
#[utoipa::path(
post,
path = "/namespaces/{namespace}/extraction_graphs/{extraction_graph}/extract_remote",
tag = "ingestion",
responses(
(status = 200, description = "Ingested a remote file successfully", body = IngestRemoteFileResponse),
(status = INTERNAL_SERVER_ERROR, description = "Unable to ingest remote file")
),
)]
#[axum::debug_handler]
async fn ingest_remote_file(
Path(namespace): Path<String>,
Path((namespace, extraction_graph)): Path<(String, String)>,
State(state): State<NamespaceEndpointState>,
Json(payload): Json<IngestRemoteFile>,
) -> Result<Json<IngestRemoteFileResponse>, IndexifyAPIError> {
Expand All @@ -751,7 +763,7 @@ async fn ingest_remote_file(
&payload.url,
&payload.mime_type,
payload.labels,
&payload.extraction_graph_names,
&vec![extraction_graph],
)
.await
.map_err(|e| {
Expand Down

0 comments on commit b5b1cbf

Please sign in to comment.