pub struct Catalog { /* private fields */ }Expand description
Reads database, schema, table, and view definitions.
Select the smallest resource you need, then call CatalogResource::get.
Each read returns the complete definition and an ETag for conditional changes.
let snapshot = client.catalog().schema("scopedb", "public").get().await?;
for table in snapshot.definition.tables {
println!("{}: {} columns", table.name, table.columns.len());
}Use CatalogResource::apply to change a definition and
CatalogResource::delete to remove a resource. Both support previews and
ETag preconditions through CatalogOptions.
Implementations§
Source§impl Catalog
impl Catalog
Sourcepub async fn get(&self) -> Result<CatalogSnapshot<CatalogDocument>, Error>
pub async fn get(&self) -> Result<CatalogSnapshot<CatalogDocument>, Error>
Examples found in repository?
examples/catalog.rs (line 23)
18async fn main() -> Result<(), Box<dyn std::error::Error>> {
19 let client = common::client()?;
20 let database = common::database();
21 let schema = common::schema();
22
23 let catalog = client.catalog().get().await?;
24 for item in catalog.definition.databases {
25 println!(
26 "database {}: {}",
27 item.name,
28 item.comment.unwrap_or_default()
29 );
30 }
31 let snapshot = client.catalog().schema(&database, &schema).get().await?;
32 println!("schema ETag: {}", snapshot.etag);
33 for table in snapshot.definition.tables {
34 println!("table {}: {:?}", table.name, table.columns);
35 }
36 Ok(())
37}Sourcepub async fn apply(
&self,
definition: &CatalogDocument,
options: CatalogOptions,
) -> Result<CatalogResult<CatalogDocument>, Error>
pub async fn apply( &self, definition: &CatalogDocument, options: CatalogOptions, ) -> Result<CatalogResult<CatalogDocument>, Error>
Replaces the complete tenant catalog. An empty document clears it.
Sourcepub fn raw(&self) -> CatalogResource<Value>
pub fn raw(&self) -> CatalogResource<Value>
Retains fields unknown to this SDK when reading and applying definitions.
pub fn database(&self, database: &str) -> CatalogResource<CatalogDatabase>
Sourcepub fn schema(
&self,
database: &str,
schema: &str,
) -> CatalogResource<CatalogSchema>
pub fn schema( &self, database: &str, schema: &str, ) -> CatalogResource<CatalogSchema>
Examples found in repository?
examples/catalog.rs (line 31)
18async fn main() -> Result<(), Box<dyn std::error::Error>> {
19 let client = common::client()?;
20 let database = common::database();
21 let schema = common::schema();
22
23 let catalog = client.catalog().get().await?;
24 for item in catalog.definition.databases {
25 println!(
26 "database {}: {}",
27 item.name,
28 item.comment.unwrap_or_default()
29 );
30 }
31 let snapshot = client.catalog().schema(&database, &schema).get().await?;
32 println!("schema ETag: {}", snapshot.etag);
33 for table in snapshot.definition.tables {
34 println!("table {}: {:?}", table.name, table.columns);
35 }
36 Ok(())
37}pub fn table( &self, database: &str, schema: &str, table: &str, ) -> CatalogResource<CatalogTable>
pub fn view( &self, database: &str, schema: &str, view: &str, ) -> CatalogResource<CatalogView>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Catalog
impl !RefUnwindSafe for Catalog
impl !UnwindSafe for Catalog
impl Send for Catalog
impl Sync for Catalog
impl Unpin for Catalog
impl UnsafeUnpin for Catalog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more