use anyhow::Result;
use crate::Client;
pub struct LinkedObjects {
pub client: Client,
}
impl LinkedObjects {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
LinkedObjects { client }
}
pub async fn list_definitions(&self) -> Result<Vec<crate::types::LinkedObject>> {
let url = "/api/v1/meta/schemas/user/linkedObjects".to_string();
self.client.get(&url, None).await
}
pub async fn list_all_definitions(&self) -> Result<Vec<crate::types::LinkedObject>> {
let url = "/api/v1/meta/schemas/user/linkedObjects".to_string();
self.client.get_all_pages(&url, None).await
}
pub async fn add_definition(
&self,
body: &crate::types::LinkedObject,
) -> Result<crate::types::LinkedObject> {
let url = "/api/v1/meta/schemas/user/linkedObjects".to_string();
self.client
.post(&url, Some(reqwest::Body::from(serde_json::to_vec(body)?)))
.await
}
pub async fn get_definition(
&self,
linked_object_name: &str,
) -> Result<crate::types::LinkedObject> {
let url = format!(
"/api/v1/meta/schemas/user/linkedObjects/{}",
crate::progenitor_support::encode_path(linked_object_name),
);
self.client.get(&url, None).await
}
pub async fn delete_definition(&self, linked_object_name: &str) -> Result<()> {
let url = format!(
"/api/v1/meta/schemas/user/linkedObjects/{}",
crate::progenitor_support::encode_path(linked_object_name),
);
self.client.delete(&url, None).await
}
}