Skip to main content

unitycatalog_client/codegen/agents/
resource.rs

1// @generated — do not edit by hand.
2#![allow(unused_imports)]
3use super::builders::*;
4use super::client::AgentServiceClient;
5use unitycatalog_common::models::agents::v0alpha1::*;
6/// A client scoped to a single `agent`.
7#[derive(Clone)]
8pub struct AgentClient {
9    pub(crate) catalog_name: String,
10    pub(crate) schema_name: String,
11    pub(crate) agent_name: String,
12    pub(crate) client: AgentServiceClient,
13}
14impl AgentClient {
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        agent_name: impl Into<String>,
20        client: AgentServiceClient,
21    ) -> Self {
22        Self {
23            catalog_name: catalog_name.into(),
24            schema_name: schema_name.into(),
25            agent_name: agent_name.into(),
26            client,
27        }
28    }
29    /// Create a `agent` client from its dot-joined full name (e.g. `"catalog_name.schema_name.agent_name"`).
30    pub fn from_full_name(full_name: impl Into<String>, client: AgentServiceClient) -> 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 agent_name = parts.next().unwrap_or_default();
36        Self::new(catalog_name, schema_name, agent_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.agent_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.agent_name
55        )
56    }
57    pub fn get(&self) -> GetAgentBuilder {
58        GetAgentBuilder::new(
59            self.client.clone(),
60            format!(
61                "{}.{}.{}",
62                self.catalog_name, self.schema_name, self.agent_name
63            ),
64        )
65    }
66    pub fn update(&self) -> UpdateAgentBuilder {
67        UpdateAgentBuilder::new(
68            self.client.clone(),
69            format!(
70                "{}.{}.{}",
71                self.catalog_name, self.schema_name, self.agent_name
72            ),
73        )
74    }
75    pub fn delete(&self) -> DeleteAgentBuilder {
76        DeleteAgentBuilder::new(
77            self.client.clone(),
78            format!(
79                "{}.{}.{}",
80                self.catalog_name, self.schema_name, self.agent_name
81            ),
82        )
83    }
84}