Skip to content

Commit

Permalink
update export API
Browse files Browse the repository at this point in the history
  • Loading branch information
drmorr0 committed Jun 19, 2024
1 parent 5dd669c commit 1cb125d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ pre-k8s:: crd
.PHONY: api
api:
openapi-generator generate -i api/v1/simkube.yml -g rust --global-property models -o generated-api
cp generated-api/src/models/export_filters.rs lib/rust/api/v1/.
cp generated-api/src/models/export_request.rs lib/rust/api/v1/.
cp generated-api/src/models/export_filters.rs lib/api/v1/.
cp generated-api/src/models/export_request.rs lib/api/v1/.
@echo ''
@echo '----------------------------------------------------------------------'
@echo 'WARNING: YOU NEED TO DO MANUAL CLEANUP TO THE OPENAPI GENERATED FILES!'
Expand Down
3 changes: 3 additions & 0 deletions api/v1/simkube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ paths:
required:
- start_ts
- end_ts
- export_path
- filters
properties:
start_ts:
Expand All @@ -25,6 +26,8 @@ paths:
end_ts:
type: integer
format: int64
export_path:
type: string
# TODO - eventually want positive filters too
filters:
type: object
Expand Down
2 changes: 1 addition & 1 deletion cli/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct Args {

pub async fn cmd(args: &Args) -> EmptyResult {
let filters = ExportFilters::new(args.excluded_namespaces.clone(), vec![], true);
let req = ExportRequest::new(args.start_time, args.end_time, filters);
let req = ExportRequest::new(args.start_time, args.end_time, "".into(), filters);
let endpoint = format!("{}/export", args.tracer_address);

println!("exporting trace data");
Expand Down
13 changes: 10 additions & 3 deletions lib/api/v1/export_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,25 @@

use super::*;

#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
pub struct ExportRequest {
#[serde(rename = "start_ts")]
pub start_ts: i64,
#[serde(rename = "end_ts")]
pub end_ts: i64,
#[serde(rename = "export_path")]
pub export_path: String,
#[serde(rename = "filters")]
pub filters: Box<ExportFilters>,
}

impl ExportRequest {
pub fn new(start_ts: i64, end_ts: i64, filters: ExportFilters) -> ExportRequest {
ExportRequest { start_ts, end_ts, filters: Box::new(filters) }
pub fn new(start_ts: i64, end_ts: i64, export_path: String, filters: ExportFilters) -> ExportRequest {
ExportRequest {
start_ts,
end_ts,
export_path,
filters: Box::new(filters),
}
}
}

0 comments on commit 1cb125d

Please sign in to comment.