connortsui20 commented on code in PR #965: URL: https://github.com/apache/iceberg-rust/pull/965#discussion_r1957521755
########## crates/catalog/rest/src/catalog.rs: ########## @@ -312,90 +317,107 @@ impl RestCatalog { } } +/// All requests and expected responses are derived from the REST catalog API spec: +/// https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml #[async_trait] impl Catalog for RestCatalog { - /// List namespaces from table. async fn list_namespaces( &self, parent: Option<&NamespaceIdent>, ) -> Result<Vec<NamespaceIdent>> { - let mut request = self.context().await?.client.request( - Method::GET, - self.context().await?.config.namespaces_endpoint(), - ); - if let Some(ns) = parent { - request = request.query(&[("parent", ns.to_url_string())]); - } + let context = self.context().await?; - let resp = self - .context() - .await? + let mut request_builder = context .client - .query::<ListNamespaceResponse, ErrorResponse>(request.build()?) - .await?; + .request(Method::GET, context.config.namespaces_endpoint()); + // Filter on `parent={namespace}` if a parent namespace exists. + if let Some(namespace) = parent { + request_builder = request_builder.query(&[("parent", namespace.to_url_string())]); + } + let request = request_builder.build()?; + + let handler = |response: Response| async move { + match response.status() { + StatusCode::OK => { + Ok(deserialize_catalog_response::<ListNamespaceResponse>(response).await?) + } + StatusCode::NOT_FOUND => Err(Error::new( + ErrorKind::Unexpected, Review Comment: I think that if we want an error case for `NamespaceNotExists` there should also be error cases for every other type of failure (for creates, updates, deletes, plus the same for tables) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org