Skip to content

Commit

Permalink
feat(wip): skeleton for new API endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe Spellman committed Mar 1, 2024
1 parent 962d6e3 commit 1a67201
Show file tree
Hide file tree
Showing 11 changed files with 141 additions and 2 deletions.
69 changes: 67 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ tower = "0.4"
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
axum = "0.7.4"
chrono = { version = "0.4.34", default-features = false, features = ["std", "clock", "serde"] }
log = { version = "0.4.21", features = ["serde"] }

[build-dependencies]
tonic-build = { version = "0.11", features = ["prost"] }
Expand Down
21 changes: 21 additions & 0 deletions src/features/admin/api_version/interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! The public interface of this endpoint
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

/// The request for getting the API Version, this is empty because
/// Any query will return the given response (authentication happens
// at a higher layer).
#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct ApiVersionRequest;

#[derive(Clone, Serialize, Deserialize)]
/// The response returning the API Version information.
pub struct ApiVersionResponse {
/// The current API Version
version: String,
/// The current commit sha
commit: String,
/// The timestamp this build was done at
build: DateTime<Utc>,
}
3 changes: 3 additions & 0 deletions src/features/admin/api_version/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! Contains API endpoints for getting build target information for the currently running service
pub mod interface;
17 changes: 17 additions & 0 deletions src/features/admin/log_level/get/interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//! The public interface for getting the log level
use log::Level;
use serde::{Deserialize, Serialize};

/// The request for getting the log level, empty because
/// the request is empty.
#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct GetLogLevelRequest;

/// The response for getting the leg level, [`tracing`] doesn't implement
/// [`Serialize`] so we use the one from [`log`] as an intermediary.
#[derive(Copy, Clone, Deserialize, Serialize)]
pub struct GetLogLevelResponse {
/// The log level we currently are at
level: Level,
}
3 changes: 3 additions & 0 deletions src/features/admin/log_level/get/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! The interface for setting the current log level
mod interface;
4 changes: 4 additions & 0 deletions src/features/admin/log_level/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Contains API endpoints for manipulating the log level
pub mod get;
pub mod set;
16 changes: 16 additions & 0 deletions src/features/admin/log_level/set/interface.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//! The public interface for defining setting the log level
use log::Level;
use serde::{Deserialize, Serialize};

/// The request for setting the log level
#[derive(Copy, Clone, Serialize, Deserialize)]
pub struct SetLogLevelRequest {
/// The current log level, [`tracing`] doesn't implement [`serde`] so
// we convert between the two internally.
level: Level,
}

/// The response for setting the log level, essentially nothing but an Ack
#[derive(Copy, Clone, Serialize, Deserialize)]
pub struct SetLogLevelResponse;
3 changes: 3 additions & 0 deletions src/features/admin/log_level/set/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! The endpoint for getting the current log level
mod interface;
4 changes: 4 additions & 0 deletions src/features/admin/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//! Contains API endpoints for administrative features
mod api_version;
mod log_level;
1 change: 1 addition & 0 deletions src/features/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! Contains various feature implementations for the ratings backend.
pub mod admin;
pub mod chart;
pub mod common;
pub mod pb;
Expand Down

0 comments on commit 1a67201

Please sign in to comment.