freedom_api/
api.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
//! # ATLAS Freedom API
//!
//! This module exists to define the Freedom API trait, which can be implemented for multiple client
//! types.
//!
//! The API trait
#![allow(clippy::type_complexity)]
use std::{future::Future, ops::Deref, pin::Pin};

use async_stream::stream;
use bytes::Bytes;
use freedom_config::Config;
use freedom_models::{
    account::Account,
    band::Band,
    pagination::Paginated,
    satellite::Satellite,
    satellite_configuration::SatelliteConfiguration,
    site::Site,
    task::{Task, TaskRequest, TaskStatusType, TaskType},
    user::User,
    utils::Embedded,
};
use reqwest::{Response, StatusCode};
use serde::de::DeserializeOwned;
use serde_json::Value as JsonValue;
use time::{format_description::well_known::Iso8601, OffsetDateTime};
use url::Url;

use futures_core::Stream;

use crate::error::Error;

pub(crate) mod post;

/// A super trait containing all the requirements for Freedom API Values
pub trait Value: std::fmt::Debug + DeserializeOwned + Clone + Send + Sync {}

impl<T> Value for T where T: std::fmt::Debug + DeserializeOwned + Clone + Send + Sync {}

trait PaginatedErr<'a, T> {
    fn once_err(self) -> PaginatedStream<'a, T>;
}

impl<'a, T: 'a + Send + Sync> PaginatedErr<'a, T> for Error {
    fn once_err(self) -> PaginatedStream<'a, T> {
        Box::pin(async_stream::stream! { yield Err(self); })
    }
}

/// The trait defining the required functionality of container types
///
/// The Freedom API is generic over "containers". Each implementer of the [`Api`] trait must
/// also define a container. This is useful since certain clients will return Arc'd values, i.e. the
/// caching client, while others return the values wrapped in a simple [`Inner`] type which is just
/// a stack value.
///
/// However, for most cases this complexity can be ignored, since containers are required to
/// implement [`Deref`](std::ops::Deref) of `T`. So for read-only operations the container can be
/// used as if it were `T`. For mutable access see [`Self::into_inner`].
///
/// # Example
///
/// ```no_run
/// # use freedom_api::prelude::*;
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # let config = Config::from_env()?;
/// # let client = Client::from_config(config);
/// let request = client
///     .get_request_by_id(42)
///     .await?;
///
/// println!("Created on {}", request.created); // Direct access to created field
///                                             // through the Container
/// # Ok(())
/// # }
/// ```
pub trait Container<T>: Deref<Target = T> + Value {
    /// All containers are capable of returning the value they wrap
    ///
    /// However, the runtime performance of this varies by client type. For [`crate::Client`], this
    /// operation is essentially free, however for the caching client, this often results in a clone
    /// of the value.
    fn into_inner(self) -> T;
}

impl<T: Deref<Target = T> + Value> Container<T> for Box<T> {
    fn into_inner(self) -> T {
        *self
    }
}

/// A simple container which stores a `T`.
///
/// This container exists to allow us to store items on the stack, without needing to allocate with
/// something like `Box<T>`. For all other intents and purposes, it acts as the `T` which it
/// contains.
#[derive(
    Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq, PartialOrd, Ord, Hash,
)]
#[repr(transparent)]
#[serde(transparent)]
pub struct Inner<T>(T);

impl<T> std::ops::Deref for Inner<T> {
    type Target = T;

    fn deref(&self) -> &Self::Target {
        &self.0
    }
}

impl<T> std::ops::DerefMut for Inner<T> {
    fn deref_mut(&mut self) -> &mut Self::Target {
        &mut self.0
    }
}

impl<T> Container<T> for Inner<T>
where
    T: Value,
{
    fn into_inner(self) -> T {
        self.0
    }
}

impl<T> Inner<T> {
    pub fn new(inner: T) -> Self {
        Self(inner)
    }
}

/// A stream of paginated results from freedom.
///
/// Each item in the stream is a result, since one or more items may fail to be serialized
pub type PaginatedStream<'a, T> = Pin<Box<dyn Stream<Item = Result<T, Error>> + 'a + Send + Sync>>;

/// The primary trait for interfacing with the Freedom API
pub trait Api: Send + Sync {
    /// The [`Api`] supports implementors with different so-called "container" types.
    ///
    /// For a more detailed description, see the [`Container`] trait.
    type Container<T: Value>: Container<T>;

