Skip to main content

unitycatalog_client/codegen/functions/
resource.rs

1// @generated — do not edit by hand.
2#![allow(unused_imports)]
3use super::builders::*;
4use super::client::FunctionServiceClient;
5use unitycatalog_common::models::functions::v1::*;
6/// A client scoped to a single `function`.
7#[derive(Clone)]
8pub struct FunctionClient {
9    pub(crate) catalog_name: String,
10    pub(crate) schema_name: String,
11    pub(crate) function_name: String,
12    pub(crate) client: FunctionServiceClient,
13}
14impl FunctionClient {
15    /// Create a client bound to the resource's name components.
16    pub fn new(
17        catalog_name: impl Into<String>,
18        schema_name: impl Into<String>,
19        function_name: impl Into<String>,
20        client: FunctionServiceClient,
21    ) -> Self {
22        Self {
23            catalog_name: catalog_name.into(),
24            schema_name: schema_name.into(),
25            function_name: function_name.into(),
26            client,
27        }
28    }
29    /// Create a `function` client from its dot-joined full name (e.g. `"catalog_name.schema_name.function_name"`).
30    pub fn from_full_name(full_name: impl Into<String>, client: FunctionServiceClient) -> Self {
31        let full_name = full_name.into();
32        let mut parts = full_name.splitn(3usize, '.');
33        let catalog_name = parts.next().unwrap_or_default();
34        let schema_name = parts.next().unwrap_or_default();
35        let function_name = parts.next().unwrap_or_default();
36        Self::new(catalog_name, schema_name, function_name, client)
37    }
38    /// The `catalog_name` component of this resource's name.
39    pub fn catalog_name(&self) -> &str {
40        &self.catalog_name
41    }
42    /// The `schema_name` component of this resource's name.
43    pub fn schema_name(&self) -> &str {
44        &self.schema_name
45    }
46    /// This resource's own name (the leaf component).
47    pub fn name(&self) -> &str {
48        &self.function_name
49    }
50    /// The fully-qualified name of this resource (its dot-joined name components).
51    pub fn full_name(&self) -> String {
52        format!(
53            "{}.{}.{}",
54            self.catalog_name, self.schema_name, self.function_name
55        )
56    }
57    /// Get a function
58    ///
59    /// Gets a function from within a parent catalog and schema. For the fetch to succeed,
60    /// the caller must be a metastore admin, the owner of the function, or have SELECT on
61    /// the function.
62    pub fn get(&self) -> GetFunctionBuilder {
63        GetFunctionBuilder::new(
64            self.client.clone(),
65            format!(
66                "{}.{}.{}",
67                self.catalog_name, self.schema_name, self.function_name
68            ),
69        )
70    }
71    /// Update a function
72    ///
73    /// Updates the function that matches the supplied name. Only the owner of the function
74    /// can be updated.
75    pub fn update(&self) -> UpdateFunctionBuilder {
76        UpdateFunctionBuilder::new(
77            self.client.clone(),
78            format!(
79                "{}.{}.{}",
80                self.catalog_name, self.schema_name, self.function_name
81            ),
82        )
83    }
84    /// Delete a function
85    ///
86    /// Deletes the function that matches the supplied name. For the deletion to succeed,
87    /// the caller must be the owner of the function.
88    pub fn delete(&self) -> DeleteFunctionBuilder {
89        DeleteFunctionBuilder::new(
90            self.client.clone(),
91            format!(
92                "{}.{}.{}",
93                self.catalog_name, self.schema_name, self.function_name
94            ),
95        )
96    }
97}