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

feat: fetch single resource by resource id #1139

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion cmd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var configCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
c := models.Config{
AWS: []models.AWSConfig{
models.AWSConfig{
{
Name: "Demo",
Source: "CREDENTIALS_FILE",
Profile: "default",
Expand Down
2 changes: 1 addition & 1 deletion dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Follow the [Contribution Guide](https://github.com/tailwarden/komiser/blob/devel
From the Komiser root folder start the Komiser server by running:

```shell
go run \*.go start --config /path/to/config.toml
go run *.go start --config /path/to/config.toml
```

In a different terminal tab navigate to the `/dashboard` folder:
Expand Down
13 changes: 13 additions & 0 deletions handlers/resources_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -429,3 +429,16 @@ func (handler *ApiHandler) RelationStatsHandler(c *gin.Context) {
c.JSON(http.StatusOK, out)

}

func (handler *ApiHandler) GetResourceByIdHandler(c *gin.Context) {
resourceId := c.Query("resourceId")

var resource Resource

err := handler.db.NewSelect().Model(&resource).Where("resource_id = ?", resourceId).Scan(handler.ctx)
if err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "Resource not found"})
}

c.JSON(http.StatusOK, resource)
}
1 change: 1 addition & 0 deletions internal/api/v1/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func Endpoints(ctx context.Context, telemetry bool, analytics utils.Analytics, d
router.GET("/resources/export-csv", api.DownloadInventoryCSV)
router.GET("/resources/export-csv/:viewId", api.DownloadInventoryCSVForView)
router.POST("/resources/relations", api.RelationStatsHandler)
router.GET("/resources", api.GetResourceByIdHandler)
mlabouardy marked this conversation as resolved.
Show resolved Hide resolved

router.GET("/views", api.ListViewsHandler)
router.POST("/views", api.NewViewHandler)
Expand Down