Skip to content

Commit 3e08c90

Browse files
authored
[OpenAPI Modification] Return created objects (apache#2603)
As per the ML thread [here](https://lists.apache.org/thread/q7q0rrsmw5gcqv30g4hr9ffq3gtr72yk), this PR introduces the change to return all objects that are created within their respective API calls.
1 parent 5ca3fdc commit 3e08c90

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ request adding CHANGELOG notes for breaking (!) changes and possibly other secti
4242

4343
### Changes
4444

45+
* The following APIs will now return the newly-created objects as part of the successful 201 response: createCatalog, createPrincipalRole, createCatalogRole.
46+
4547
### Deprecations
4648

4749
* The property `polaris.active-roles-provider.type` is deprecated and has no effect anymore.

regtests/t_catalog_federation/src/catalog_federation.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ NEW_CLIENT_SECRET=$(echo "$PRINCIPAL_RESPONSE" | jq -r '.credentials.clientSecre
4343

4444
# Step 2: Create local catalog
4545
echo "Creating local catalog..."
46-
RESPONSE_CODE=$(curl -s -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" -H 'Content-Type: application/json' \
46+
RESPONSE_CODE=$(curl -s -o /dev/null -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" -H 'Content-Type: application/json' \
4747
http://${POLARIS_HOST:-localhost}:8181/api/management/v1/catalogs \
4848
-d '{
4949
"type": "INTERNAL",
@@ -87,7 +87,7 @@ echo "Assign service_admin to new-user response code: $RESPONSE_CODE"
8787

8888
# Step 4: Create external catalog
8989
echo "Creating external catalog (passthrough facade)..."
90-
RESPONSE_CODE=$(curl -s -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" -H 'Content-Type: application/json' \
90+
RESPONSE_CODE=$(curl -s -o /dev/null -X POST -H "Authorization: Bearer ${SPARK_BEARER_TOKEN}" -H 'Content-Type: application/json' \
9191
http://${POLARIS_HOST:-localhost}:8181/api/management/v1/catalogs \
9292
-d "{
9393
\"type\": \"EXTERNAL\",

runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisServiceImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public Response createCatalog(
126126
validateExternalCatalog(catalog);
127127
Catalog newCatalog = CatalogEntity.of(adminService.createCatalog(request)).asCatalog();
128128
LOGGER.info("Created new catalog {}", newCatalog);
129-
return Response.status(Response.Status.CREATED).build();
129+
return Response.status(Response.Status.CREATED).entity(newCatalog).build();
130130
}
131131

132132
private void validateClientId(String clientId) {
@@ -338,7 +338,7 @@ public Response createPrincipalRole(
338338
PrincipalRole newPrincipalRole =
339339
new PrincipalRoleEntity(adminService.createPrincipalRole(entity)).asPrincipalRole();
340340
LOGGER.info("Created new principalRole {}", newPrincipalRole);
341-
return Response.status(Response.Status.CREATED).build();
341+
return Response.status(Response.Status.CREATED).entity(newPrincipalRole).build();
342342
}
343343

344344
/** From PolarisPrincipalRolesApiService */
@@ -394,7 +394,7 @@ public Response createCatalogRole(
394394
CatalogRole newCatalogRole =
395395
new CatalogRoleEntity(adminService.createCatalogRole(catalogName, entity)).asCatalogRole();
396396
LOGGER.info("Created new catalogRole {}", newCatalogRole);
397-
return Response.status(Response.Status.CREATED).build();
397+
return Response.status(Response.Status.CREATED).entity(newCatalogRole).build();
398398
}
399399

400400
/** From PolarisCatalogsApiService */

spec/polaris-management-service.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ paths:
6363
responses:
6464
201:
6565
description: "Successful response"
66+
content:
67+
application/json:
68+
schema:
69+
$ref: "#/components/schemas/Catalog"
6670
403:
6771
description: "The caller does not have permission to create a catalog"
6872
404:
@@ -400,6 +404,10 @@ paths:
400404
responses:
401405
201:
402406
description: "Successful response"
407+
content:
408+
application/json:
409+
schema:
410+
$ref: "#/components/schemas/PrincipalRole"
403411
403:
404412
description: "The caller does not have permission to add a principal role"
405413

@@ -613,6 +621,10 @@ paths:
613621
responses:
614622
201:
615623
description: "Successful response"
624+
content:
625+
application/json:
626+
schema:
627+
$ref: "#/components/schemas/CatalogRole"
616628
403:
617629
description: "The principal is not authorized to create roles"
618630
404:

0 commit comments

Comments
 (0)