Skip to content

Commit dc69bd0

Browse files
committed
feat: Add bundles features flag, and BundleApi
1 parent e853a76 commit dc69bd0

4 files changed

Lines changed: 39 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ moka = { version = "0.12.10", features = ["future"], optional = true }
2828

2929
# ATLAS internal dependencies
3030
freedom-config = { version = "1.0.0", features = ["serde"] }
31-
freedom-models = { version = "2.2.0", features = ["serde"] }
31+
freedom-models = { git = "https://github.com/ATLAS-Space-Operations/rust-freedom-models", branch = "dev", features = ["serde"] }
3232

3333
[dev-dependencies]
3434
futures = { version = "0.3.30" }
@@ -38,6 +38,7 @@ tokio-test = { version = "0.4.4"}
3838
tracing-test = { version = "0.2.4" }
3939

4040
[features]
41+
bundles = ["freedom-models/bundles"]
4142
caching = ["dep:moka", "serde/rc"]
4243

4344
[[example]]

src/api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ use futures_core::Stream;
3131

3232
use crate::error::Error;
3333

34+
#[cfg(feature = "bundles")]
35+
pub(crate) mod bundle;
3436
pub(crate) mod post;
3537

3638
/// A super trait containing all the requirements for Freedom API Values

src/api/bundle.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use freedom_models::bundle::fps_task;
2+
use time::{OffsetDateTime, format_description::well_known::Iso8601};
3+
4+
use super::{Api, Error};
5+
6+
/// Adds additional functionality by exposing bundle endpoints.
7+
///
8+
/// These are primarily used internally by the FPS and Gateway but exist in the public API, and are
9+
/// thus included here. In general, use of these should be avoided for customers
10+
pub trait BundleApi: Api {
11+
/// Produces a list of [`fps_task::Bundle`]s within the designated window
12+
///
13+
/// See [`get`](Api::get) documentation for more details about the process and return type
14+
fn get_fps_task_bundle(
15+
&self,
16+
start: OffsetDateTime,
17+
end: OffsetDateTime,
18+
) -> impl Future<Output = Result<Self::Container<Vec<fps_task::Bundle>>, Error>> + Send + Sync
19+
{
20+
async move {
21+
let start = start.format(&Iso8601::DEFAULT).map_err(Error::from)?;
22+
let end = end.format(&Iso8601::DEFAULT).map_err(Error::from)?;
23+
24+
let mut uri = self.path_to_url("fpstaskbundle/search/findByOverlapping");
25+
uri.set_query(Some(&format!("start={}&end={}", start, end)));
26+
27+
self.get_json_map::<Self::Container<Vec<fps_task::Bundle>>>(uri)
28+
.await
29+
}
30+
}
31+
}
32+
33+
impl<T> BundleApi for T where T: Api {}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ pub mod error;
88
pub mod extensions;
99
mod utils;
1010

11+
#[cfg(feature = "bundles")]
12+
pub use self::api::bundle::BundleApi;
1113
pub use self::{
1214
api::{Api, Container, Inner, PaginatedStream, Value},
1315
client::Client,

0 commit comments

Comments
 (0)