Conversation
Signed-off-by: Lee Calcote <lee.calcote@layer5.io>
Summary of ChangesHello @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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| func (c *Credential) EventCategory() string { | ||
| return "connection" | ||
| } |
There was a problem hiding this comment.
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.
| func (c *Credential) EventCategory() string { | |
| return "connection" | |
| } | |
| func (c *Credential) EventCategory() string { | |
| return "credential" | |
| } |
| 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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|
@copilot use the singular noun for "credential", not plural noun "credentials". |
|
@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. |
Signed-off-by: Lee Calcote lee.calcote@layer5.io