Skip to content

feat: Add 'credential' schema#557

Open
leecalcote wants to merge 1 commit intomasterfrom
schemas/credentials
Open

feat: Add 'credential' schema#557
leecalcote wants to merge 1 commit intomasterfrom
schemas/credentials

Conversation

@leecalcote
Copy link
Member

Signed-off-by: Lee Calcote lee.calcote@layer5.io

Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @leecalcote, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a foundational credential schema, complete with its Go struct definitions, OpenAPI specifications for API interactions, and corresponding JSON schema and templates. This enhancement establishes a robust framework for securely managing sensitive user credentials, such as API keys and tokens, within the system, facilitating standardized data handling and API-driven operations.

Highlights

  • New Credential Schema Definition: Introduced Credential and CredentialPage Go structs for managing sensitive information, including fields for ID, name, user ID, type, secret, and timestamps, along with pagination details.
  • Credential Helper Functions: Added TableName() and EventCategory() methods to the Credential struct for database interaction and event categorization, enhancing its utility within the application.
  • OpenAPI Specification for Credentials: Defined a comprehensive OpenAPI api.yml for credential management, including endpoints for listing, creating, updating, deleting, and retrieving credentials by ID, with support for pagination, search, and ordering.
  • JSON Schema for Credential: Created a credential.yaml file detailing the JSON schema for the Credential object, ensuring data validation and consistency across the system.
  • Credential Templates: Provided credential_template.json and credential_template.yaml files for easy instantiation and reference of the new credential schema in both JSON and YAML formats.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@leecalcote leecalcote changed the title feat: Add 'credential' schema' feat: Add 'credential' schema Jan 13, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new credential schema, including the Go model, helper functions, and OpenAPI specifications. The changes are well-structured. I've provided a few suggestions to improve the REST API design for PUT and DELETE operations, to enhance consistency in the YAML schema definitions, and to make event categorization more specific. Overall, this is a good addition.

Comment on lines +100 to +119
delete:
x-internal: ["cloud"]
tags:
- Credentials
operationId: DeleteUserCredential
summary: Delete a credential
description: Soft deletes a credential by its ID.
parameters:
- name: credential_id
in: query
description: ID of the credential to delete
required: true
schema:
type: string
format: uuid
responses:
"200":
description: Credential deleted successfully
"500":
description: Server error
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The DELETE operation for a single resource should be on the resource's specific path, e.g., /api/integrations/credentials/{id}. Using DELETE on a collection path like /api/integrations/credentials with an ID in a query parameter is not standard REST practice and can be confused with an operation to delete multiple resources. For consistency and clarity, this operation should be moved to the /api/integrations/credentials/{id} path, using a path parameter for the ID.

Comment on lines +11 to +13
func (c *Credential) EventCategory() string {
return "connection"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The EventCategory for the Credential entity is hardcoded to "connection". This could be misleading. To make event tracking clearer and more specific, it would be better if this returned "credential". This would result in events like credential_created, credential_updated, etc., which is more descriptive.

Suggested change
func (c *Credential) EventCategory() string {
return "connection"
}
func (c *Credential) EventCategory() string {
return "credential"
}

Comment on lines +77 to +98
put:
x-internal: ["cloud"]
tags:
- Credentials
operationId: UpdateUserCredential
summary: Update an existing credential
description: Updates an existing credential for the authenticated user.
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Credential"
responses:
"200":
description: Credential updated successfully
content:
application/json:
schema:
$ref: "#/components/schemas/Credential"
"500":
description: Server error
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The PUT operation to update a single credential is on the collection path /api/integrations/credentials. While passing the ID in the request body is possible, it's more conventional in REST APIs to identify the resource to be updated in the URL path, e.g., PUT /api/integrations/credentials/{id}. This would make the update endpoint consistent with the GET by ID endpoint (GET /api/integrations/credentials/{id}). Consider moving this operation to the /api/integrations/credentials/{id} path.

x-oapi-codegen-extra-tags:
db: id
json: id,omitempty
yaml: id
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The yaml struct tag is missing omitempty, while the corresponding json tag on the previous line includes it. For consistency in serialization behavior between JSON and YAML, it's recommended to add omitempty to the yaml tags. This principle applies to other fields in this file as well.

      yaml: id,omitempty

@leecalcote leecalcote requested review from a team and aabidsofi19 January 13, 2026 22:08
@ritzorama
Copy link
Member

@copilot use the singular noun for "credential", not plural noun "credentials".

Copy link
Contributor

Copilot AI commented Jan 13, 2026

@ritzorama I've opened a new pull request, #558, to work on those changes. Once the pull request is ready, I'll request review from you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants