add rootly stub

This commit is contained in:
Brandon Thomas committed 2026-03-25 02:18:58 -04:00
1 parent 389b1c3d17
commit c35ea620b3
14 files changed
+200

No files matched your search

Generated
+16
View File
@@ -9584,6 +9584,22 @@ dependencies = [
"syn 1.0.109",
]
[[package]]
name = "rootly_client"
version = "0.0.1"
dependencies = [
"env",
"env_logger 0.11.9",
"errors",
"log",
"reqwest 0.12.23",
"serde",
"serde_derive",
"serde_json",
"tokio",
"workspace-build-acceleration",
]
[[package]]
name = "rsa"
version = "0.9.6"
+2
View File
@@ -18,6 +18,7 @@ members = [
"crates/api_clients/muapi_client",
"crates/api_clients/openai_sora_client",
"crates/api_clients/openart_client",
"crates/api_clients/rootly_client",
"crates/api_clients/runwayml_client",
"crates/api_clients/seedance2pro_client",
"crates/api_clients/thumbnail_generator",
@@ -239,6 +240,7 @@ ffmpeg_utils = { path = "crates/lib/ffmpeg_utils" }
file_to_base64_url = { path = "crates/lib/files/file_to_base64_url" }
filesys = { path = "crates/lib/files/filesys" }
grok_client = { path = "crates/api_clients/grok_client" }
rootly_client = { path = "crates/api_clients/rootly_client" }
http_headers = { path = "crates/lib/http_headers" }
images = { path = "crates/lib/files/images" }
jobs_common = { path = "crates/lib/jobs_common" }
@@ -0,0 +1,31 @@
[package]
name = "rootly_client"
edition = "2024"
version = "0.0.1"
publish = false
[package.metadata.cargo-udeps.ignore]
normal = ["workspace-build-acceleration"]
[lib]
name = "rootly_client"
path = "src/lib.rs"
[dependencies]
# Workspace hack (faster compile times)
workspace-build-acceleration.workspace = true
# Internal
errors.workspace = true
# External
log.workspace = true
reqwest.workspace = true
serde.workspace = true
serde_derive.workspace = true
serde_json.workspace = true
[dev-dependencies]
env.workspace = true
env_logger.workspace = true
tokio = { version = "1", features = ["full"] }
@@ -0,0 +1 @@
pub mod rootly_api_key;
@@ -0,0 +1,11 @@
/// Holds the API key for authenticating with the Rootly API.
#[derive(Clone)]
pub struct RootlyApiKey {
pub (crate) api_key: String,
}
impl RootlyApiKey {
pub fn new(api_key: String) -> Self {
Self { api_key }
}
}
@@ -0,0 +1,4 @@
pub mod rootly_client_error;
pub mod rootly_error;
pub mod rootly_generic_api_error;
pub mod rootly_specific_api_error;
@@ -0,0 +1,22 @@
use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum RootlyClientError {
/// No API key is present.
NoApiKeyPresent,
/// An error was encountered in building the reqwest client.
ReqwestClientError(reqwest::Error),
}
impl Error for RootlyClientError {}
impl Display for RootlyClientError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::NoApiKeyPresent => write!(f, "No API key present."),
Self::ReqwestClientError(err) => write!(f, "Reqwest client error (during client creation): {}", err),
}
}
}
@@ -0,0 +1,41 @@
use crate::error::rootly_client_error::RootlyClientError;
use crate::error::rootly_generic_api_error::RootlyGenericApiError;
use crate::error::rootly_specific_api_error::RootlySpecificApiError;
use std::error::Error;
#[derive(Debug)]
pub enum RootlyError {
Client(RootlyClientError),
ApiSpecific(RootlySpecificApiError),
ApiGeneric(RootlyGenericApiError),
}
impl Error for RootlyError {}
impl std::fmt::Display for RootlyError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Client(e) => write!(f, "RootlyClientError: {:?}", e),
Self::ApiSpecific(e) => write!(f, "RootlySpecificApiError: {:?}", e),
Self::ApiGeneric(e) => write!(f, "RootlyGenericApiError: {:?}", e),
}
}
}
impl From<RootlyClientError> for RootlyError {
fn from(error: RootlyClientError) -> Self {
Self::Client(error)
}
}
impl From<RootlySpecificApiError> for RootlyError {
fn from(error: RootlySpecificApiError) -> Self {
Self::ApiSpecific(error)
}
}
impl From<RootlyGenericApiError> for RootlyError {
fn from(error: RootlyGenericApiError) -> Self {
Self::ApiGeneric(error)
}
}
@@ -0,0 +1,35 @@
use std::error::Error;
use std::fmt::{Display, Formatter};
use reqwest::StatusCode;
#[derive(Debug)]
pub enum RootlyGenericApiError {
/// serde_json::Error, likely from JSON deserialization schema mismatch.
/// Includes the original body.
SerdeResponseParseErrorWithBody(serde_json::Error, String),
/// An uncategorized bad HTTP response.
UncategorizedBadResponse(String),
/// An uncategorized bad HTTP response with status code and body.
UncategorizedBadResponseWithStatusAndBody {
status_code: StatusCode,
body: String,
},
/// An uncaught error from the HTTP client.
ReqwestError(reqwest::Error),
}
impl Error for RootlyGenericApiError {}
impl Display for RootlyGenericApiError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::SerdeResponseParseErrorWithBody(err, body) => write!(f, "Failed to parse response body: {:?}. Body: {}", err, body),
Self::UncategorizedBadResponse(msg) => write!(f, "Uncategorized bad response: {}", msg),
Self::UncategorizedBadResponseWithStatusAndBody { status_code, body } => write!(f, "Uncategorized bad response: status code {}, body: {}", status_code, body),
Self::ReqwestError(err) => write!(f, "Reqwest client error: {}", err),
}
}
}
@@ -0,0 +1,18 @@
use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum RootlySpecificApiError {
/// The API key is invalid or expired.
Unauthorized,
}
impl Error for RootlySpecificApiError {}
impl Display for RootlySpecificApiError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::Unauthorized => write!(f, "Unauthorized: API key is invalid or expired."),
}
}
}
@@ -0,0 +1,7 @@
#[cfg(test)]
pub (crate) mod test_utils;
// Public API
pub mod creds;
pub mod error;
pub mod requests;
@@ -0,0 +1 @@
// Endpoint request implementations will go here.
@@ -0,0 +1,9 @@
use errors::AnyhowResult;
use std::fs::read_to_string;
#[cfg(test)]
pub fn get_test_api_key() -> AnyhowResult<String> {
let api_key = read_to_string("/Users/bt/Artcraft/credentials/rootly_api_key.txt")?;
let api_key = api_key.trim().to_string();
Ok(api_key)
}
@@ -0,0 +1,2 @@
#[cfg(test)]
pub (crate) mod get_test_api_key;