This is an automated email from the ASF dual-hosted git repository.

emaynard pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new 1426a0dd Add support for the loadCredentials endpoint (#1107)
1426a0dd is described below

commit 1426a0ddde3791b511b7dbde1f4da925e8dad22c
Author: Eric Maynard <[email protected]>
AuthorDate: Tue Mar 4 18:54:49 2025 -0800

    Add support for the loadCredentials endpoint (#1107)
    
    * initial commit
    
    * autolint
    
    * Add test
    
    * test fix
    
    * style
    
    * fix
    
    * autolint
    
    * remove an unneccesary check
    
    * s/ALL/all/g
    
    * autolint
    
    * s/ALL/all/g
---
 .../it/test/PolarisRestCatalogIntegrationTest.java  | 19 +++++++++++++++++++
 .../service/catalog/IcebergCatalogAdapter.java      | 21 +++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java
 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java
index 505465d1..2a31f2f1 100644
--- 
a/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java
+++ 
b/integration-tests/src/main/java/org/apache/polaris/service/it/test/PolarisRestCatalogIntegrationTest.java
@@ -1012,4 +1012,23 @@ public class PolarisRestCatalogIntegrationTest extends 
CatalogTests<RESTCatalog>
       assertThat(response).returns(Response.Status.NO_CONTENT.getStatusCode(), 
Response::getStatus);
     }
   }
+
+  @Test
+  public void testLoadCredentials() {
+    String tableName = "tbl1";
+    Namespace namespace = Namespace.of("ns1");
+    TableIdentifier identifier = TableIdentifier.of(namespace, tableName);
+
+    catalog().createNamespace(namespace);
+    catalog().buildTable(identifier, SCHEMA).create();
+
+    try (Response response =
+        catalogApi
+            .request(
+                "v1/{cat}/namespaces/{ns}/tables/{table}/credentials",
+                Map.of("cat", currentCatalogName, "ns", namespace.toString(), 
"table", tableName))
+            .head()) {
+      assertThat(response).returns(Response.Status.OK.getStatusCode(), 
Response::getStatus);
+    }
+  }
 }
diff --git 
a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java
 
b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java
index f2ba62ad..968d9c5f 100644
--- 
a/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java
+++ 
b/service/common/src/main/java/org/apache/polaris/service/catalog/IcebergCatalogAdapter.java
@@ -53,6 +53,8 @@ import org.apache.iceberg.rest.requests.RenameTableRequest;
 import org.apache.iceberg.rest.requests.ReportMetricsRequest;
 import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest;
 import org.apache.iceberg.rest.responses.ConfigResponse;
+import org.apache.iceberg.rest.responses.ImmutableLoadCredentialsResponse;
+import org.apache.iceberg.rest.responses.LoadTableResponse;
 import org.apache.polaris.core.PolarisConfigurationStore;
 import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
@@ -459,6 +461,25 @@ public class IcebergCatalogAdapter
         .build();
   }
 
+  @Override
+  public Response loadCredentials(
+      String prefix,
+      String namespace,
+      String table,
+      RealmContext realmContext,
+      SecurityContext securityContext) {
+    Namespace ns = decodeNamespace(namespace);
+    TableIdentifier tableIdentifier = TableIdentifier.of(ns, 
RESTUtil.decodeString(table));
+    LoadTableResponse loadTableResponse =
+        newHandlerWrapper(realmContext, securityContext, prefix)
+            .loadTableWithAccessDelegation(tableIdentifier, "all");
+    return Response.ok(
+            ImmutableLoadCredentialsResponse.builder()
+                .credentials(loadTableResponse.credentials())
+                .build())
+        .build();
+  }
+
   @Override
   public Response loadView(
       String prefix,

Reply via email to