Skip to content

Commit

Permalink
feature. change audit api path "/organizations/" to "/admin"
Browse files Browse the repository at this point in the history
  • Loading branch information
ktkfree committed Mar 13, 2024
1 parent ceb699c commit 24d7d22
Show file tree
Hide file tree
Showing 8 changed files with 501 additions and 508 deletions.
366 changes: 183 additions & 183 deletions api/swagger/docs.go

Large diffs are not rendered by default.

366 changes: 183 additions & 183 deletions api/swagger/swagger.json

Large diffs are not rendered by default.

234 changes: 117 additions & 117 deletions api/swagger/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2925,6 +2925,120 @@ info:
title: tks-api service
version: "1.0"
paths:
/admin/audits:
get:
consumes:
- application/json
description: Get Audits
parameters:
- description: pageSize
in: query
name: limit
type: string
- description: pageNumber
in: query
name: page
type: string
- description: sortColumn
in: query
name: soertColumn
type: string
- description: sortOrder
in: query
name: sortOrder
type: string
- collectionFormat: csv
description: filters
in: query
items:
type: string
name: filter
type: array
- collectionFormat: csv
description: filters
in: query
items:
type: string
name: or
type: array
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetAuditsResponse'
security:
- JWT: []
summary: Get Audits
tags:
- Audits
post:
consumes:
- application/json
description: Create Audit
parameters:
- description: create audit request
in: body
name: body
required: true
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.CreateAuditRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.CreateAuditResponse'
security:
- JWT: []
summary: Create Audit
tags:
- Audits
/admin/audits/{auditId}:
delete:
consumes:
- application/json
description: Delete Audit
parameters:
- description: auditId
in: path
name: auditId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
security:
- JWT: []
summary: Delete Audit 'NOT IMPLEMENTED'
tags:
- Audits
get:
consumes:
- application/json
description: Get Audit
parameters:
- description: auditId
in: path
name: auditId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetAuditResponse'
security:
- JWT: []
summary: Get Audit
tags:
- Audits
/admin/organizations/{organizationId}/projects:
get:
consumes:
Expand Down Expand Up @@ -3441,7 +3555,7 @@ paths:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.CreateStackTemplateResponse'
security:
- JWT: []
summary: Create StackTemplate 'NOT IMPLEMENTED'
summary: Create StackTemplate
tags:
- StackTemplates
/admin/stack-templates/{stackTemplateId}:
Expand All @@ -3462,7 +3576,7 @@ paths:
description: OK
security:
- JWT: []
summary: Delete StackTemplate 'NOT IMPLEMENTED'
summary: Delete StackTemplate
tags:
- StackTemplates
get:
Expand Down Expand Up @@ -3505,7 +3619,7 @@ paths:
description: OK
security:
- JWT: []
summary: Update StackTemplate 'NOT IMPLEMENTED'
summary: Update StackTemplate
tags:
- StackTemplates
/admin/stack-templates/{stackTemplateId}/organizations:
Expand Down Expand Up @@ -4397,120 +4511,6 @@ paths:
summary: Create alert action
tags:
- Alerts
/organizations/{organizationId}/audits:
get:
consumes:
- application/json
description: Get Audits
parameters:
- description: pageSize
in: query
name: limit
type: string
- description: pageNumber
in: query
name: page
type: string
- description: sortColumn
in: query
name: soertColumn
type: string
- description: sortOrder
in: query
name: sortOrder
type: string
- collectionFormat: csv
description: filters
in: query
items:
type: string
name: filter
type: array
- collectionFormat: csv
description: filters
in: query
items:
type: string
name: or
type: array
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetAuditsResponse'
security:
- JWT: []
summary: Get Audits
tags:
- Audits
post:
consumes:
- application/json
description: Create Audit
parameters:
- description: create audit request
in: body
name: body
required: true
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.CreateAuditRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.CreateAuditResponse'
security:
- JWT: []
summary: Create Audit
tags:
- Audits
/organizations/{organizationId}/audits/{auditId}:
delete:
consumes:
- application/json
description: Delete Audit
parameters:
- description: auditId
in: path
name: auditId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
security:
- JWT: []
summary: Delete Audit 'NOT IMPLEMENTED'
tags:
- Audits
get:
consumes:
- application/json
description: Get Audit
parameters:
- description: auditId
in: path
name: auditId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/github_com_openinfradev_tks-api_pkg_domain.GetAuditResponse'
security:
- JWT: []
summary: Get Audit
tags:
- Audits
/organizations/{organizationId}/cloud-accounts:
get:
consumes:
Expand Down
17 changes: 5 additions & 12 deletions internal/delivery/http/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func NewAuditHandler(h usecase.Usecase) *AuditHandler {
// @Produce json
// @Param body body domain.CreateAuditRequest true "create audit request"
// @Success 200 {object} domain.CreateAuditResponse
// @Router /organizations/{organizationId}/audits [post]
// @Router /admin/audits [post]
// @Security JWT
func (h *AuditHandler) CreateAudit(w http.ResponseWriter, r *http.Request) {
ErrorJSON(w, r, fmt.Errorf("need implementation"))
Expand All @@ -54,19 +54,12 @@ func (h *AuditHandler) CreateAudit(w http.ResponseWriter, r *http.Request) {
// @Param filter query []string false "filters"
// @Param or query []string false "filters"
// @Success 200 {object} domain.GetAuditsResponse
// @Router /organizations/{organizationId}/audits [get]
// @Router /admin/audits [get]
// @Security JWT
func (h *AuditHandler) GetAudits(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
organizationId, ok := vars["organizationId"]
if !ok {
ErrorJSON(w, r, httpErrors.NewBadRequestError(fmt.Errorf("Invalid organizationId"), "C_INVALID_ORGANIZATION_ID", ""))
return
}

urlParams := r.URL.Query()
pg := pagination.NewPagination(&urlParams)
audits, err := h.usecase.Fetch(r.Context(), organizationId, pg)
audits, err := h.usecase.Fetch(r.Context(), pg)
if err != nil {
ErrorJSON(w, r, err)
return
Expand Down Expand Up @@ -96,7 +89,7 @@ func (h *AuditHandler) GetAudits(w http.ResponseWriter, r *http.Request) {
// @Produce json
// @Param auditId path string true "auditId"
// @Success 200 {object} domain.GetAuditResponse
// @Router /organizations/{organizationId}/audits/{auditId} [get]
// @Router /admin/audits/{auditId} [get]
// @Security JWT
func (h *AuditHandler) GetAudit(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -137,7 +130,7 @@ func (h *AuditHandler) GetAudit(w http.ResponseWriter, r *http.Request) {
// @Produce json
// @Param auditId path string true "auditId"
// @Success 200 {object} nil
// @Router /organizations/{organizationId}/audits/{auditId} [delete]
// @Router /admin/audits/{auditId} [delete]
// @Security JWT
func (h *AuditHandler) DeleteAudit(w http.ResponseWriter, r *http.Request) {
ErrorJSON(w, r, fmt.Errorf("need implementation"))
Expand Down
6 changes: 3 additions & 3 deletions internal/delivery/http/stack-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func NewStackTemplateHandler(h usecase.Usecase) *StackTemplateHandler {
// CreateStackTemplate godoc
//
// @Tags StackTemplates
// @Summary Create StackTemplate 'NOT IMPLEMENTED'
// @Summary Create StackTemplate
// @Description Create StackTemplate
// @Accept json
// @Produce json
Expand Down Expand Up @@ -171,7 +171,7 @@ func (h *StackTemplateHandler) GetStackTemplate(w http.ResponseWriter, r *http.R
// UpdateStackTemplate godoc
//
// @Tags StackTemplates
// @Summary Update StackTemplate 'NOT IMPLEMENTED'
// @Summary Update StackTemplate
// @Description Update StackTemplate
// @Accept json
// @Produce json
Expand Down Expand Up @@ -210,7 +210,7 @@ func (h *StackTemplateHandler) UpdateStackTemplate(w http.ResponseWriter, r *htt
// DeleteStackTemplate godoc
//
// @Tags StackTemplates
// @Summary Delete StackTemplate 'NOT IMPLEMENTED'
// @Summary Delete StackTemplate
// @Description Delete StackTemplate
// @Accept json
// @Produce json
Expand Down
6 changes: 3 additions & 3 deletions internal/repository/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
// Interfaces
type IAuditRepository interface {
Get(auditId uuid.UUID) (model.Audit, error)
Fetch(organizationId string, pg *pagination.Pagination) ([]model.Audit, error)
Fetch(pg *pagination.Pagination) ([]model.Audit, error)
Create(dto model.Audit) (auditId uuid.UUID, err error)
Delete(auditId uuid.UUID) (err error)
}
Expand All @@ -38,12 +38,12 @@ func (r *AuditRepository) Get(auditId uuid.UUID) (out model.Audit, err error) {
return
}

func (r *AuditRepository) Fetch(organizationId string, pg *pagination.Pagination) (out []model.Audit, err error) {
func (r *AuditRepository) Fetch(pg *pagination.Pagination) (out []model.Audit, err error) {
if pg == nil {
pg = pagination.NewPagination(nil)
}

db := r.db.Model(&model.Audit{}).Preload(clause.Associations).Where("audits.organization_id = ?", organizationId)
db := r.db.Model(&model.Audit{}).Preload(clause.Associations)
_, res := pg.Fetch(db, &out)
if res.Error != nil {
return nil, res.Error
Expand Down
8 changes: 4 additions & 4 deletions internal/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,9 @@ func SetupRouter(db *gorm.DB, argoClient argowf.ArgoClient, kc keycloak.IKeycloa

stackTemplateHandler := delivery.NewStackTemplateHandler(usecaseFactory)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates", customMiddleware.Handle(internalApi.Admin_GetStackTemplates, http.HandlerFunc(stackTemplateHandler.GetStackTemplates))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/services", customMiddleware.Handle(internalApi.Admin_GetStackTemplateServices, http.HandlerFunc(stackTemplateHandler.GetStackTemplateServices))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/{stackTemplateId}", customMiddleware.Handle(internalApi.Admin_GetStackTemplates, http.HandlerFunc(stackTemplateHandler.GetStackTemplate))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates", customMiddleware.Handle(internalApi.Admin_CreateStackTemplate, http.HandlerFunc(stackTemplateHandler.CreateStackTemplate))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/services", customMiddleware.Handle(internalApi.Admin_GetStackTemplateServices, http.HandlerFunc(stackTemplateHandler.GetStackTemplateServices))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/{stackTemplateId}/organizations", customMiddleware.Handle(internalApi.Admin_UpdateStackTemplateOrganizations, http.HandlerFunc(stackTemplateHandler.UpdateStackTemplateOrganizations))).Methods(http.MethodPut)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/{stackTemplateId}", customMiddleware.Handle(internalApi.Admin_UpdateStackTemplate, http.HandlerFunc(stackTemplateHandler.UpdateStackTemplate))).Methods(http.MethodPut)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/stack-templates/{stackTemplateId}", customMiddleware.Handle(internalApi.Admin_DeleteStackTemplate, http.HandlerFunc(stackTemplateHandler.DeleteStackTemplate))).Methods(http.MethodDelete)
Expand Down Expand Up @@ -246,9 +246,9 @@ func SetupRouter(db *gorm.DB, argoClient argowf.ArgoClient, kc keycloak.IKeycloa
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/projects/{projectId}/kubeconfig", customMiddleware.Handle(internalApi.GetProjectKubeconfig, http.HandlerFunc(projectHandler.GetProjectKubeconfig))).Methods(http.MethodGet)

auditHandler := delivery.NewAuditHandler(usecaseFactory)
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/audits", customMiddleware.Handle(internalApi.GetAudits, http.HandlerFunc(auditHandler.GetAudits))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/audits/{auditId}", customMiddleware.Handle(internalApi.GetAudit, http.HandlerFunc(auditHandler.GetAudit))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/audits/{auditId}", customMiddleware.Handle(internalApi.DeleteAudit, http.HandlerFunc(auditHandler.DeleteAudit))).Methods(http.MethodDelete)
r.Handle(API_PREFIX+API_VERSION+"/admin/audits", customMiddleware.Handle(internalApi.GetAudits, http.HandlerFunc(auditHandler.GetAudits))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/admin/audits/{auditId}", customMiddleware.Handle(internalApi.GetAudit, http.HandlerFunc(auditHandler.GetAudit))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/admin/audits/{auditId}", customMiddleware.Handle(internalApi.DeleteAudit, http.HandlerFunc(auditHandler.DeleteAudit))).Methods(http.MethodDelete)

roleHandler := delivery.NewRoleHandler(usecaseFactory)
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/roles", customMiddleware.Handle(internalApi.CreateTksRole, http.HandlerFunc(roleHandler.CreateTksRole))).Methods(http.MethodPost)
Expand Down
Loading

0 comments on commit 24d7d22

Please sign in to comment.