Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6092] docs(core): add credential openapi document #6088

Merged
merged 9 commits into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/open-api/catalogs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ components:
- hive
- lakehouse-iceberg
- lakehouse-paimon
- lakehouse-hudi
- jdbc-mysql
- jdbc-postgresql
- jdbc-doris
Expand Down
130 changes: 130 additions & 0 deletions docs/open-api/credentials.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# 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:
mchades marked this conversation as resolved.
Show resolved Hide resolved
parameters:
- $ref: "./openapi.yaml#/components/parameters/metalake"
- $ref: "./openapi.yaml#/components/parameters/metadataObjectType"
- $ref: "./openapi.yaml#/components/parameters/metadataObjectFullName"
get:
tags:
- credentials
summary: List credentials for metadata object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary will be used as the title in the sidebar (https://gravitino.apache.org/docs/0.7.0-incubating/api/rest/list-catalogs), it should not be too long.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

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":
mchades marked this conversation as resolved.
Show resolved Hide resolved
description: Not Found - The credential does not exist
content:
application/vnd.gravitino.v1+json:
schema:
$ref: "./openapi.yaml#/components/schemas/ErrorModel"
examples:
NoSuchCredentialException:
$ref: "#/components/examples/NoSuchCredentialException"
"5xx":
$ref: "./openapi.yaml#/components/responses/ServerErrorResponse"


components:
schemas:
Credential:
type: object
description: A credential
required:
- credentialType
- expireTimeInMs
- credentialInfo
properties:
credentialType:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't call this credentialType because the property has a well-defined scope.
E.g. when I'm modeling a Person, I'll simply add a gender property rather than
naming it as personGender.

This can be pretty simple, e.g.
{"type": "gcs-token", "expireTimeInMs": 12345, "data": {"token": "secret"}}

Copy link
Contributor Author

@FANNG1 FANNG1 Jan 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks for pointing this out, I agree with you, how about keeping this as it has been published as API? I will try to use the short style for new features.

type: string
description: The type of the credential
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we have a enum for this field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we didn't define an enum because we should support custom credentials. add the build-in credentials

expireTimeInMs:
type: long
description: The expire time of the credential
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please amend the description so that users know what this long number is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

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"
}
},
]
}

NoSuchCredentialException:
value: {
"code": 1003,
"type": "NoSuchCredentialException",
"message": "Failed to get credentials under object [metalake.catalog.schema.fileset1], reason [NoSuchCredentialException]",
"stack": [
"org.apache.gravitino.exceptions.NoSuchCredentialException: Credential does not exist",
"..."
]
}
Loading