Skip to main content

unitycatalog_client/codegen/catalogs/
resource.rs

1// @generated — do not edit by hand.
2#![allow(unused_imports)]
3use super::builders::*;
4use super::client::CatalogServiceClient;
5use unitycatalog_common::models::catalogs::v1::*;
6use unitycatalog_common::models::schemas::v1::*;
7/// A client scoped to a single `catalog`.
8#[derive(Clone)]
9pub struct CatalogClient {
10    pub(crate) catalog_name: String,
11    pub(crate) client: CatalogServiceClient,
12}
13impl CatalogClient {
14    /// Create a client bound to the resource's name components.
15    pub fn new(catalog_name: impl Into<String>, client: CatalogServiceClient) -> Self {
16        Self {
17            catalog_name: catalog_name.into(),
18            client,
19        }
20    }
21    /// This resource's own name (the leaf component).
22    pub fn name(&self) -> &str {
23        &self.catalog_name
24    }
25    /// The fully-qualified name of this resource.
26    pub fn full_name(&self) -> String {
27        self.catalog_name.clone()
28    }
29    /// Get a catalog
30    ///
31    /// Gets the specified catalog in a metastore. The caller must be a metastore admin,
32    /// the owner of the catalog, or a user that has the USE_CATALOG privilege set for their account.
33    pub fn get(&self) -> GetCatalogBuilder {
34        GetCatalogBuilder::new(self.client.clone(), &self.catalog_name)
35    }
36    /// Update a catalog
37    ///
38    /// Updates the catalog that matches the supplied name. The caller must be either
39    /// the owner of the catalog, or a metastore admin (when changing the owner field of the catalog).
40    pub fn update(&self) -> UpdateCatalogBuilder {
41        UpdateCatalogBuilder::new(self.client.clone(), &self.catalog_name)
42    }
43    /// Delete a catalog
44    ///
45    /// Deletes the catalog that matches the supplied name. The caller must
46    /// be a metastore admin or the owner of the catalog.
47    pub fn delete(&self) -> DeleteCatalogBuilder {
48        DeleteCatalogBuilder::new(self.client.clone(), &self.catalog_name)
49    }
50    /// Access a `schema` within this resource.
51    pub fn schema(&self, schema_name: impl Into<String>) -> crate::codegen::schemas::SchemaClient {
52        crate::codegen::schemas::SchemaClient::new(
53            &self.catalog_name,
54            schema_name,
55            crate::codegen::schemas::SchemaServiceClient::new(
56                self.client.client.clone(),
57                self.client.base_url.clone(),
58            ),
59        )
60    }
61    /// Create a `schema` within this resource.
62    pub fn create_schema(
63        &self,
64        name: impl Into<String>,
65    ) -> crate::codegen::schemas::CreateSchemaBuilder {
66        crate::codegen::schemas::CreateSchemaBuilder::new(
67            crate::codegen::schemas::SchemaServiceClient::new(
68                self.client.client.clone(),
69                self.client.base_url.clone(),
70            ),
71            name,
72            &self.catalog_name,
73        )
74    }
75    /// List `schema` resources within this resource.
76    pub fn list_schemas(&self) -> crate::codegen::schemas::ListSchemasBuilder {
77        crate::codegen::schemas::ListSchemasBuilder::new(
78            crate::codegen::schemas::SchemaServiceClient::new(
79                self.client.client.clone(),
80                self.client.base_url.clone(),
81            ),
82            &self.catalog_name,
83        )
84    }
85}