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(dashboard): Dashboard api returning different analytics #99

Merged
merged 1 commit into from
Feb 27, 2025
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
107 changes: 107 additions & 0 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,42 @@ const docTemplate = `{
}
}
},
"/dashboard": {
"get": {
"security": [
{
"ApiKeyAuth": [],
"{}": []
}
],
"description": "Fetches data to be displayed on the dashboard",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Dashboard"
],
"summary": "Fetches data to be displayed on the dashboard",
"operationId": "GetDashboardData",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.DashboardResponse"
}
},
"500": {
"description": "Something went wrong",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/health": {
"get": {
"description": "Check health of the service",
Expand Down Expand Up @@ -2298,6 +2334,19 @@ const docTemplate = `{
}
}
},
"models.CategoryObligationCount": {
"type": "object",
"properties": {
"category": {
"type": "string",
"example": "GENERAL"
},
"count": {
"type": "integer",
"example": 6
}
}
},
"models.ChangeLog": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2341,6 +2390,51 @@ const docTemplate = `{
}
}
},
"models.Dashboard": {
"type": "object",
"properties": {
"category_obligation_frequency": {
"type": "array",
"items": {
"$ref": "#/definitions/models.CategoryObligationCount"
}
},
"licenses_count": {
"type": "integer",
"example": 2
},
"monthly_license_changes_count": {
"type": "integer",
"example": 6
},
"obligations_count": {
"type": "integer",
"example": 7
},
"risk_license_frequency": {
"type": "array",
"items": {
"$ref": "#/definitions/models.RiskLicenseCount"
}
},
"users_count": {
"type": "integer",
"example": 5
}
}
},
"models.DashboardResponse": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Dashboard"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ImportLicensesResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -3050,6 +3144,19 @@ const docTemplate = `{
}
}
},
"models.RiskLicenseCount": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"example": 6
},
"risk": {
"type": "integer",
"example": 2
}
}
},
"models.SearchLicense": {
"type": "object",
"required": [
Expand Down
107 changes: 107 additions & 0 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,42 @@
}
}
},
"/dashboard": {
"get": {
"security": [
{
"ApiKeyAuth": [],
"{}": []
}
],
"description": "Fetches data to be displayed on the dashboard",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Dashboard"
],
"summary": "Fetches data to be displayed on the dashboard",
"operationId": "GetDashboardData",
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/models.DashboardResponse"
}
},
"500": {
"description": "Something went wrong",
"schema": {
"$ref": "#/definitions/models.LicenseError"
}
}
}
}
},
"/health": {
"get": {
"description": "Check health of the service",
Expand Down Expand Up @@ -2291,6 +2327,19 @@
}
}
},
"models.CategoryObligationCount": {
"type": "object",
"properties": {
"category": {
"type": "string",
"example": "GENERAL"
},
"count": {
"type": "integer",
"example": 6
}
}
},
"models.ChangeLog": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -2334,6 +2383,51 @@
}
}
},
"models.Dashboard": {
"type": "object",
"properties": {
"category_obligation_frequency": {
"type": "array",
"items": {
"$ref": "#/definitions/models.CategoryObligationCount"
}
},
"licenses_count": {
"type": "integer",
"example": 2
},
"monthly_license_changes_count": {
"type": "integer",
"example": 6
},
"obligations_count": {
"type": "integer",
"example": 7
},
"risk_license_frequency": {
"type": "array",
"items": {
"$ref": "#/definitions/models.RiskLicenseCount"
}
},
"users_count": {
"type": "integer",
"example": 5
}
}
},
"models.DashboardResponse": {
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/models.Dashboard"
},
"status": {
"type": "integer",
"example": 200
}
}
},
"models.ImportLicensesResponse": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -3043,6 +3137,19 @@
}
}
},
"models.RiskLicenseCount": {
"type": "object",
"properties": {
"count": {
"type": "integer",
"example": 6
},
"risk": {
"type": "integer",
"example": 2
}
}
},
"models.SearchLicense": {
"type": "object",
"required": [
Expand Down
72 changes: 72 additions & 0 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ definitions:
example: 200
type: integer
type: object
models.CategoryObligationCount:
properties:
category:
example: GENERAL
type: string
count:
example: 6
type: integer
type: object
models.ChangeLog:
properties:
audit_id:
Expand Down Expand Up @@ -84,6 +93,37 @@ definitions:
example: 200
type: integer
type: object
models.Dashboard:
properties:
category_obligation_frequency:
items:
$ref: '#/definitions/models.CategoryObligationCount'
type: array
licenses_count:
example: 2
type: integer
monthly_license_changes_count:
example: 6
type: integer
obligations_count:
example: 7
type: integer
risk_license_frequency:
items:
$ref: '#/definitions/models.RiskLicenseCount'
type: array
users_count:
example: 5
type: integer
type: object
models.DashboardResponse:
properties:
data:
$ref: '#/definitions/models.Dashboard'
status:
example: 200
type: integer
type: object
models.ImportLicensesResponse:
properties:
data:
Expand Down Expand Up @@ -586,6 +626,15 @@ definitions:
user_password:
type: string
type: object
models.RiskLicenseCount:
properties:
count:
example: 6
type: integer
risk:
example: 2
type: integer
type: object
models.SearchLicense:
properties:
field:
Expand Down Expand Up @@ -877,6 +926,29 @@ paths:
summary: Get a changelog
tags:
- Audits
/dashboard:
get:
consumes:
- application/json
description: Fetches data to be displayed on the dashboard
operationId: GetDashboardData
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/models.DashboardResponse'
"500":
description: Something went wrong
schema:
$ref: '#/definitions/models.LicenseError'
security:
- '{}': []
ApiKeyAuth: []
summary: Fetches data to be displayed on the dashboard
tags:
- Dashboard
/health:
get:
consumes:
Expand Down
8 changes: 8 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func Router() *gin.Engine {
audit.GET(":audit_id/changes", GetChangeLogs)
audit.GET(":audit_id/changes/:id", GetChangeLogbyId)
}
dashboard := authorizedv1.Group("/dashboard")
{
dashboard.GET("", GetDashboardData)
}
}
} else {
unAuthorizedv1 := r.Group("/api/v1")
Expand Down Expand Up @@ -213,6 +217,10 @@ func Router() *gin.Engine {
{
oidc.POST("", auth.CreateOidcUser)
}
dashboard := unAuthorizedv1.Group("/dashboard")
{
dashboard.GET("", GetDashboardData)
}
}

authorizedv1 := r.Group("/api/v1")
Expand Down
Loading