Skip to content

Commit

Permalink
Merge pull request #99 from siemens/feat/dashboard
Browse files Browse the repository at this point in the history
feat(dashboard): Dashboard api returning different analytics
  • Loading branch information
GMishx authored Feb 27, 2025
2 parents 9bb36c7 + 4a10a0d commit e1d602f
Show file tree
Hide file tree
Showing 6 changed files with 448 additions and 0 deletions.
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 @@ -2231,6 +2267,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 @@ -2274,6 +2323,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 @@ -2895,6 +2989,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 @@ -2224,6 +2260,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 @@ -2267,6 +2316,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 @@ -2888,6 +2982,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 @@ -518,6 +558,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 @@ -809,6 +858,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 @@ -215,6 +219,10 @@ func Router() *gin.Engine {
{
oidc.POST("", auth.CreateOidcUser)
}
dashboard := unAuthorizedv1.Group("/dashboard")
{
dashboard.GET("", GetDashboardData)
}
}

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

0 comments on commit e1d602f

Please sign in to comment.