use crate::client::GraphClient;
#[derive(Debug)]
pub struct RemoteGraph {
endpoint: String,
graph_id: String,
client: GraphClient,
}
impl RemoteGraph {
pub fn new(endpoint: impl Into<String>, graph_id: impl Into<String>) -> Self {
let endpoint_str = endpoint.into();
let graph_id_str = graph_id.into();
Self {
endpoint: endpoint_str.clone(),
graph_id: graph_id_str.clone(),
client: GraphClient::new(
reqwest::Client::new(),
format!("{endpoint_str}/graphs/{graph_id_str}"),
crate::client::AuthConfig::None,
),
}
}
#[must_use]
pub fn graph_id(&self) -> &str {
&self.graph_id
}
#[must_use]
pub fn endpoint(&self) -> &str {
&self.endpoint
}
#[must_use]
pub const fn client(&self) -> &GraphClient {
&self.client
}
}
impl Clone for RemoteGraph {
fn clone(&self) -> Self {
Self {
endpoint: self.endpoint.clone(),
graph_id: self.graph_id.clone(),
client: GraphClient::new(
self.client.client().clone(),
self.client.endpoint().to_string(),
self.client.auth().clone(),
),
}
}
}