This is an automated email from the ASF dual-hosted git repository.
mchades pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new b3a848bf33 [#6092] docs(core): add credential openapi document (#6088)
b3a848bf33 is described below
commit b3a848bf333caca4af38a021459f3016616bd29c
Author: FANNG <[email protected]>
AuthorDate: Tue Jan 7 13:57:28 2025 +0800
[#6092] docs(core): add credential openapi document (#6088)
### What changes were proposed in this pull request?
add credential openapi document
### Why are the changes needed?
Fix: #6092
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
just document
---
.../gravitino/credential/SupportsCredentials.java | 2 +-
.../org/apache/gravitino/client/ErrorHandlers.java | 5 -
.../gravitino/client/TestSupportCredentials.java | 12 ---
docs/open-api/catalogs.yaml | 1 +
docs/open-api/credentials.yaml | 119 +++++++++++++++++++++
docs/open-api/openapi.yaml | 3 +
docs/open-api/tags.yaml | 22 +++-
.../TestMetadataObjectCredentialOperations.java | 23 ----
8 files changed, 145 insertions(+), 42 deletions(-)
diff --git
a/api/src/main/java/org/apache/gravitino/credential/SupportsCredentials.java
b/api/src/main/java/org/apache/gravitino/credential/SupportsCredentials.java
index 678172c422..b2569fe393 100644
--- a/api/src/main/java/org/apache/gravitino/credential/SupportsCredentials.java
+++ b/api/src/main/java/org/apache/gravitino/credential/SupportsCredentials.java
@@ -41,7 +41,7 @@ public interface SupportsCredentials {
* org.apache.gravitino.file.Fileset}, {@link
org.apache.gravitino.rel.Table}. There will be
* at most one credential for one credential type.
*/
- Credential[] getCredentials() throws NoSuchCredentialException;
+ Credential[] getCredentials();
/**
* Retrieves an {@link Credential} object based on the specified credential
type.
diff --git
a/clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
b/clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
index 2fca9cde35..d9b4ddb49f 100644
---
a/clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
+++
b/clients/client-java/src/main/java/org/apache/gravitino/client/ErrorHandlers.java
@@ -44,7 +44,6 @@ import
org.apache.gravitino.exceptions.MetalakeNotInUseException;
import org.apache.gravitino.exceptions.ModelAlreadyExistsException;
import
org.apache.gravitino.exceptions.ModelVersionAliasesAlreadyExistException;
import org.apache.gravitino.exceptions.NoSuchCatalogException;
-import org.apache.gravitino.exceptions.NoSuchCredentialException;
import org.apache.gravitino.exceptions.NoSuchFilesetException;
import org.apache.gravitino.exceptions.NoSuchGroupException;
import org.apache.gravitino.exceptions.NoSuchMetadataObjectException;
@@ -898,10 +897,6 @@ public class ErrorHandlers {
case ErrorConstants.NOT_FOUND_CODE:
if
(errorResponse.getType().equals(NoSuchMetalakeException.class.getSimpleName()))
{
throw new NoSuchMetalakeException(errorMessage);
- } else if (errorResponse
- .getType()
- .equals(NoSuchCredentialException.class.getSimpleName())) {
- throw new NoSuchCredentialException(errorMessage);
} else {
throw new NotFoundException(errorMessage);
}
diff --git
a/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportCredentials.java
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportCredentials.java
index 7b0817c8bb..842af4a640 100644
---
a/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportCredentials.java
+++
b/clients/client-java/src/test/java/org/apache/gravitino/client/TestSupportCredentials.java
@@ -19,7 +19,6 @@
package org.apache.gravitino.client;
import static org.apache.hc.core5.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
-import static org.apache.hc.core5.http.HttpStatus.SC_NOT_FOUND;
import static org.apache.hc.core5.http.HttpStatus.SC_OK;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -39,7 +38,6 @@ import org.apache.gravitino.dto.file.FilesetDTO;
import org.apache.gravitino.dto.responses.CredentialResponse;
import org.apache.gravitino.dto.responses.ErrorResponse;
import org.apache.gravitino.dto.util.DTOConverters;
-import org.apache.gravitino.exceptions.NoSuchCredentialException;
import org.apache.gravitino.file.Fileset;
import org.apache.hc.core5.http.Method;
import org.junit.jupiter.api.Assertions;
@@ -154,16 +152,6 @@ public class TestSupportCredentials extends TestBase {
credentials = supportsCredentials.getCredentials();
Assertions.assertEquals(0, credentials.length);
- // Test throw NoSuchCredentialException
- ErrorResponse errorResp =
-
ErrorResponse.notFound(NoSuchCredentialException.class.getSimpleName(), "mock
error");
- buildMockResource(Method.GET, path, null, errorResp, SC_NOT_FOUND);
-
- Throwable ex =
- Assertions.assertThrows(
- NoSuchCredentialException.class, () ->
supportsCredentials.getCredentials());
- Assertions.assertTrue(ex.getMessage().contains("mock error"));
-
// Test throw internal error
ErrorResponse errorResp1 = ErrorResponse.internalError("mock error");
buildMockResource(Method.GET, path, null, errorResp1,
SC_INTERNAL_SERVER_ERROR);
diff --git a/docs/open-api/catalogs.yaml b/docs/open-api/catalogs.yaml
index 0096944f27..9e4efdaf58 100644
--- a/docs/open-api/catalogs.yaml
+++ b/docs/open-api/catalogs.yaml
@@ -291,6 +291,7 @@ components:
- hive
- lakehouse-iceberg
- lakehouse-paimon
+ - lakehouse-hudi
- jdbc-mysql
- jdbc-postgresql
- jdbc-doris
diff --git a/docs/open-api/credentials.yaml b/docs/open-api/credentials.yaml
new file mode 100644
index 0000000000..4f5106c396
--- /dev/null
+++ b/docs/open-api/credentials.yaml
@@ -0,0 +1,119 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+---
+
+paths:
+
+
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/credentials:
+ parameters:
+ - $ref: "./openapi.yaml#/components/parameters/metalake"
+ - $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
+ - $ref: "./openapi.yaml#/components/parameters/metadataObjectFullName"
+ get:
+ tags:
+ - credentials
+ summary: Get credentials
+ operationId: getCredentials
+ responses:
+ "200":
+ description: Returns the list of credential objects associated with
specified metadata object.
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "#/components/responses/CredentialResponse"
+ examples:
+ CredentialResponse:
+ $ref: "#/components/examples/CredentialResponse"
+ "400":
+ $ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
+ "404":
+ description: Not Found - The specified metalake does not exist
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "./openapi.yaml#/components/schemas/ErrorModel"
+ examples:
+ NoSuchMetalakeException:
+ $ref:
"./metalakes.yaml#/components/examples/NoSuchMetalakeException"
+ "5xx":
+ $ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
+
+
+components:
+ schemas:
+ Credential:
+ type: object
+ description: A credential
+ required:
+ - credentialType
+ - expireTimeInMs
+ - credentialInfo
+ properties:
+ credentialType:
+ type: string
+ description: The type of the credential, for example, s3-token,
s3-secret-key, oss-token, oss-secret-key, gcs-token, adls-token,
azure-account-key, etc.
+ expireTimeInMs:
+ type: integer
+ description: The expiration time of the credential in milliseconds
since the epoch, 0 means not expire.
+ credentialInfo:
+ type: object
+ description: The specific information of the credential.
+ default: { }
+ additionalProperties:
+ type: string
+
+ responses:
+ CredentialResponse:
+ type: object
+ properties:
+ code:
+ type: integer
+ format: int32
+ description: Status code of the response
+ enum:
+ - 0
+ credentials:
+ type: array
+ description: A list of credential objects
+ items:
+ $ref: "#/components/schemas/Credential"
+
+ examples:
+ CredentialResponse:
+ value: {
+ "code": 0,
+ "credentials": [
+ {
+ "credentialType": "s3-token",
+ "expireTimeInMs": 1735891948411,
+ "credentialInfo": {
+ "s3-access-key-id": "value1",
+ "s3-secret-access-key": "value2",
+ "s3-session-token": "value3"
+ }
+ },
+ {
+ "credentialType": "s3-secret-key",
+ "expireTimeInMs": 0,
+ "credentialInfo": {
+ "s3-access-key-id": "value1",
+ "s3-secret-access-key": "value2"
+ }
+ },
+ ]
+ }
\ No newline at end of file
diff --git a/docs/open-api/openapi.yaml b/docs/open-api/openapi.yaml
index d0c941ab47..f39a90f55f 100644
--- a/docs/open-api/openapi.yaml
+++ b/docs/open-api/openapi.yaml
@@ -68,6 +68,9 @@ paths:
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/roles:
$ref:
"./roles.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1objects~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1roles"
+
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/credentials:
+ $ref:
"./credentials.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1objects~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1credentials"
+
/metalakes/{metalake}/objects/{metadataObjectType}/{metadataObjectFullName}/tags/{tag}:
$ref:
"./tags.yaml#/paths/~1metalakes~1%7Bmetalake%7D~1objects~1%7BmetadataObjectType%7D~1%7BmetadataObjectFullName%7D~1tags~1%7Btag%7D"
diff --git a/docs/open-api/tags.yaml b/docs/open-api/tags.yaml
index 7b8deef252..a3be5230b9 100644
--- a/docs/open-api/tags.yaml
+++ b/docs/open-api/tags.yaml
@@ -206,6 +206,15 @@ paths:
$ref: "#/components/examples/TagListResponse"
"400":
$ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
+ "404":
+ description: Not Found - The specified metalake does not exist
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "./openapi.yaml#/components/schemas/ErrorModel"
+ examples:
+ NoSuchMetalakeException:
+ $ref:
"./metalakes.yaml#/components/examples/NoSuchMetalakeException"
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
@@ -233,6 +242,15 @@ paths:
examples:
NameListResponse:
$ref: "#/components/examples/NameListResponse"
+ "404":
+ description: Not Found - The specified metalake does not exist
+ content:
+ application/vnd.gravitino.v1+json:
+ schema:
+ $ref: "./openapi.yaml#/components/schemas/ErrorModel"
+ examples:
+ NoSuchMetalakeException:
+ $ref:
"./metalakes.yaml#/components/examples/NoSuchMetalakeException"
"409":
description: Conflict - The target tag already associated with the
specified metadata object
content:
@@ -272,7 +290,7 @@ paths:
"400":
$ref: "./openapi.yaml#/components/responses/BadRequestErrorResponse"
"404":
- description: Not Found - The specified metadata object does not
exist or the specified tag is not associated with the specified metadata object
+ description: Not Found - The specified metalake does not exist or
the specified tag is not associated with the specified metadata object
content:
application/vnd.gravitino.v1+json:
schema:
@@ -280,6 +298,8 @@ paths:
examples:
NoSuchTagException:
$ref: "#/components/examples/NoSuchTagException"
+ NoSuchMetalakeException:
+ $ref:
"./metalakes.yaml#/components/examples/NoSuchMetalakeException"
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"
diff --git
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestMetadataObjectCredentialOperations.java
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestMetadataObjectCredentialOperations.java
index 464ccd8698..ce759fac65 100644
---
a/server/src/test/java/org/apache/gravitino/server/web/rest/TestMetadataObjectCredentialOperations.java
+++
b/server/src/test/java/org/apache/gravitino/server/web/rest/TestMetadataObjectCredentialOperations.java
@@ -19,7 +19,6 @@
package org.apache.gravitino.server.web.rest;
import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -35,10 +34,7 @@ import org.apache.gravitino.credential.Credential;
import org.apache.gravitino.credential.CredentialOperationDispatcher;
import org.apache.gravitino.credential.S3SecretKeyCredential;
import org.apache.gravitino.dto.responses.CredentialResponse;
-import org.apache.gravitino.dto.responses.ErrorConstants;
-import org.apache.gravitino.dto.responses.ErrorResponse;
import org.apache.gravitino.dto.util.DTOConverters;
-import org.apache.gravitino.exceptions.NoSuchCredentialException;
import org.apache.gravitino.rest.RESTUtils;
import org.glassfish.jersey.internal.inject.AbstractBinder;
import org.glassfish.jersey.server.ResourceConfig;
@@ -138,25 +134,6 @@ public class TestMetadataObjectCredentialOperations
extends JerseyTest {
credentialResponse = response.readEntity(CredentialResponse.class);
Assertions.assertEquals(0, credentialResponse.getCode());
Assertions.assertEquals(0, credentialResponse.getCredentials().length);
-
- // Test throws NoSuchCredentialException
- doThrow(new NoSuchCredentialException("mock error"))
- .when(credentialOperationDispatcher)
- .getCredentials(any());
- response =
- target(basePath(metalake))
- .path(metadataObject.type().toString())
- .path(metadataObject.fullName())
- .path("/credentials")
- .request(MediaType.APPLICATION_JSON_TYPE)
- .accept("application/vnd.gravitino.v1+json")
- .get();
-
- Assertions.assertEquals(Response.Status.NOT_FOUND.getStatusCode(),
response.getStatus());
- ErrorResponse errorResponse = response.readEntity(ErrorResponse.class);
- Assertions.assertEquals(ErrorConstants.NOT_FOUND_CODE,
errorResponse.getCode());
- Assertions.assertEquals(
- NoSuchCredentialException.class.getSimpleName(),
errorResponse.getType());
}
private String basePath(String metalake) {