#![allow(unused_imports)]
use super::builders::*;
use super::client::FunctionServiceClient;
use unitycatalog_common::models::functions::v1::*;
#[derive(Clone)]
pub struct FunctionClient {
pub(crate) catalog_name: String,
pub(crate) schema_name: String,
pub(crate) function_name: String,
pub(crate) client: FunctionServiceClient,
}
impl FunctionClient {
pub fn new(
catalog_name: impl Into<String>,
schema_name: impl Into<String>,
function_name: impl Into<String>,
client: FunctionServiceClient,
) -> Self {
Self {
catalog_name: catalog_name.into(),
schema_name: schema_name.into(),
function_name: function_name.into(),
client,
}
}
pub fn from_full_name(full_name: impl Into<String>, client: FunctionServiceClient) -> Self {
let full_name = full_name.into();
let mut parts = full_name.splitn(3usize, '.');
let catalog_name = parts.next().unwrap_or_default();
let schema_name = parts.next().unwrap_or_default();
let function_name = parts.next().unwrap_or_default();
Self::new(catalog_name, schema_name, function_name, client)
}
pub fn catalog_name(&self) -> &str {
&self.catalog_name
}
pub fn schema_name(&self) -> &str {
&self.schema_name
}
pub fn name(&self) -> &str {
&self.function_name
}
pub fn full_name(&self) -> String {
format!(
"{}.{}.{}",
self.catalog_name, self.schema_name, self.function_name
)
}
pub fn get(&self) -> GetFunctionBuilder {
GetFunctionBuilder::new(
self.client.clone(),
format!(
"{}.{}.{}",
self.catalog_name, self.schema_name, self.function_name
),
)
}
pub fn update(&self) -> UpdateFunctionBuilder {
UpdateFunctionBuilder::new(
self.client.clone(),
format!(
"{}.{}.{}",
self.catalog_name, self.schema_name, self.function_name
),
)
}
pub fn delete(&self) -> DeleteFunctionBuilder {
DeleteFunctionBuilder::new(
self.client.clone(),
format!(
"{}.{}.{}",
self.catalog_name, self.schema_name, self.function_name
),
)
}
}