unitycatalog_client/codegen/temporary_credentials/
client.rs1#![allow(unused_imports)]
3use crate::Result;
4use olai_http::CloudClient;
5use unitycatalog_common::models::temporary_credentials::v1::*;
6use url::Url;
7#[derive(Clone)]
9pub struct TemporaryCredentialClient {
10 pub(crate) client: CloudClient,
11 pub(crate) base_url: Url,
12}
13impl TemporaryCredentialClient {
14 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 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 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 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}