Skip to main content

iceberg_rest_catalog/apis/
catalog_api_api.rs

1/*
2 * Apache Iceberg REST Catalog API
3 *
4 * Defines the specification for the first version of the REST Catalog API. Implementations should ideally support both Iceberg table specs v1 and v2, with priority given to v2.
5 *
6 * The version of the OpenAPI document: 0.0.1
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11use std::collections::HashMap;
12
13use super::{configuration, fetch, Error};
14use crate::{apis::ResponseContent, models};
15use iceberg_rust::{
16    catalog::{
17        commit::{CommitTable, CommitView},
18        create::{CreateTable, CreateView},
19    },
20    spec::view_metadata::Materialization,
21};
22use reqwest;
23use serde::{Deserialize, Serialize};
24
25/// struct for typed errors of method [`cancel_planning`]
26#[derive(Debug, Clone, Serialize, Deserialize)]
27#[serde(untagged)]
28pub enum CancelPlanningError {
29    Status400(models::IcebergErrorResponse),
30    Status401(models::IcebergErrorResponse),
31    Status403(models::IcebergErrorResponse),
32    Status404(models::IcebergErrorResponse),
33    Status419(models::IcebergErrorResponse),
34    Status503(models::IcebergErrorResponse),
35    Status5XX(models::IcebergErrorResponse),
36    UnknownValue(serde_json::Value),
37}
38
39/// struct for typed errors of method [`commit_transaction`]
40#[derive(Debug, Clone, Serialize, Deserialize)]
41#[serde(untagged)]
42pub enum CommitTransactionError {
43    Status400(models::IcebergErrorResponse),
44    Status401(models::IcebergErrorResponse),
45    Status403(models::IcebergErrorResponse),
46    Status404(models::IcebergErrorResponse),
47    Status409(models::IcebergErrorResponse),
48    Status419(models::IcebergErrorResponse),
49    Status500(models::IcebergErrorResponse),
50    Status503(models::IcebergErrorResponse),
51    Status502(models::IcebergErrorResponse),
52    Status504(models::IcebergErrorResponse),
53    Status5XX(models::IcebergErrorResponse),
54    UnknownValue(serde_json::Value),
55}
56
57/// struct for typed errors of method [`create_namespace`]
58#[derive(Debug, Clone, Serialize, Deserialize)]
59#[serde(untagged)]
60pub enum CreateNamespaceError {
61    Status400(models::IcebergErrorResponse),
62    Status401(models::IcebergErrorResponse),
63    Status403(models::IcebergErrorResponse),
64    Status406(models::ErrorModel),
65    Status409(models::IcebergErrorResponse),
66    Status419(models::IcebergErrorResponse),
67    Status503(models::IcebergErrorResponse),
68    Status5XX(models::IcebergErrorResponse),
69    UnknownValue(serde_json::Value),
70}
71
72/// struct for typed errors of method [`create_table`]
73#[derive(Debug, Clone, Serialize, Deserialize)]
74#[serde(untagged)]
75pub enum CreateTableError {
76    Status400(models::IcebergErrorResponse),
77    Status401(models::IcebergErrorResponse),
78    Status403(models::IcebergErrorResponse),
79    Status404(models::IcebergErrorResponse),
80    Status409(models::IcebergErrorResponse),
81    Status419(models::IcebergErrorResponse),
82    Status503(models::IcebergErrorResponse),
83    Status5XX(models::IcebergErrorResponse),
84    UnknownValue(serde_json::Value),
85}
86
87/// struct for typed errors of method [`create_view`]
88#[derive(Debug, Clone, Serialize, Deserialize)]
89#[serde(untagged)]
90pub enum CreateViewError {
91    Status400(models::IcebergErrorResponse),
92    Status401(models::IcebergErrorResponse),
93    Status403(models::IcebergErrorResponse),
94    Status404(models::ErrorModel),
95    Status409(models::ErrorModel),
96    Status419(models::IcebergErrorResponse),
97    Status503(models::IcebergErrorResponse),
98    Status5XX(models::IcebergErrorResponse),
99    UnknownValue(serde_json::Value),
100}
101
102/// struct for typed errors of method [`drop_namespace`]
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[serde(untagged)]
105pub enum DropNamespaceError {
106    Status400(models::IcebergErrorResponse),
107    Status401(models::IcebergErrorResponse),
108    Status403(models::IcebergErrorResponse),
109    Status404(models::IcebergErrorResponse),
110    Status419(models::IcebergErrorResponse),
111    Status503(models::IcebergErrorResponse),
112    Status5XX(models::IcebergErrorResponse),
113    UnknownValue(serde_json::Value),
114}
115
116/// struct for typed errors of method [`drop_table`]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(untagged)]
119pub enum DropTableError {
120    Status400(models::IcebergErrorResponse),
121    Status401(models::IcebergErrorResponse),
122    Status403(models::IcebergErrorResponse),
123    Status404(models::IcebergErrorResponse),
124    Status419(models::IcebergErrorResponse),
125    Status503(models::IcebergErrorResponse),
126    Status5XX(models::IcebergErrorResponse),
127    UnknownValue(serde_json::Value),
128}
129
130/// struct for typed errors of method [`drop_view`]
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(untagged)]
133pub enum DropViewError {
134    Status400(models::IcebergErrorResponse),
135    Status401(models::IcebergErrorResponse),
136    Status403(models::IcebergErrorResponse),
137    Status404(models::ErrorModel),
138    Status419(models::IcebergErrorResponse),
139    Status503(models::IcebergErrorResponse),
140    Status5XX(models::IcebergErrorResponse),
141    UnknownValue(serde_json::Value),
142}
143
144/// struct for typed errors of method [`fetch_planning_result`]
145#[derive(Debug, Clone, Serialize, Deserialize)]
146#[serde(untagged)]
147pub enum FetchPlanningResultError {
148    Status400(models::IcebergErrorResponse),
149    Status401(models::IcebergErrorResponse),
150    Status403(models::IcebergErrorResponse),
151    Status404(models::IcebergErrorResponse),
152    Status419(models::IcebergErrorResponse),
153    Status503(models::IcebergErrorResponse),
154    Status5XX(models::IcebergErrorResponse),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`fetch_scan_tasks`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum FetchScanTasksError {
162    Status400(models::IcebergErrorResponse),
163    Status401(models::IcebergErrorResponse),
164    Status403(models::IcebergErrorResponse),
165    Status404(models::IcebergErrorResponse),
166    Status419(models::IcebergErrorResponse),
167    Status503(models::IcebergErrorResponse),
168    Status5XX(models::IcebergErrorResponse),
169    UnknownValue(serde_json::Value),
170}
171
172/// struct for typed errors of method [`list_namespaces`]
173#[derive(Debug, Clone, Serialize, Deserialize)]
174#[serde(untagged)]
175pub enum ListNamespacesError {
176    Status400(models::IcebergErrorResponse),
177    Status401(models::IcebergErrorResponse),
178    Status403(models::IcebergErrorResponse),
179    Status404(models::IcebergErrorResponse),
180    Status419(models::IcebergErrorResponse),
181    Status503(models::IcebergErrorResponse),
182    Status5XX(models::IcebergErrorResponse),
183    UnknownValue(serde_json::Value),
184}
185
186/// struct for typed errors of method [`list_tables`]
187#[derive(Debug, Clone, Serialize, Deserialize)]
188#[serde(untagged)]
189pub enum ListTablesError {
190    Status400(models::IcebergErrorResponse),
191    Status401(models::IcebergErrorResponse),
192    Status403(models::IcebergErrorResponse),
193    Status404(models::IcebergErrorResponse),
194    Status419(models::IcebergErrorResponse),
195    Status503(models::IcebergErrorResponse),
196    Status5XX(models::IcebergErrorResponse),
197    UnknownValue(serde_json::Value),
198}
199
200/// struct for typed errors of method [`list_views`]
201#[derive(Debug, Clone, Serialize, Deserialize)]
202#[serde(untagged)]
203pub enum ListViewsError {
204    Status400(models::IcebergErrorResponse),
205    Status401(models::IcebergErrorResponse),
206    Status403(models::IcebergErrorResponse),
207    Status404(models::ErrorModel),
208    Status419(models::IcebergErrorResponse),
209    Status503(models::IcebergErrorResponse),
210    Status5XX(models::IcebergErrorResponse),
211    UnknownValue(serde_json::Value),
212}
213
214/// struct for typed errors of method [`load_credentials`]
215#[derive(Debug, Clone, Serialize, Deserialize)]
216#[serde(untagged)]
217pub enum LoadCredentialsError {
218    Status400(models::IcebergErrorResponse),
219    Status401(models::IcebergErrorResponse),
220    Status403(models::IcebergErrorResponse),
221    Status404(models::IcebergErrorResponse),
222    Status419(models::IcebergErrorResponse),
223    Status503(models::IcebergErrorResponse),
224    Status5XX(models::IcebergErrorResponse),
225    UnknownValue(serde_json::Value),
226}
227
228/// struct for typed errors of method [`load_namespace_metadata`]
229#[derive(Debug, Clone, Serialize, Deserialize)]
230#[serde(untagged)]
231pub enum LoadNamespaceMetadataError {
232    Status400(models::IcebergErrorResponse),
233    Status401(models::IcebergErrorResponse),
234    Status403(models::IcebergErrorResponse),
235    Status404(models::IcebergErrorResponse),
236    Status419(models::IcebergErrorResponse),
237    Status503(models::IcebergErrorResponse),
238    Status5XX(models::IcebergErrorResponse),
239    UnknownValue(serde_json::Value),
240}
241
242/// struct for typed errors of method [`load_table`]
243#[derive(Debug, Clone, Serialize, Deserialize)]
244#[serde(untagged)]
245pub enum LoadTableError {
246    Status400(models::IcebergErrorResponse),
247    Status401(models::IcebergErrorResponse),
248    Status403(models::IcebergErrorResponse),
249    Status404(models::IcebergErrorResponse),
250    Status419(models::IcebergErrorResponse),
251    Status503(models::IcebergErrorResponse),
252    Status5XX(models::IcebergErrorResponse),
253    UnknownValue(serde_json::Value),
254}
255
256/// struct for typed errors of method [`load_view`]
257#[derive(Debug, Clone, Serialize, Deserialize)]
258#[serde(untagged)]
259pub enum LoadViewError {
260    Status400(models::IcebergErrorResponse),
261    Status401(models::IcebergErrorResponse),
262    Status403(models::IcebergErrorResponse),
263    Status404(models::ErrorModel),
264    Status419(models::IcebergErrorResponse),
265    Status503(models::IcebergErrorResponse),
266    Status5XX(models::IcebergErrorResponse),
267    UnknownValue(serde_json::Value),
268}
269
270/// struct for typed errors of method [`namespace_exists`]
271#[derive(Debug, Clone, Serialize, Deserialize)]
272#[serde(untagged)]
273pub enum NamespaceExistsError {
274    Status400(models::IcebergErrorResponse),
275    Status401(models::IcebergErrorResponse),
276    Status403(models::IcebergErrorResponse),
277    Status404(models::IcebergErrorResponse),
278    Status419(models::IcebergErrorResponse),
279    Status503(models::IcebergErrorResponse),
280    Status5XX(models::IcebergErrorResponse),
281    UnknownValue(serde_json::Value),
282}
283
284/// struct for typed errors of method [`plan_table_scan`]
285#[derive(Debug, Clone, Serialize, Deserialize)]
286#[serde(untagged)]
287pub enum PlanTableScanError {
288    Status400(models::IcebergErrorResponse),
289    Status401(models::IcebergErrorResponse),
290    Status403(models::IcebergErrorResponse),
291    Status404(models::IcebergErrorResponse),
292    Status406(models::ErrorModel),
293    Status419(models::IcebergErrorResponse),
294    Status503(models::IcebergErrorResponse),
295    Status5XX(models::IcebergErrorResponse),
296    UnknownValue(serde_json::Value),
297}
298
299/// struct for typed errors of method [`register_table`]
300#[derive(Debug, Clone, Serialize, Deserialize)]
301#[serde(untagged)]
302pub enum RegisterTableError {
303    Status400(models::IcebergErrorResponse),
304    Status401(models::IcebergErrorResponse),
305    Status403(models::IcebergErrorResponse),
306    Status404(models::IcebergErrorResponse),
307    Status409(models::IcebergErrorResponse),
308    Status419(models::IcebergErrorResponse),
309    Status503(models::IcebergErrorResponse),
310    Status5XX(models::IcebergErrorResponse),
311    UnknownValue(serde_json::Value),
312}
313
314/// struct for typed errors of method [`rename_table`]
315#[derive(Debug, Clone, Serialize, Deserialize)]
316#[serde(untagged)]
317pub enum RenameTableError {
318    Status400(models::IcebergErrorResponse),
319    Status401(models::IcebergErrorResponse),
320    Status403(models::IcebergErrorResponse),
321    Status404(models::IcebergErrorResponse),
322    Status406(models::ErrorModel),
323    Status409(models::IcebergErrorResponse),
324    Status419(models::IcebergErrorResponse),
325    Status503(models::IcebergErrorResponse),
326    Status5XX(models::IcebergErrorResponse),
327    UnknownValue(serde_json::Value),
328}
329
330/// struct for typed errors of method [`rename_view`]
331#[derive(Debug, Clone, Serialize, Deserialize)]
332#[serde(untagged)]
333pub enum RenameViewError {
334    Status400(models::IcebergErrorResponse),
335    Status401(models::IcebergErrorResponse),
336    Status403(models::IcebergErrorResponse),
337    Status404(models::ErrorModel),
338    Status406(models::ErrorModel),
339    Status409(models::ErrorModel),
340    Status419(models::IcebergErrorResponse),
341    Status503(models::IcebergErrorResponse),
342    Status5XX(models::IcebergErrorResponse),
343    UnknownValue(serde_json::Value),
344}
345
346/// struct for typed errors of method [`replace_view`]
347#[derive(Debug, Clone, Serialize, Deserialize)]
348#[serde(untagged)]
349pub enum ReplaceViewError {
350    Status400(models::IcebergErrorResponse),
351    Status401(models::IcebergErrorResponse),
352    Status403(models::IcebergErrorResponse),
353    Status404(models::ErrorModel),
354    Status409(models::ErrorModel),
355    Status419(models::IcebergErrorResponse),
356    Status500(models::ErrorModel),
357    Status503(models::IcebergErrorResponse),
358    Status502(models::ErrorModel),
359    Status504(models::ErrorModel),
360    Status5XX(models::ErrorModel),
361    UnknownValue(serde_json::Value),
362}
363
364/// struct for typed errors of method [`report_metrics`]
365#[derive(Debug, Clone, Serialize, Deserialize)]
366#[serde(untagged)]
367pub enum ReportMetricsError {
368    Status400(models::IcebergErrorResponse),
369    Status401(models::IcebergErrorResponse),
370    Status403(models::IcebergErrorResponse),
371    Status404(models::IcebergErrorResponse),
372    Status419(models::IcebergErrorResponse),
373    Status503(models::IcebergErrorResponse),
374    Status5XX(models::IcebergErrorResponse),
375    UnknownValue(serde_json::Value),
376}
377
378/// struct for typed errors of method [`table_exists`]
379#[derive(Debug, Clone, Serialize, Deserialize)]
380#[serde(untagged)]
381pub enum TableExistsError {
382    Status400(models::IcebergErrorResponse),
383    Status401(models::IcebergErrorResponse),
384    Status403(models::IcebergErrorResponse),
385    Status404(models::IcebergErrorResponse),
386    Status419(models::IcebergErrorResponse),
387    Status503(models::IcebergErrorResponse),
388    Status5XX(models::IcebergErrorResponse),
389    UnknownValue(serde_json::Value),
390}
391
392/// struct for typed errors of method [`update_properties`]
393#[derive(Debug, Clone, Serialize, Deserialize)]
394#[serde(untagged)]
395pub enum UpdatePropertiesError {
396    Status400(models::IcebergErrorResponse),
397    Status401(models::IcebergErrorResponse),
398    Status403(models::IcebergErrorResponse),
399    Status404(models::IcebergErrorResponse),
400    Status406(models::ErrorModel),
401    Status422(models::IcebergErrorResponse),
402    Status419(models::IcebergErrorResponse),
403    Status503(models::IcebergErrorResponse),
404    Status5XX(models::IcebergErrorResponse),
405    UnknownValue(serde_json::Value),
406}
407
408/// struct for typed errors of method [`update_table`]
409#[derive(Debug, Clone, Serialize, Deserialize)]
410#[serde(untagged)]
411pub enum UpdateTableError {
412    Status400(models::IcebergErrorResponse),
413    Status401(models::IcebergErrorResponse),
414    Status403(models::IcebergErrorResponse),
415    Status404(models::IcebergErrorResponse),
416    Status409(models::IcebergErrorResponse),
417    Status419(models::IcebergErrorResponse),
418    Status500(models::IcebergErrorResponse),
419    Status503(models::IcebergErrorResponse),
420    Status502(models::IcebergErrorResponse),
421    Status504(models::IcebergErrorResponse),
422    Status5XX(models::IcebergErrorResponse),
423    UnknownValue(serde_json::Value),
424}
425
426/// struct for typed errors of method [`view_exists`]
427#[derive(Debug, Clone, Serialize, Deserialize)]
428#[serde(untagged)]
429pub enum ViewExistsError {
430    Status400(),
431    Status401(),
432    Status404(),
433    Status419(models::IcebergErrorResponse),
434    Status503(models::IcebergErrorResponse),
435    Status5XX(models::IcebergErrorResponse),
436    UnknownValue(serde_json::Value),
437}
438
439pub async fn commit_transaction(
440    configuration: &configuration::Configuration,
441    prefix: Option<&str>,
442    commit_transaction_request: models::CommitTransactionRequest,
443) -> Result<(), Error<CommitTransactionError>> {
444    let uri_str = "transactions/commit".to_string();
445    let method = reqwest::Method::POST;
446
447    fetch::fetch_empty(
448        configuration,
449        method,
450        prefix,
451        &uri_str,
452        &commit_transaction_request,
453        None,
454        None,
455    )
456    .await
457}
458
459/// Create a namespace, with an optional set of properties. The server might also add properties, such as `last_modified_time` etc.
460pub async fn create_namespace(
461    configuration: &configuration::Configuration,
462    prefix: Option<&str>,
463    create_namespace_request: models::CreateNamespaceRequest,
464) -> Result<models::CreateNamespaceResponse, Error<CreateNamespaceError>> {
465    let uri_str = "namespaces".to_string();
466    let method = reqwest::Method::POST;
467
468    fetch::fetch(
469        configuration,
470        method,
471        prefix,
472        &uri_str,
473        &create_namespace_request,
474        None,
475        None,
476    )
477    .await
478}
479
480/// Create a table or start a create transaction, like atomic CTAS.  If `stage-create` is false, the table is created immediately.  If `stage-create` is true, the table is not created, but table metadata is initialized and returned. The service should prepare as needed for a commit to the table commit endpoint to complete the create transaction. The client uses the returned metadata to begin a transaction. To commit the transaction, the client sends all create and subsequent changes to the table commit route. Changes from the table create operation include changes like AddSchemaUpdate and SetCurrentSchemaUpdate that set the initial table state.
481pub async fn create_table(
482    configuration: &configuration::Configuration,
483    prefix: Option<&str>,
484    namespace: &str,
485    create_table_request: CreateTable,
486    x_iceberg_access_delegation: Option<&str>,
487) -> Result<models::LoadTableResult, Error<CreateTableError>> {
488    let mut headers = HashMap::new();
489    if let Some(param_value) = x_iceberg_access_delegation {
490        headers.insert(
491            "X-Iceberg-Access-Delegation".to_owned(),
492            param_value.to_string(),
493        );
494    }
495
496    let uri_str = format!(
497        "namespaces/{namespace}/tables",
498        namespace = crate::apis::urlencode(namespace)
499    );
500    let method = reqwest::Method::POST;
501
502    fetch::fetch(
503        configuration,
504        method,
505        prefix,
506        &uri_str,
507        &create_table_request,
508        Some(headers),
509        None,
510    )
511    .await
512}
513
514/// Create a view in the given namespace.
515pub async fn create_view<T: Materialization + serde::Serialize>(
516    configuration: &configuration::Configuration,
517    prefix: Option<&str>,
518    namespace: &str,
519    create_view_request: CreateView<T>,
520) -> Result<models::LoadViewResult, Error<CreateViewError>> {
521    let uri_str = format!(
522        "namespaces/{namespace}/views",
523        namespace = crate::apis::urlencode(namespace)
524    );
525    let method = reqwest::Method::POST;
526
527    fetch::fetch(
528        configuration,
529        method,
530        prefix,
531        &uri_str,
532        &create_view_request,
533        None,
534        None,
535    )
536    .await
537}
538
539pub async fn drop_namespace(
540    configuration: &configuration::Configuration,
541    prefix: Option<&str>,
542    namespace: &str,
543) -> Result<(), Error<DropNamespaceError>> {
544    let uri_str = format!(
545        "namespaces/{namespace}",
546        namespace = crate::apis::urlencode(namespace)
547    );
548
549    let method = reqwest::Method::DELETE;
550
551    fetch::fetch_empty(configuration, method, prefix, &uri_str, &(), None, None).await
552}
553
554/// Remove a table from the catalog
555pub async fn drop_table(
556    configuration: &configuration::Configuration,
557    prefix: Option<&str>,
558    namespace: &str,
559    table: &str,
560    purge_requested: Option<bool>,
561) -> Result<(), Error<DropTableError>> {
562    let mut query_params = HashMap::new();
563    if let Some(purge_requested) = purge_requested {
564        query_params.insert("purgeRequested".to_owned(), purge_requested.to_string());
565    }
566
567    let uri_str = format!(
568        "namespaces/{namespace}/tables/{table}",
569        namespace = crate::apis::urlencode(namespace),
570        table = crate::apis::urlencode(table)
571    );
572    let method = reqwest::Method::DELETE;
573
574    fetch::fetch_empty(
575        configuration,
576        method,
577        prefix,
578        &uri_str,
579        &(),
580        None,
581        Some(query_params),
582    )
583    .await
584}
585
586/// Remove a view from the catalog
587pub async fn drop_view(
588    configuration: &configuration::Configuration,
589    prefix: Option<&str>,
590    namespace: &str,
591    view: &str,
592) -> Result<(), Error<DropViewError>> {
593    let uri_str = format!(
594        "namespaces/{namespace}/views/{view}",
595        namespace = crate::apis::urlencode(namespace),
596        view = crate::apis::urlencode(view)
597    );
598    let method = reqwest::Method::DELETE;
599
600    fetch::fetch_empty(configuration, method, prefix, &uri_str, &(), None, None).await
601}
602
603/// List all namespaces at a certain level, optionally starting from a given parent namespace. If table accounting.tax.paid.info exists, using 'SELECT NAMESPACE IN accounting' would translate into `GET /namespaces?parent=accounting` and must return a namespace, [\"accounting\", \"tax\"] only. Using 'SELECT NAMESPACE IN accounting.tax' would translate into `GET /namespaces?parent=accounting%1Ftax` and must return a namespace, [\"accounting\", \"tax\", \"paid\"]. If `parent` is not provided, all top-level namespaces should be listed.
604pub async fn list_namespaces(
605    configuration: &configuration::Configuration,
606    prefix: Option<&str>,
607    page_token: Option<&str>,
608    page_size: Option<i32>,
609    parent: Option<&str>,
610) -> Result<models::ListNamespacesResponse, Error<ListNamespacesError>> {
611    let mut query_params = HashMap::new();
612    if let Some(page_token) = page_token {
613        query_params.insert("pageToken".to_owned(), page_token.to_string());
614    }
615    if let Some(page_size) = page_size {
616        query_params.insert("pageSize".to_owned(), page_size.to_string());
617    }
618    if let Some(parent) = parent {
619        query_params.insert("parent".to_owned(), parent.to_string());
620    }
621
622    let uri_str = "namespaces".to_string();
623
624    let method = reqwest::Method::GET;
625
626    fetch::fetch(
627        configuration,
628        method,
629        prefix,
630        &uri_str,
631        &(),
632        None,
633        Some(query_params),
634    )
635    .await
636}
637
638/// Return all table identifiers under this namespace
639pub async fn list_tables(
640    configuration: &configuration::Configuration,
641    prefix: Option<&str>,
642    namespace: &str,
643    page_token: Option<&str>,
644    page_size: Option<i32>,
645) -> Result<models::ListTablesResponse, Error<ListTablesError>> {
646    let mut query_params = HashMap::new();
647    if let Some(page_token) = page_token {
648        query_params.insert("pageToken".to_owned(), page_token.to_string());
649    }
650    if let Some(page_size) = page_size {
651        query_params.insert("pageSize".to_owned(), page_size.to_string());
652    }
653
654    let uri_str = format!(
655        "namespaces/{namespace}/tables",
656        namespace = crate::apis::urlencode(namespace)
657    );
658    let method = reqwest::Method::GET;
659
660    fetch::fetch(
661        configuration,
662        method,
663        prefix,
664        &uri_str,
665        &(),
666        None,
667        Some(query_params),
668    )
669    .await
670}
671
672/// Return all view identifiers under this namespace
673pub async fn list_views(
674    configuration: &configuration::Configuration,
675    prefix: Option<&str>,
676    namespace: &str,
677    page_token: Option<&str>,
678    page_size: Option<i32>,
679) -> Result<models::ListTablesResponse, Error<ListViewsError>> {
680    let mut query_params = HashMap::new();
681    if let Some(page_token) = page_token {
682        query_params.insert("pageToken".to_owned(), page_token.to_string());
683    }
684    if let Some(page_size) = page_size {
685        query_params.insert("pageSize".to_owned(), page_size.to_string());
686    }
687
688    let uri_str = format!(
689        "namespaces/{namespace}/views",
690        namespace = crate::apis::urlencode(namespace)
691    );
692    let method = reqwest::Method::GET;
693
694    fetch::fetch(
695        configuration,
696        method,
697        prefix,
698        &uri_str,
699        &(),
700        None,
701        Some(query_params),
702    )
703    .await
704}
705/// Load vended credentials for a table from the catalog.
706pub async fn load_credentials(
707    configuration: &configuration::Configuration,
708    prefix: &str,
709    namespace: &str,
710    table: &str,
711) -> Result<models::LoadCredentialsResponse, Error<LoadCredentialsError>> {
712    // add a prefix to parameters to efficiently prevent name collisions
713    let p_prefix = prefix;
714    let p_namespace = namespace;
715    let p_table = table;
716
717    let uri_str = format!(
718        "{}/v1/{prefix}/namespaces/{namespace}/tables/{table}/credentials",
719        configuration.base_path,
720        prefix = crate::apis::urlencode(p_prefix),
721        namespace = crate::apis::urlencode(p_namespace),
722        table = crate::apis::urlencode(p_table)
723    );
724    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
725
726    if let Some(ref aws_v4_key) = configuration.aws_v4_key {
727        let new_headers = match aws_v4_key.sign(&uri_str, "GET", "") {
728            Ok(new_headers) => new_headers,
729            Err(err) => return Err(Error::AWSV4SignatureError(err)),
730        };
731        for (name, value) in new_headers.iter() {
732            req_builder = req_builder.header(name.as_str(), value.as_str());
733        }
734    }
735    if let Some(ref user_agent) = configuration.user_agent {
736        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
737    }
738    if let Some(ref token) = configuration.oauth_access_token {
739        req_builder = req_builder.bearer_auth(token.to_owned());
740    };
741    if let Some(ref token) = configuration.bearer_access_token {
742        req_builder = req_builder.bearer_auth(token.to_owned());
743    };
744
745    let req = req_builder.build()?;
746    let resp = configuration.client.execute(req).await?;
747
748    let status = resp.status();
749
750    if !status.is_client_error() && !status.is_server_error() {
751        let content = resp.text().await?;
752        serde_json::from_str(&content).map_err(Error::from)
753    } else {
754        let content = resp.text().await?;
755        let entity: Option<LoadCredentialsError> = serde_json::from_str(&content).ok();
756        Err(Error::ResponseError(ResponseContent {
757            status,
758            content,
759            entity,
760        }))
761    }
762}
763
764/// Return all stored metadata properties for a given namespace
765pub async fn load_namespace_metadata(
766    configuration: &configuration::Configuration,
767    prefix: Option<&str>,
768    namespace: &str,
769) -> Result<models::GetNamespaceResponse, Error<LoadNamespaceMetadataError>> {
770    let uri_str = format!(
771        "namespaces/{namespace}",
772        namespace = crate::apis::urlencode(namespace)
773    );
774    let method = reqwest::Method::GET;
775
776    fetch::fetch(configuration, method, prefix, &uri_str, &(), None, None).await
777}
778
779/// Load a table from the catalog.  The response contains both configuration and table metadata. The configuration, if non-empty is used as additional configuration for the table that overrides catalog configuration. For example, this configuration may change the FileIO implementation to be used for the table.  The response also contains the table's full metadata, matching the table metadata JSON file.  The catalog configuration may contain credentials that should be used for subsequent requests for the table. The configuration key \"token\" is used to pass an access token to be used as a bearer token for table requests. Otherwise, a token may be passed using a RFC 8693 token type as a configuration key. For example, \"urn:ietf:params:oauth:token-type:jwt=<JWT-token>\".
780pub async fn load_table(
781    configuration: &configuration::Configuration,
782    prefix: Option<&str>,
783    namespace: &str,
784    table: &str,
785    x_iceberg_access_delegation: Option<&str>,
786    snapshots: Option<&str>,
787) -> Result<models::LoadTableResult, Error<LoadTableError>> {
788    let mut headers = HashMap::new();
789    if let Some(param_value) = x_iceberg_access_delegation {
790        headers.insert(
791            "X-Iceberg-Access-Delegation".to_owned(),
792            param_value.to_string(),
793        );
794    }
795    let mut query_params = HashMap::new();
796    if let Some(snapshots) = snapshots {
797        query_params.insert("snapshots".to_owned(), snapshots.to_string());
798    }
799
800    let uri_str = format!(
801        "namespaces/{namespace}/tables/{table}",
802        namespace = crate::apis::urlencode(namespace),
803        table = crate::apis::urlencode(table)
804    );
805    let method = reqwest::Method::GET;
806
807    fetch::fetch(
808        configuration,
809        method,
810        prefix,
811        &uri_str,
812        &(),
813        Some(headers),
814        Some(query_params),
815    )
816    .await
817}
818
819/// Load a view from the catalog.  The response contains both configuration and view metadata. The configuration, if non-empty is used as additional configuration for the view that overrides catalog configuration.  The response also contains the view's full metadata, matching the view metadata JSON file.  The catalog configuration may contain credentials that should be used for subsequent requests for the view. The configuration key \"token\" is used to pass an access token to be used as a bearer token for view requests. Otherwise, a token may be passed using a RFC 8693 token type as a configuration key. For example, \"urn:ietf:params:oauth:token-type:jwt=<JWT-token>\".
820pub async fn load_view(
821    configuration: &configuration::Configuration,
822    prefix: Option<&str>,
823    namespace: &str,
824    view: &str,
825) -> Result<models::LoadViewResult, Error<LoadViewError>> {
826    let uri_str = format!(
827        "namespaces/{namespace}/views/{view}",
828        namespace = crate::apis::urlencode(namespace),
829        view = crate::apis::urlencode(view)
830    );
831    let method = reqwest::Method::GET;
832
833    fetch::fetch(configuration, method, prefix, &uri_str, &(), None, None).await
834}
835
836/// Check if a namespace exists. The response does not contain a body.
837pub async fn namespace_exists(
838    configuration: &configuration::Configuration,
839    prefix: Option<&str>,
840    namespace: &str,
841) -> Result<(), Error<NamespaceExistsError>> {
842    let uri_str = format!(
843        "namespaces/{namespace}",
844        namespace = crate::apis::urlencode(namespace)
845    );
846
847    let method = reqwest::Method::HEAD;
848
849    fetch::fetch_empty(configuration, method, prefix, &uri_str, &(), None, None).await
850}
851
852/// Register a table using given metadata file location.
853pub async fn register_table(
854    configuration: &configuration::Configuration,
855    prefix: Option<&str>,
856    namespace: &str,
857    register_table_request: models::RegisterTableRequest,
858) -> Result<models::LoadTableResult, Error<RegisterTableError>> {
859    let uri_str = format!(
860        "namespaces/{namespace}/register",
861        namespace = crate::apis::urlencode(namespace)
862    );
863
864    let method = reqwest::Method::POST;
865
866    fetch::fetch(
867        configuration,
868        method,
869        prefix,
870        &uri_str,
871        &register_table_request,
872        None,
873        None,
874    )
875    .await
876}
877
878/// Rename a table from one identifier to another. It's valid to move a table across namespaces, but the server implementation is not required to support it.
879pub async fn rename_table(
880    configuration: &configuration::Configuration,
881    prefix: Option<&str>,
882    rename_table_request: models::RenameTableRequest,
883) -> Result<(), Error<RenameTableError>> {
884    let uri_str = "tables/rename".to_string();
885    let method = reqwest::Method::POST;
886
887    fetch::fetch_empty(
888        configuration,
889        method,
890        prefix,
891        &uri_str,
892        &rename_table_request,
893        None,
894        None,
895    )
896    .await
897}
898
899/// Rename a view from one identifier to another. It's valid to move a view across namespaces, but the server implementation is not required to support it.
900pub async fn rename_view(
901    configuration: &configuration::Configuration,
902    prefix: Option<&str>,
903    rename_table_request: models::RenameTableRequest,
904) -> Result<(), Error<RenameViewError>> {
905    let uri_str = "views/rename".to_string();
906    let method = reqwest::Method::POST;
907
908    fetch::fetch_empty(
909        configuration,
910        method,
911        prefix,
912        &uri_str,
913        &rename_table_request,
914        None,
915        None,
916    )
917    .await
918}
919
920/// Commit updates to a view.
921pub async fn replace_view<T: Materialization + serde::Serialize>(
922    configuration: &configuration::Configuration,
923    prefix: Option<&str>,
924    namespace: &str,
925    view: &str,
926    commit_view_request: CommitView<T>,
927) -> Result<models::LoadViewResult, Error<ReplaceViewError>> {
928    let uri_str = format!(
929        "namespaces/{namespace}/views/{view}",
930        namespace = crate::apis::urlencode(namespace),
931        view = crate::apis::urlencode(view)
932    );
933    let method = reqwest::Method::POST;
934
935    fetch::fetch(
936        configuration,
937        method,
938        prefix,
939        &uri_str,
940        &commit_view_request,
941        None,
942        None,
943    )
944    .await
945}
946
947pub async fn report_metrics(
948    configuration: &configuration::Configuration,
949    prefix: Option<&str>,
950    namespace: &str,
951    table: &str,
952    report_metrics_request: models::ReportMetricsRequest,
953) -> Result<(), Error<ReportMetricsError>> {
954    let uri_str = format!(
955        "namespaces/{namespace}/tables/{table}/metrics",
956        namespace = crate::apis::urlencode(namespace),
957        table = crate::apis::urlencode(table)
958    );
959    let method = reqwest::Method::POST;
960
961    fetch::fetch_empty(
962        configuration,
963        method,
964        prefix,
965        &uri_str,
966        &report_metrics_request,
967        None,
968        None,
969    )
970    .await
971}
972
973/// Check if a table exists within a given namespace. The response does not contain a body.
974pub async fn table_exists(
975    configuration: &configuration::Configuration,
976    prefix: Option<&str>,
977    namespace: &str,
978    table: &str,
979) -> Result<(), Error<TableExistsError>> {
980    let uri_str = format!(
981        "namespaces/{namespace}/tables/{table}",
982        namespace = crate::apis::urlencode(namespace),
983        table = crate::apis::urlencode(table)
984    );
985
986    let method = reqwest::Method::HEAD;
987
988    fetch::fetch_empty(configuration, method, prefix, &uri_str, &(), None, None).await
989}
990
991/// Set and/or remove properties on a namespace. The request body specifies a list of properties to remove and a map of key value pairs to update. Properties that are not in the request are not modified or removed by this call. Server implementations are not required to support namespace properties.
992pub async fn update_properties(
993    configuration: &configuration::Configuration,
994    prefix: Option<&str>,
995    namespace: &str,
996    update_namespace_properties_request: models::UpdateNamespacePropertiesRequest,
997) -> Result<models::UpdateNamespacePropertiesResponse, Error<UpdatePropertiesError>> {
998    let uri_str = format!(
999        "namespaces/{namespace}/properties",
1000        namespace = crate::apis::urlencode(namespace)
1001    );
1002    let method = reqwest::Method::POST;
1003
1004    fetch::fetch(
1005        configuration,
1006        method,
1007        prefix,
1008        &uri_str,
1009        &update_namespace_properties_request,
1010        None,
1011        None,
1012    )
1013    .await
1014}
1015
1016/// Commit updates to a table.  Commits have two parts, requirements and updates. Requirements are assertions that will be validated before attempting to make and commit changes. For example, `assert-ref-snapshot-id` will check that a named ref's snapshot ID has a certain value.  Updates are changes to make to table metadata. For example, after asserting that the current main ref is at the expected snapshot, a commit may add a new child snapshot and set the ref to the new snapshot id.  Create table transactions that are started by createTable with `stage-create` set to true are committed using this route. Transactions should include all changes to the table, including table initialization, like AddSchemaUpdate and SetCurrentSchemaUpdate. The `assert-create` requirement is used to ensure that the table was not created concurrently.
1017pub async fn update_table(
1018    configuration: &configuration::Configuration,
1019    prefix: Option<&str>,
1020    namespace: &str,
1021    table: &str,
1022    commit_table_request: CommitTable,
1023) -> Result<models::CommitTableResponse, Error<UpdateTableError>> {
1024    let uri_str = format!(
1025        "namespaces/{namespace}/tables/{table}",
1026        namespace = crate::apis::urlencode(namespace),
1027        table = crate::apis::urlencode(table)
1028    );
1029    let method = reqwest::Method::POST;
1030
1031    fetch::fetch(
1032        configuration,
1033        method,
1034        prefix,
1035        &uri_str,
1036        &commit_table_request,
1037        None,
1038        None,
1039    )
1040    .await
1041}
1042
1043/// Check if a view exists within a given namespace. This request does not return a response body.
1044pub async fn view_exists(
1045    configuration: &configuration::Configuration,
1046    prefix: Option<&str>,
1047    namespace: &str,
1048    view: &str,
1049) -> Result<(), Error<ViewExistsError>> {
1050    let uri_str = format!(
1051        "namespaces/{namespace}/views/{view}",
1052        namespace = crate::apis::urlencode(namespace),
1053        view = crate::apis::urlencode(view)
1054    );
1055
1056    let method = reqwest::Method::HEAD;
1057
1058    fetch::fetch_empty(configuration, method, prefix, &uri_str, &(), None, None).await
1059}