Skip to main content

unitycatalog_client/codegen/temporary_credentials/
client.rs

1// @generated — do not edit by hand.
2#![allow(unused_imports)]
3use crate::Result;
4use olai_http::CloudClient;
5use unitycatalog_common::models::temporary_credentials::v1::*;
6use url::Url;
7/// HTTP client for service operations
8#[derive(Clone)]
9pub struct TemporaryCredentialClient {
10    pub(crate) client: CloudClient,
11    pub(crate) base_url: Url,
12}
13impl TemporaryCredentialClient {
14    /// Create a new client instance
15    pub fn new(client: CloudClient, mut base_url: Url) -> Self {
16        if !base_url.path().ends_with('/') {
17            base_url.set_path(&format!("{}/", base_url.path()));
18        }
19        Self { client, base_url }
20    }
21    /// Generate a new set of credentials for a table.
22    pub async fn generate_temporary_table_credentials(
23        &self,
24        request: &GenerateTemporaryTableCredentialsRequest,
25    ) -> Result<TemporaryCredential> {
26        let url = self.base_url.join("temporary-table-credentials")?;
27        let response = self.client.post(url).json(request).send().await?;
28        if !response.status().is_success() {
29            return Err(crate::error::parse_error_response(response).await);
30        }
31        let result = response.bytes().await?;
32        Ok(serde_json::from_slice(&result)?)
33    }
34    /// Generate a new set of credentials for a path.
35    pub async fn generate_temporary_path_credentials(
36        &self,
37        request: &GenerateTemporaryPathCredentialsRequest,
38    ) -> Result<TemporaryCredential> {
39        let url = self.base_url.join("temporary-path-credentials")?;
40        let response = self.client.post(url).json(request).send().await?;
41        if !response.status().is_success() {
42            return Err(crate::error::parse_error_response(response).await);
43        }
44        let result = response.bytes().await?;
45        Ok(serde_json::from_slice(&result)?)
46    }
47    /// Generate a new set of credentials for a volume.
48    ///
49    /// The metastore must have the `external_access_enabled` flag set to true
50    /// (default false). The caller must have the `EXTERNAL_USE_SCHEMA`
51    /// privilege on the parent schema (granted by a catalog owner).
52    pub async fn generate_temporary_volume_credentials(
53        &self,
54        request: &GenerateTemporaryVolumeCredentialsRequest,
55    ) -> Result<TemporaryCredential> {
56        let url = self.base_url.join("temporary-volume-credentials")?;
57        let response = self.client.post(url).json(request).send().await?;
58        if !response.status().is_success() {
59            return Err(crate::error::parse_error_response(response).await);
60        }
61        let result = response.bytes().await?;
62        Ok(serde_json::from_slice(&result)?)
63    }
64}