    /// Creates a get request at the provided absolute URI for the client's environment, using basic
    /// authentication.
    ///
    /// The JSON response is then deserialized into the required type, erroring if the
    /// deserialization fails, and providing the object if it succeeds.
    fn get_json_map<T>(&self, url: Url) -> impl Future<Output = Result<T, Error>> + Send + Sync
    where
        T: Value,
    {
        async move {
            let (body, status) = self.get(url).await?;

            error_on_non_success(&status)?;

            let utf8_str = String::from_utf8_lossy(&body);
            serde_json::from_str(&utf8_str).map_err(From::from)
        }
    }

    /// Creates a get request at the provided absolute URI for the client's environment, using basic
    /// authentication.
    ///
    /// Returns the raw binary body, and the status code.
    fn get(
        &self,
        url: Url,
    ) -> impl Future<Output = Result<(Bytes, StatusCode), Error>> + Send + Sync;

    /// Creates a stream of items from a paginated endpoint.
    ///
    /// The stream is produced as a collection of `Result<T>`. This is so that if any one item fails
    /// deserialization, it is added to the stream of items as an error rather than causing the
    /// entire stream to result in an Error.
    ///
    /// # Pinning
    ///
    /// For convenience the stream is pinned on the heap via [`Box::pin`](https://doc.rust-lang.org/std/boxed/struct.Box.html#method.pin).
    /// This allows us to treat the returned stream more like any other object, without requiring
    /// the end user to manually  pin the result on the stack. This comes with a slight performance
    /// penalty (it requires an allocation), however this will be negligible given the latency of
    /// the responses. For more information on pinning in rust refer to the [pinning chapter](https://rust-lang.github.io/async-book/04_pinning/01_chapter.html)
    /// of the async book.
    fn get_paginated<T>(&self, head_url: Url) -> PaginatedStream<'_, Self::Container<T>>
    where
        T: 'static + Value + Send + Sync,
    {
        let base = self.config().environment().freedom_entrypoint();
        let mut current_url = head_url; // Not necessary but makes control flow more obvious
        Box::pin(stream! {
            loop {
                // Get the results for the current page.
                let pag = self.get_json_map::<Paginated<JsonValue>>(current_url).await?;
                for item in pag.items {
                    let i = serde_json::from_value::<Self::Container<T>>(item).map_err(From::from);
                    yield i;
                }
                if let Some(link) = pag.links.get("next") {
                    // Update the URL to the next page.
                    current_url = match link.has_host() {
                        true => link.to_owned(),
                        false => {
                            base.clone()
                                .join(link.as_str())
                                .map_err(|e| crate::error::Error::pag_item(e.to_string()))?
                        }
                    };
                } else {
                    break;
                }
            }
        })
    }

    /// Returns the freedom configuration for the API
    fn config(&self) -> &Config;

    /// Returns a mutable reference to the freedom configuration for the API
    fn config_mut(&mut self) -> &mut Config;

    /// Fetch the URL from the given path
    ///
    /// # Panics
    ///
    /// Panics in the event the URL cannot be constructed from the provided path
    fn path_to_url(&self, path: impl AsRef<str>) -> Url {
        let url = self.config().environment().freedom_entrypoint();
        url.join(path.as_ref()).expect("Invalid URL construction")
    }

    fn delete(&self, url: Url) -> impl Future<Output = Result<Response, Error>> + Send;

