Skip to content

Commit 2b8088f

Browse files
authored
feat: Add support for Freedom Gateway licensing API (#18)
* feat: Add support for Freedom Gateway licensing API * dep: freedom-models -> 2.4.0
1 parent ca54e08 commit 2b8088f

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

Cargo.toml

Lines changed: 1 addition & 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 = { version = "2.4.0", features = ["serde"] }
3232

3333
[dev-dependencies]
3434
futures = { version = "0.3.30" }

src/gateway_licenses.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use freedom_models::gateway_licenses;
2+
3+
use crate::{Api, error::Error};
4+
5+
/// Extension API for interacting with the Freedom Gateway licensing architecture
6+
pub trait GatewayApi: Api {
7+
fn get_all_gateway_licenses(
8+
&self,
9+
) -> impl Future<Output = Result<gateway_licenses::View, Error>> + Send + Sync {
10+
let uri = self.path_to_url("gateway-licenses");
11+
self.get_json_map(uri)
12+
}
13+
14+
fn get_all_gateway_license(
15+
&self,
16+
id: u32,
17+
) -> impl Future<Output = Result<gateway_licenses::ViewOne, Error>> + Send + Sync {
18+
let uri = self.path_to_url(format!("gateway-licenses/{id}"));
19+
self.get_json_map(uri)
20+
}
21+
22+
fn verify_gateway_license(
23+
&self,
24+
request: gateway_licenses::Verify,
25+
) -> impl Future<Output = Result<gateway_licenses::VerifyResponse, Error>> + Send + Sync {
26+
let uri = self.path_to_url("gateway-licenses/verify");
27+
self.post_deserialize(uri, request)
28+
}
29+
30+
fn regenerate_gateway_license(
31+
&self,
32+
id: u32,
33+
) -> impl Future<Output = Result<gateway_licenses::RegenerateResponse, Error>> + Send + Sync
34+
{
35+
let uri = self.path_to_url(format!("gateway-licenses/{id}/regenerate"));
36+
self.post_deserialize(uri, serde_json::json!({}))
37+
}
38+
}
39+
40+
impl<T> GatewayApi for T where T: Api {}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ mod caching_client;
66
mod client;
77
pub mod error;
88
pub mod extensions;
9+
mod gateway_licenses;
910
mod utils;
1011

1112
pub use self::{
1213
api::{Api, Container, Inner, PaginatedStream, Value},
1314
client::Client,
15+
gateway_licenses::GatewayApi,
1416
};
1517

1618
/// Contains the client, data models, and traits necessary for queries

0 commit comments

Comments
 (0)