Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#6860] docs: add OpenAPI docs for fileset/files (#7334)

Yunchi Pang45b6609cc1e2
diff --git a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java
index 0f7c8889ab..dd17969482 100644
--- a/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java
+++ b/catalogs/catalog-hadoop/src/test/java/org/apache/gravitino/catalog/hadoop/integration/test/HadoopCatalogIT.java
@@ -196,10 +196,10 @@ public class HadoopCatalogIT extends BaseIT {
}
if (!StringUtils.isBlank(subPath)) {
- uriBuilder.addParameter("subPath", subPath);
+ uriBuilder.addParameter("sub_path", subPath);
}
if (!StringUtils.isBlank(locationName)) {
- uriBuilder.addParameter("locationName", locationName);
+ uriBuilder.addParameter("location_name", locationName);
}
HttpGet httpGet;
diff --git a/docs/open-api/filesets.yaml b/docs/open-api/filesets.yaml
index db5c5b190d..8a3915c4f3 100644
--- a/docs/open-api/filesets.yaml
+++ b/docs/open-api/filesets.yaml
@@ -205,6 +205,55 @@ paths:
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/filesets/{fileset}/files:
+ parameters:
+ - $ref: "./openapi.yaml#/components/parameters/metalake"
+ - $ref: "./openapi.yaml#/components/parameters/catalog"
+ - $ref: "./openapi.yaml#/components/parameters/schema"
+ - $ref: "./openapi.yaml#/components/parameters/fileset"
+
+ get:
+ tags:
+ - fileset
+ summary: List files
+ operationId: listFilesetFiles
+ description: List metadata of files and directories in a fileset
+ parameters:
+ - name: sub_path
+ in: query
+ required: false
+ schema:
+ type: string
+ default: "/"
+ description: The sub path within the fileset to list files and directories from
+ - name: location_name
+ in: query
+ required: false
+ schema:
+ type: string
+ default: null
+ description: The name of the storage location
+ responses:
+ "200":
+ $ref: "#/components/responses/FileInfoListResponse"
+ "404":
+ description: Not Found – the target fileset or subPath or locationName does not exist
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "./openapi.yaml#/components/schemas/ErrorModel"
+ examples:
+ NoSuchMetalakeException:
+ $ref: "./metalakes.yaml#/components/examples/NoSuchMetalakeException"
+ NoSuchCatalogException:
+ $ref: "./catalogs.yaml#/components/examples/NoSuchCatalogException"
+ NoSuchSchemaException:
+ $ref: "./schemas.yaml#/components/examples/NoSuchSchemaException"
+ NoSuchFilesetException:
+ $ref: "#/components/examples/NoSuchFilesetException"
+ "5xx":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
components:
schemas:
@@ -235,6 +284,33 @@ components:
default: {}
additionalProperties:
type: string
+ FileInfo:
+ type: object
+ required:
+ - name
+ - isDir
+ - size
+ - lastModified
+ - path
+ properties:
+ name:
+ type: string
+ description: The name of the file/directory
+ isDir:
+ type: boolean
+ description: Whether this is a directory
+ size:
+ type: integer
+ format: int64
+ description: The file size in bytes (0 if directory)
+ lastModified:
+ type: integer
+ format: int64
+ description: The last modification time of the file/directory
+ path:
+ type: string
+ description: The gvfs path of the file/directory
+
FilesetCreateRequest:
type: object
required:
@@ -411,6 +487,26 @@ components:
FilesetResponse:
$ref: "#/components/examples/FilesetResponse"
+ FileInfoListResponse:
+ description: The response containing a list of file/directory metadata
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ description: Status code of the response
+ enum: [0]
+ files:
+ type: array
+ items:
+ $ref: "#/components/schemas/FileInfo"
+ examples:
+ FileInfoListResponse:
+ $ref: "#/components/examples/FileInfoListResponse"
+
FileLocationResponse:
description: The response of the file location object
content:
@@ -459,6 +555,27 @@ components:
}
}
+ FileInfoListResponse:
+ value: {
+ "code": 0,
+ "files": [
+ {
+ "name": "file.txt",
+ "isDir": false,
+ "size": 5,
+ "lastModified": 1748875070123,
+ "path": "/fileset/catalog1/schema1/fileset1/file.txt"
+ },
+ {
+ "name": "sub_dir",
+ "isDir": true,
+ "size": 0,
+ "lastModified": 1748875070124,
+ "path": "/fileset/catalog1/schema1/fileset1/sub_dir"
+ }
+ ]
+ }
+
FileLocationResponse:
value: {
"code": 0,
diff --git a/docs/open-api/openapi.yaml b/docs/open-api/openapi.yaml
index 7ded1b6778..602cf45eef 100644
--- a/docs/open-api/openapi.yaml
+++ b/docs/open-api/openapi.yaml
@@ -110,6 +110,9 @@ paths:
/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/filesets/{fileset}:
$ref: "./filesets.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1filesets~1%7Bfileset%7D"
+ /metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/filesets/{fileset}/files:
+ $ref: "./filesets.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1filesets~1%7Bfileset%7D~1files"
+
/metalakes/{metalake}/catalogs/{catalog}/schemas/{schema}/topics:
$ref: "./topics.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1catalogs~1%7Bcatalog%7D~1schemas~1%7Bschema%7D~1topics"
diff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java
index 51baa3c655..2d4eb8ead7 100644
--- a/server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java
+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/FilesetOperations.java
@@ -199,8 +199,8 @@ public class FilesetOperations {
@PathParam("catalog") String catalog,
@PathParam("schema") String schema,
@PathParam("fileset") String fileset,
- @QueryParam("subPath") @DefaultValue("/") String subPath,
- @QueryParam("locationName") String locationName)
+ @QueryParam("sub_path") @DefaultValue("/") String subPath,
+ @QueryParam("location_name") String locationName)
throws UnsupportedEncodingException {
LOG.info(
"Received list files request: {}.{}.{}.{}, subPath: {}, locationName:{}",