    /// Request to delete the band details object matching the provided id
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_task_request(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_band_details(&self, id: i32) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("satellite_bands/{id}"));
            self.delete(uri).await
        }
    }

    /// Request to delete the satellite configuration matching the provided `id`
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_satellite_configuration(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_satellite_configuration(
        &self,
        id: i32,
    ) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("satellite_configurations/{id}"));
            self.delete(uri).await
        }
    }

    /// Request to delete the satellite object matching the provided `id`
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_satellite(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_satellite(&self, id: i32) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("satellites/{id}"));
            self.delete(uri).await
        }
    }

    /// Request to delete the override matching the provided `id`
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_override(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_override(&self, id: i32) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("overrides/{id}"));
            self.delete(uri).await
        }
    }

    /// Request to delete the user matching the provided `id`
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_user(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_user(&self, id: i32) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("users/{id}"));
            self.delete(uri).await
        }
    }

    /// Request to delete the user matching the provided `id`
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client.delete_task_request(42).await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn delete_task_request(&self, id: i32) -> impl Future<Output = Result<Response, Error>> + Send {
        async move {
            let uri = self.path_to_url(format!("requests/{id}"));
            self.delete(uri).await
        }
    }

    /// Lower level method, not intended for direct use
    fn post_deserialize<S, T>(
        &self,
        url: Url,
        msg: S,
    ) -> impl Future<Output = Result<T, Error>> + Send + Sync
    where
        S: serde::Serialize + Send + Sync,
        T: Value,
    {
        async move {
            let resp = self.post(url, msg).await?;

            resp.json::<T>().await.map_err(From::from)
        }
    }

    /// Lower level method, not intended for direct use
    fn post<S>(
        &self,
        url: Url,
        msg: S,
    ) -> impl Future<Output = Result<Response, Error>> + Send + Sync
    where
        S: serde::Serialize + Send + Sync;

    /// Produces a single [`Account`](freedom_models::account::Account) matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// let account = client.get_account_by_name("ATLAS").await?;
    /// println!("{}", account.name);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn get_account_by_name(
        &self,
        account_name: &str,
    ) -> impl Future<Output = Result<Self::Container<Account>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("accounts/search/findOneByName");
            uri.set_query(Some(&format!("name={account_name}")));
            self.get_json_map(uri).await
        }
    }

    /// Produces a single [`Account`](freedom_models::account::Account) matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// let data = client.get_file_by_task_id_and_name(42, "data.bin").await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn get_file_by_task_id_and_name(
        &self,
        task_id: i32,
        file_name: &str,
    ) -> impl Future<Output = Result<Bytes, Error>> + Send + Sync {
        async move {
            let path = format!("downloads/{}/{}", task_id, file_name);
            let uri = self.path_to_url(path);

            let (data, status) = self.get(uri).await?;
            error_on_non_success(&status)?;

            Ok(data)
        }
    }

    /// Produces a single [`Account`](freedom_models::account::Account) matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_account_by_id(
        &self,
        account_id: i32,
    ) -> impl Future<Output = Result<Self::Container<Account>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("accounts/{account_id}"));
            self.get_json_map(uri).await
        }
    }

    /// Produces a paginated stream of [`Account`](freedom_models::account::Account) objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_accounts(&self) -> PaginatedStream<'_, Self::Container<Account>> {
        let uri = self.path_to_url("accounts");
        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`Band`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_satellite_bands(&self) -> PaginatedStream<'_, Self::Container<Band>> {
        let uri = self.path_to_url("satellite_bands");
        self.get_paginated(uri)
    }

    /// Produces a single [`Band`] matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_satellite_band_by_id(
        &self,
        satellite_band_id: i32,
    ) -> impl Future<Output = Result<Self::Container<Band>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("satellite_bands/{satellite_band_id}"));
            self.get_json_map(uri).await
        }
    }

    /// Produces a single [`Band`] matching the provided name.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_satellite_band_by_name(
        &self,
        satellite_band_name: &str,
    ) -> impl Future<Output = Result<Self::Container<Band>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("satellite_bands/search/findOneByName");
            uri.set_query(Some(&format!("name={satellite_band_name}")));
            self.get_json_map(uri).await
        }
    }

    /// Produces a paginated stream of [`Band`] objects matching the provided account name.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_satellite_bands_by_account_name(
        &self,
        account_name: &str,
    ) -> PaginatedStream<'_, Self::Container<Band>> {
        let mut uri = self.path_to_url("satellite_bands/search/findAllByAccountName");
        uri.set_query(Some(&format!("accountName={account_name}")));

        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`SatelliteConfiguration`] objects matching the provided
    /// account name.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_satellite_configurations_by_account_name(
        &self,
        account_name: &str,
    ) -> PaginatedStream<'_, Self::Container<SatelliteConfiguration>> {
        let mut uri = self.path_to_url("satellite_configurations/search/findAllByAccountName");
        uri.set_query(Some(&format!("accountName={account_name}")));

        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`SatelliteConfiguration`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_satellite_configurations(
        &self,
    ) -> PaginatedStream<'_, Self::Container<SatelliteConfiguration>> {
        let uri = self.path_to_url("satellite_configurations");

        self.get_paginated(uri)
    }

    /// Produces a single satellite configuration matching the provided satellite configuration ID
    fn get_satellite_configuration_by_id(
        &self,
        satellite_configuration_id: i32,
    ) -> impl Future<Output = Result<Self::Container<SatelliteConfiguration>, Error>> + Send + Sync
    {
        async move {
            let uri = self.path_to_url(format!(
                "satellite_configurations/{satellite_configuration_id}"
            ));

            self.get_json_map(uri).await
        }
    }

    /// Produces a single satellite configuration matching the provided satellite configuration name
    fn get_satellite_configuration_by_name(
        &self,
        satellite_configuration_name: &str,
    ) -> impl Future<Output = Result<Self::Container<SatelliteConfiguration>, Error>> + Send + Sync
    {
        async move {
            let mut uri = self.path_to_url("satellite_configurations/search/findOneByName");
            uri.set_query(Some(&format!("name={satellite_configuration_name}")));

            self.get_json_map(uri).await
        }
    }

    /// Produces a paginated stream of [`Site`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_sites(&self) -> PaginatedStream<'_, Self::Container<Site>> {
        let uri = self.path_to_url("sites");
        self.get_paginated(uri)
    }

    /// Produces a single [`Site`] object matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_site_by_id(
        &self,
        id: i32,
    ) -> impl Future<Output = Result<Self::Container<Site>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("sites/{id}"));
            self.get_json_map(uri).await
        }
    }

    /// Produces a single [`Site`] object matching the provided name.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_site_by_name(
        &self,
        name: impl AsRef<str> + Send + Sync,
    ) -> impl Future<Output = Result<Self::Container<Site>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("sites/search/findOneByName");
            let query = format!("name={}", name.as_ref());
            uri.set_query(Some(&query));

            self.get_json_map(uri).await
        }
    }

    /// Produces a single [`TaskRequest`] matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_request_by_id(
        &self,
        task_request_id: i32,
    ) -> impl Future<Output = Result<Self::Container<TaskRequest>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("requests/{task_request_id}"));

            self.get_json_map(uri).await
        }
    }

    /// Produces a paginated stream of [`TaskRequest`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests(&self) -> PaginatedStream<'_, Self::Container<TaskRequest>> {
        {
            let uri = self.path_to_url("requests/search/findAll");
            self.get_paginated(uri)
        }
    }

    /// Produces a vector of [`TaskRequest`] items, representing all the task requests matching the
    /// target time overlapping with the provided time range.
    fn get_requests_by_target_date_between(
        &self,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("requests/search/findAllByTargetDateBetween");

            uri.set_query(Some(&format!(
                "start={}&end={}",
                start.format(&Iso8601::DEFAULT).unwrap(),
                end.format(&Iso8601::DEFAULT).unwrap(),
            )));

            self.get_json_map(uri).await
        }
    }

    /// Produces a vector of [`TaskRequest`] items,
    /// representing all the task requests matching the account at the provided URI and whose
    /// target time overlaps with the provided time range.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_account_and_target_date_between<T>(
        &self,
        account_uri: T,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>>
    where
        T: AsRef<str> + Send + Sync,
    {
        let mut uri = self.path_to_url("requests/search/findAllByAccountAndTargetDateBetween");

        uri.set_query(Some(&format!(
            "account={}&start={}&end={}",
            account_uri.as_ref(),
            start.format(&Iso8601::DEFAULT).unwrap(),
            end.format(&Iso8601::DEFAULT).unwrap(),
        )));

        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`TaskRequest`]
    /// objects whose account name matches the provided name, and whose pass will occur today.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_account_and_upcoming_today(
        &self,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>> {
        let uri = self.path_to_url("requests/search/findByAccountUpcomingToday");

        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`TaskRequest`]
    /// objects whose satellite configuration matches that of the configuration at the
    /// `configuration_uri` endpoint.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    ///
    /// # Note
    /// The results are ordered by the creation time of the task request
    fn get_requests_by_configuration<T>(
        &self,
        configuration_uri: T,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>>
    where
        T: AsRef<str> + Send + Sync,
    {
        let mut uri = self.path_to_url("requests/search/findAllByConfigurationOrderByCreatedAsc");

        uri.set_query(Some(&format!(
            "configuration={}",
            configuration_uri.as_ref()
        )));

        self.get_paginated::<TaskRequest>(uri)
    }

    /// Produces a vector of [`TaskRequest`] items, representing all the task requests which match
    /// the provided configuration, whose satellite name matches one of the names provided as part
    /// of `satellite_name`, and which overlaps the provided time range.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_by_configuration_and_satellite_names_and_target_date_between<T, I, S>(
        &self,
        configuration_uri: T,
        satellites: I,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
        I: IntoIterator<Item = S> + Send + Sync,
        S: AsRef<str> + Send + Sync,
    {
        async move {
            let satellites_string = crate::utils::list_to_string(satellites);
            let mut uri = self.path_to_url(
                "requests/search/findAllByConfigurationAndSatelliteNamesAndTargetDateBetween",
            );

            uri.set_query(Some(&format!(
                "configuration={}&satelliteNames={}&start={}&end={}",
                configuration_uri.as_ref(),
                satellites_string,
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?,
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`TaskRequest`] items, representing all the task requests matching the
    /// configuration at the provided URI and whose target time overlaps with the provided time
    /// range.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_configuration_and_target_date_between<T>(
        &self,
        configuration_uri: T,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
    {
        async move {
            let mut uri =
                self.path_to_url("requests/search/findAllByConfigurationAndTargetDateBetween");
            uri.set_query(Some(&format!(
                "configuration={}&start={}&end={}",
                configuration_uri.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?,
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`TaskRequest`] items,
    /// representing all the task requests whose ID matches one of the IDs provided as part of
    /// `ids`.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_by_ids<I, S>(
        &self,
        ids: I,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync
    where
        I: IntoIterator<Item = S> + Send + Sync,
        S: AsRef<str> + Send + Sync,
    {
        async move {
            let ids_string = crate::utils::list_to_string(ids);
            let mut uri = self.path_to_url("requests/search/findAllByIds");

            uri.set_query(Some(&format!("ids={}", ids_string)));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a paginated stream of [`TaskRequest`] objects which are public, and which overlap
    /// with the provided time range.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_overlapping_public(
        &self,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>> {
        let mut uri = self.path_to_url("requests/search/findAllByOverlappingPublic");

        uri.set_query(Some(&format!(
            "start={}&end={}",
            start.format(&Iso8601::DEFAULT).unwrap(),
            end.format(&Iso8601::DEFAULT).unwrap(),
        )));

        self.get_paginated(uri)
    }

    /// Produces a paginated stream of [`TaskRequest`] objects whose satellite name matches one of
    /// the names provided as part of `satellite_name`.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_satellite_name<T>(
        &self,
        satellite_name: T,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>>
    where
        T: AsRef<str> + Send + Sync,
    {
        let mut uri = self.path_to_url("requests/search/findBySatelliteName");

        uri.set_query(Some(&format!("name={}", satellite_name.as_ref())));

        self.get_paginated(uri)
    }

    /// Produces a vector of [`TaskRequest`] items, representing all the task requests whose
    /// satellite name matches the provided name and whose target time overlaps with the provided
    /// time range.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_by_satellite_name_and_target_date_between<T>(
        &self,
        satellite_name: T,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
    {
        async move {
            let mut uri =
                self.path_to_url("requests/search/findAllBySatelliteNameAndTargetDateBetween");

            uri.set_query(Some(&format!(
                "name={}&start={}&end={}",
                satellite_name.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a paginated stream of [`TaskRequest`] objects whose status matches the provided
    /// status.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_status<T>(
        &self,
        status: T,
    ) -> Result<PaginatedStream<'_, Self::Container<TaskRequest>>, Error>
    where
        T: TryInto<TaskStatusType> + Send + Sync,
        Error: From<<T as TryInto<TaskStatusType>>::Error>,
    {
        let status: TaskStatusType = status.try_into()?;
        let mut uri = self.path_to_url("requests/search/findByStatus");

        uri.set_query(Some(&format!("status={}", status.as_ref())));

        Ok(self.get_paginated(uri))
    }

    /// Produces a paginated stream of [`TaskRequest`], representing all the task requests which
    /// match the provided status, account, and overlap the provided time range.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_requests_by_status_and_account_and_target_date_between<T, U>(
        &self,
        status: T,
        account_uri: U,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> PaginatedStream<'_, Self::Container<TaskRequest>>
    where
        T: AsRef<str> + Send + Sync,
        U: AsRef<str> + Send + Sync,
    {
        let mut uri =
            self.path_to_url("requests/search/findAllByStatusAndAccountAndTargetDateBetween");

        uri.set_query(Some(&format!(
            "status={}&satelliteNames={}&start={}&end={}",
            status.as_ref(),
            account_uri.as_ref(),
            start.format(&Iso8601::DEFAULT).unwrap(),
            end.format(&Iso8601::DEFAULT).unwrap()
        )));

        self.get_paginated(uri)
    }

    /// Produces a vector of [`TaskRequest`] items, representing all the tasks which match the
    /// provided type, overlap with the provided time range.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_by_type_and_target_date_between<T>(
        &self,
        typ: T,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync
    where
        T: TryInto<TaskType> + Send + Sync,
        Error: From<<T as TryInto<TaskType>>::Error>,
    {
        async move {
            let typ: TaskType = typ.try_into()?;
            let mut uri = self.path_to_url("requests/search/findAllByTypeAndTargetDateBetween");

            uri.set_query(Some(&format!(
                "type={}&start={}&end={}",
                typ.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`TaskRequest`] items, representing the list of tasks which have
    /// already occurred today.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_passed_today(
        &self,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url("requests/search/findAllPassedToday");

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`TaskRequest`] items, representing the list of tasks which will occur
    /// later today.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_requests_upcoming_today(
        &self,
    ) -> impl Future<Output = Result<Self::Container<Vec<TaskRequest>>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url("requests/search/findAllUpcomingToday");

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<TaskRequest>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a paginated stream of [`Satellite`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_satellites(&self) -> PaginatedStream<'_, Self::Container<Satellite>> {
        let uri = self.path_to_url("satellites");

        self.get_paginated(uri)
    }

    /// Produces single satellite object matching the provided satellite ID
    fn get_satellite_by_id(
        &self,
        satellite_id: i32,
    ) -> impl Future<Output = Result<Self::Container<Satellite>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("satellites/{}", satellite_id));

            self.get_json_map(uri).await
        }
    }

    /// Produces single satellite object matching the provided satellite name
    fn get_satellite_by_name(
        &self,
        satellite_name: &str,
    ) -> impl Future<Output = Result<Self::Container<Satellite>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("satellites/findOneByName");
            uri.set_query(Some(&format!("name={satellite_name}")));

            self.get_json_map(uri).await
        }
    }

    /// Produces a single [`Task`] matching the provided ID.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_task_by_id(
        &self,
        task_id: i32,
    ) -> impl Future<Output = Result<Self::Container<Task>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url(format!("tasks/{}", task_id));

            self.get_json_map(uri).await
        }
    }

    /// Produces a vector of [`Task`] items, representing all the tasks which match the provided
    /// account, and intersect with the provided time frame.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_tasks_by_account_and_pass_overlapping<T>(
        &self,
        account_uri: T,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
    {
        async move {
            let mut uri = self.path_to_url("tasks/search/findByAccountAndPassOverlapping");

            uri.set_query(Some(&format!(
                "account={}&start={}&end={}",
                account_uri.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`Task`] items, representing all the tasks which match the provided
    /// account, satellite, band, and intersect with the provided time frame.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_tasks_by_account_and_satellite_and_band_and_pass_overlapping<T, U, V>(
        &self,
        account_uri: T,
        satellite_config_uri: U,
        band: V,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
        U: AsRef<str> + Send + Sync,
        V: AsRef<str> + Send + Sync,
    {
        async move {
            let mut uri = self.path_to_url(
                "tasks/search/findByAccountAndSiteConfigurationAndBandAndPassOverlapping",
            );

            uri.set_query(Some(&format!(
                "account={}&satellite={}&band={}&start={}&end={}",
                account_uri.as_ref(),
                satellite_config_uri.as_ref(),
                band.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?,
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`Task`] representing all the tasks which match the provided account,
    /// site configuration, band, and intersect with the provided time frame.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_tasks_by_account_and_site_configuration_and_band_and_pass_overlapping<T, U, V>(
        &self,
        account_uri: T,
        site_config_uri: U,
        band: V,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync
    where
        T: AsRef<str> + Send + Sync,
        U: AsRef<str> + Send + Sync,
        V: AsRef<str> + Send + Sync,
    {
        async move {
            let mut uri = self.path_to_url(
                "tasks/search/findByAccountAndSiteConfigurationAndBandAndPassOverlapping",
            );

            uri.set_query(Some(&format!(
                "account={}&siteConfig={}&band={}&start={}&end={}",
                account_uri.as_ref(),
                site_config_uri.as_ref(),
                band.as_ref(),
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`Task`] items, representing all the tasks contained within the
    /// provided time frame.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    ///
    /// # Note
    ///
    /// This differs from [`Self::get_tasks_by_pass_overlapping`] in that it only produces tasks
    /// which are wholly contained within the window.
    fn get_tasks_by_pass_window(
        &self,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync {
        async move {
            let mut uri = self.path_to_url("tasks/search/findByStartBetweenOrderByStartAsc");

            uri.set_query(Some(&format!(
                "start={}&end={}",
                start.format(&Iso8601::DEFAULT)?,
                end.format(&Iso8601::DEFAULT)?
            )));

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a paginated stream of [`Task`] items, representing all the tasks which overlap the
    /// provided time frame.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    ///
    /// # Note
    ///
    /// This differs from [`Self::get_tasks_by_pass_window`] in that it also includes tasks which
    /// only partially fall within the provided time frame.
    fn get_tasks_by_pass_overlapping(
        &self,
        start: OffsetDateTime,
        end: OffsetDateTime,
    ) -> PaginatedStream<'_, Self::Container<Task>> {
        let start = match start.format(&Iso8601::DEFAULT).map_err(Error::from) {
            Ok(start) => start,
            Err(error) => return error.once_err(),
        };

        let end = match end.format(&Iso8601::DEFAULT).map_err(Error::from) {
            Ok(end) => end,
            Err(error) => return error.once_err(),
        };

        let mut uri = self.path_to_url("tasks/search/findByOverlapping");

        uri.set_query(Some(&format!("start={}&end={}", start, end)));

        self.get_paginated(uri)
    }

    /// Produces a vector of [`Task`] items, representing the list of tasks which have already
    /// occurred today.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_tasks_passed_today(
        &self,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url("tasks/search/findAllPassedToday");

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a vector of [`Task`] items, representing the list of tasks which will occur later
    /// today.
    ///
    /// See [`get`](Self::get) documentation for more details about the process and return type
    fn get_tasks_upcoming_today(
        &self,
    ) -> impl Future<Output = Result<Self::Container<Vec<Task>>, Error>> + Send + Sync {
        async move {
            let uri = self.path_to_url("tasks/search/findAllUpcomingToday");

            Ok(self
                .get_json_map::<Embedded<Self::Container<Vec<Task>>>>(uri)
                .await?
                .items)
        }
    }

    /// Produces a paginated stream of [`User`] objects.
    ///
    /// See [`get_paginated`](Self::get_paginated) documentation for more details about the process
    /// and return type
    fn get_users(&self) -> PaginatedStream<'_, Self::Container<User>> {
        let uri = self.path_to_url("users");
        self.get_paginated(uri)
    }

    /// Create a new satellite band object
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_band_details()
    ///     .name("My Satellite Band")
    ///     .band_type(BandType::Receive)
    ///     .frequency(8096.0)
    ///     .default_band_width(1.45)
    ///     .io_hardware(IoHardware::Modem)
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_band_details(&self) -> post::band::BandDetailsBuilder<'_, Self, post::band::NoName>
    where
        Self: Sized,
    {
        post::band::new(self)
    }

    /// Create a new satellite configuration
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_satellite_configuration()
    ///     .name("My Satellite Configuration")
    ///     .band_ids([1, 2, 3]) // List of band IDs to associate with config
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_satellite_configuration(
        &self,
    ) -> post::sat_config::SatelliteConfigurationBuilder<'_, Self, post::sat_config::NoName>
    where
        Self: Sized,
    {
        post::sat_config::new(self)
    }

    /// Create a new satellite
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_satellite()
    ///     .name("My Satellite")
    ///     .satellite_configuration_id(42)
    ///     .norad_id(3600)
    ///     .description("A test satellite")
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_satellite(&self) -> post::satellite::SatelliteBuilder<'_, Self, post::satellite::NoName>
    where
        Self: Sized,
    {
        post::satellite::new(self)
    }

    /// Create a new override
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_override()
    ///     .name("downconverter.gain override for sat 1 on config 2")
    ///     .satellite_id(1)
    ///     .satellite_configuration_id(2)
    ///     .add_property("site.hardware.modem.ttc.rx.demodulator.bitrate", 8096_u32)
    ///     .add_property("site.hardware.modem.ttc.tx.modulator.bitrate", 8096_u32)
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_override(&self) -> post::overrides::OverrideBuilder<'_, Self, post::overrides::NoName>
    where
        Self: Sized,
    {
        post::overrides::new(self)
    }

    /// Create a new user
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_user()
    ///     .account_id(1)
    ///     .first_name("Han")
    ///     .last_name("Solo")
    ///     .email("flyingsolo@gmail.com")
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_user(&self) -> post::user::UserBuilder<'_, Self, post::user::NoAccount>
    where
        Self: Sized,
    {
        post::user::new(self)
    }

    /// Create a new task request
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # use time::OffsetDateTime;
    /// # use std::time::Duration;
    /// # tokio_test::block_on(async {
    /// let client = Client::from_env()?;
    ///
    /// client
    ///     .new_task_request()
    ///     .test_task("my_test_file.bin")
    ///     .target_time_utc(OffsetDateTime::now_utc() + Duration::from_secs(15 * 60))
    ///     .task_duration(120)
    ///     .satellite_id(1016)
    ///     .site_id(27)
    ///     .site_configuration_id(47)
    ///     .band_ids([2017, 2019])
    ///     .send()
    ///     .await?;
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_task_request(&self) -> post::TaskRequestBuilder<'_, Self, post::request::NoType>
    where
        Self: Sized,
    {
        post::request::new(self)
    }

    /// Fetch an FPS token for the provided band ID and site configuration ID
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// const BAND_ID: u32 = 42;
    /// const SITE_CONFIG_ID: u32 = 201;
    ///
    /// let client = Client::from_env()?;
    ///
    /// let token = client.new_token_by_site_configuration_id(BAND_ID, SITE_CONFIG_ID).await?;
    /// // Submit token to FPS ...
    /// println!("{:?}", token);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_token_by_site_configuration_id(
        &self,
        band_id: u32,
        site_configuration_id: u32,
    ) -> impl Future<Output = Result<String, Error>> + Send + Sync {
        async move {
            let url = self.path_to_url("fps");
            let payload = serde_json::json!({
                "band": format!("/api/satellite_bands/{}", band_id),
                "configuration": format!("/api/configurations/{}", site_configuration_id),
            });

            let value: JsonValue = self.post_deserialize(url, &payload).await?;

            value
                .get("token")
                .ok_or(Error::Response(String::from("Missing token field")))?
                .as_str()
                .ok_or(Error::Response(String::from("Invalid type for token")))
                .map(|s| s.to_owned())
                .map_err(From::from)
        }
    }

    /// Fetch an FPS token for the provided band ID and satellite ID
    ///
    /// # Example
    ///
    /// ```no_run
    /// # use freedom_api::prelude::*;
    /// # tokio_test::block_on(async {
    /// const BAND_ID: u32 = 42;
    /// const SATELLITE_ID: u32 = 101;
    ///
    /// let client = Client::from_env()?;
    ///
    /// let token = client.new_token_by_satellite_id(BAND_ID, SATELLITE_ID).await?;
    /// // Submit token to FPS ...
    /// println!("{:?}", token);
    /// # Ok::<_, Box<dyn std::error::Error>>(())
    /// # });
    /// ```
    fn new_token_by_satellite_id(
        &self,
        band_id: u32,
        satellite_id: u32,
    ) -> impl Future<Output = Result<String, Error>> + Send + Sync {
        async move {
            let url = self.path_to_url("fps");
            let payload = serde_json::json!({
                "band": format!("/api/satellite_bands/{}", band_id),
                "satellite": format!("/api/satellites/{}", satellite_id),
            });

            let value: JsonValue = self.post_deserialize(url, &payload).await?;

            value
                .get("token")
                .ok_or(Error::Response(String::from("Missing token field")))?
                .as_str()
                .ok_or(Error::Response(String::from("Invalid type for token")))
                .map(|s| s.to_owned())
                .map_err(From::from)
        }
    }
}

fn error_on_non_success(status: &StatusCode) -> Result<(), Error> {
    if !status.is_success() {
        return Err(Error::Response(status.to_string()));
    }

    Ok(())
}