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

/policytemplates -> /policy-templates, 일부 함수 네이밍 변경 #295

Merged
merged 1 commit into from
Mar 22, 2024
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
34 changes: 17 additions & 17 deletions internal/delivery/http/policy-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func NewPolicyTemplateHandler(u usecase.Usecase) IPolicyTemplateHandler {
// @Produce json
// @Param body body domain.CreatePolicyTemplateRequest true "create policy template request"
// @Success 200 {object} domain.CreatePolicyTemplateReponse
// @Router /admin/policytemplates [post]
// @Router /admin/policy-templates [post]
// @Security JWT
func (h *PolicyTemplateHandler) CreatePolicyTemplate(w http.ResponseWriter, r *http.Request) {
input := domain.CreatePolicyTemplateRequest{}
Expand Down Expand Up @@ -94,7 +94,7 @@ func (h *PolicyTemplateHandler) CreatePolicyTemplate(w http.ResponseWriter, r *h
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Param body body domain.UpdatePolicyTemplateRequest true "update policy template request"
// @Success 200 {object} nil
// @Router /admin/policytemplates/{policyTemplateId} [patch]
// @Router /admin/policy-templates/{policyTemplateId} [patch]
// @Security JWT
func (h *PolicyTemplateHandler) UpdatePolicyTemplate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -146,7 +146,7 @@ func (h *PolicyTemplateHandler) UpdatePolicyTemplate(w http.ResponseWriter, r *h
// @Produce json
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Success 200 {object} nil
// @Router /admin/policytemplates/{policyTemplateId} [delete]
// @Router /admin/policy-templates/{policyTemplateId} [delete]
// @Security JWT
func (h *PolicyTemplateHandler) DeletePolicyTemplate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -193,7 +193,7 @@ func (h *PolicyTemplateHandler) DeletePolicyTemplate(w http.ResponseWriter, r *h
// @Produce json
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Success 200 {object} domain.GetPolicyTemplateResponse
// @Router /admin/policytemplates/{policyTemplateId} [get]
// @Router /admin/policy-templates/{policyTemplateId} [get]
// @Security JWT
func (h *PolicyTemplateHandler) GetPolicyTemplate(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -237,7 +237,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplate(w http.ResponseWriter, r *http
log.Error(r.Context(), err)
}

if err = h.usecase.UpdatePermittedOrganizations(r.Context(), policyTemplate, &out.PolicyTemplate); err != nil {
if err = h.usecase.FillPermittedOrganizations(r.Context(), policyTemplate, &out.PolicyTemplate); err != nil {
log.Error(r.Context(), err)
}

Expand All @@ -257,7 +257,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplate(w http.ResponseWriter, r *http
// @Param sortOrder query string false "sortOrder"
// @Param filters query []string false "filters"
// @Success 200 {object} domain.ListPolicyTemplateResponse
// @Router /admin/policytemplates [get]
// @Router /admin/policy-templates [get]
// @Security JWT
func (h *PolicyTemplateHandler) ListPolicyTemplate(w http.ResponseWriter, r *http.Request) {
urlParams := r.URL.Query()
Expand All @@ -279,7 +279,7 @@ func (h *PolicyTemplateHandler) ListPolicyTemplate(w http.ResponseWriter, r *htt
}
}

if err = h.usecase.UpdatePermittedOrganizationsForList(r.Context(), &policyTemplates, &out.PolicyTemplates); err != nil {
if err = h.usecase.FillPermittedOrganizationsForList(r.Context(), &policyTemplates, &out.PolicyTemplates); err != nil {
log.Error(r.Context(), err)
}

Expand All @@ -299,7 +299,7 @@ func (h *PolicyTemplateHandler) ListPolicyTemplate(w http.ResponseWriter, r *htt
// @Produce json
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Success 200 {object} domain.ListPolicyTemplateVersionsResponse
// @Router /admin/policytemplates/{policyTemplateId}/versions [get]
// @Router /admin/policy-templates/{policyTemplateId}/versions [get]
// @Security JWT
func (h *PolicyTemplateHandler) ListPolicyTemplateVersions(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -347,7 +347,7 @@ func (h *PolicyTemplateHandler) ListPolicyTemplateVersions(w http.ResponseWriter
// @Produce json
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Success 200 {object} domain.ListPolicyTemplateStatisticsResponse
// @Router /admin/policytemplates/{policyTemplateId}/statistics [get]
// @Router /admin/policy-templates/{policyTemplateId}/statistics [get]
// @Security JWT
func (h *PolicyTemplateHandler) ListPolicyTemplateStatistics(w http.ResponseWriter, r *http.Request) {
// result := domain.ListPolicyTemplateStatisticsResponse{
Expand Down Expand Up @@ -376,7 +376,7 @@ func (h *PolicyTemplateHandler) ListPolicyTemplateStatistics(w http.ResponseWrit
// @Produce json
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Success 200 {object} domain.GetPolicyTemplateDeployResponse
// @Router /admin/policytemplates/{policyTemplateId}/deploy [get]
// @Router /admin/policy-templates/{policyTemplateId}/deploy [get]
// @Security JWT
func (h *PolicyTemplateHandler) GetPolicyTemplateDeploy(w http.ResponseWriter, r *http.Request) {
// c1 := util.UUIDGen()
Expand All @@ -403,7 +403,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplateDeploy(w http.ResponseWriter, r
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Param version path string true "조회할 버전(v0.0.0 형식)"
// @Success 200 {object} domain.GetPolicyTemplateVersionResponse
// @Router /admin/policytemplates/{policyTemplateId}/versions/{version} [get]
// @Router /admin/policy-templates/{policyTemplateId}/versions/{version} [get]
// @Security JWT
func (h *PolicyTemplateHandler) GetPolicyTemplateVersion(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -443,7 +443,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplateVersion(w http.ResponseWriter,
log.Error(r.Context(), err)
}

if err = h.usecase.UpdatePermittedOrganizations(r.Context(), policyTemplate, &out.PolicyTemplate); err != nil {
if err = h.usecase.FillPermittedOrganizations(r.Context(), policyTemplate, &out.PolicyTemplate); err != nil {
log.Error(r.Context(), err)
}

Expand All @@ -460,7 +460,7 @@ func (h *PolicyTemplateHandler) GetPolicyTemplateVersion(w http.ResponseWriter,
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Param body body domain.CreatePolicyTemplateVersionRequest true "create policy template version request"
// @Success 200 {object} domain.CreatePolicyTemplateVersionResponse
// @Router /admin/policytemplates/{policyTemplateId}/versions [post]
// @Router /admin/policy-templates/{policyTemplateId}/versions [post]
// @Security JWT
func (h *PolicyTemplateHandler) CreatePolicyTemplateVersion(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -536,7 +536,7 @@ func (h *PolicyTemplateHandler) CreatePolicyTemplateVersion(w http.ResponseWrite
// @Param policyTemplateId path string true "정책 템플릿 식별자(uuid)"
// @Param version path string true "삭제할 버전(v0.0.0 형식)"
// @Success 200 {object} nil
// @Router /admin/policytemplates/{policyTemplateId}/versions/{version} [delete]
// @Router /admin/policy-templates/{policyTemplateId}/versions/{version} [delete]
// @Security JWT
func (h *PolicyTemplateHandler) DeletePolicyTemplateVersion(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -584,7 +584,7 @@ func (h *PolicyTemplateHandler) DeletePolicyTemplateVersion(w http.ResponseWrite
// @Produce json
// @Param policyTemplateName path string true "정책 템플릿 이름"
// @Success 200 {object} domain.CheckExistedResponse
// @Router /admin/policytemplates/name/{policyTemplateName}/existence [get]
// @Router /admin/policy-templates/name/{policyTemplateName}/existence [get]
// @Security JWT
func (h *PolicyTemplateHandler) ExistsPolicyTemplateName(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -616,7 +616,7 @@ func (h *PolicyTemplateHandler) ExistsPolicyTemplateName(w http.ResponseWriter,
// @Produce json
// @Param policyTemplateKind path string true "정책 템플릿 이름"
// @Success 200 {object} domain.ExistsPolicyTemplateKindResponse
// @Router /admin/policytemplates/kind/{policyTemplateKind}/existence [get]
// @Router /admin/policy-templates/kind/{policyTemplateKind}/existence [get]
// @Security JWT
func (h *PolicyTemplateHandler) ExistsPolicyTemplateKind(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
Expand Down Expand Up @@ -649,7 +649,7 @@ func (h *PolicyTemplateHandler) ExistsPolicyTemplateKind(w http.ResponseWriter,
// @Param parseParameter query bool true "파라미터 파싱 여부"
// @Param body body domain.RegoCompileRequest true "Rego 코드"
// @Success 200 {object} domain.RegoCompileResponse
// @Router /policytemplates/rego-compile [post]
// @Router /policy-templates/rego-compile [post]
// @Security JWT
func (h *PolicyTemplateHandler) RegoCompile(w http.ResponseWriter, r *http.Request) {
parseParameter := false
Expand Down
28 changes: 14 additions & 14 deletions internal/route/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,20 +288,20 @@ func SetupRouter(db *gorm.DB, argoClient argowf.ArgoClient, kc keycloak.IKeycloa
r.Handle(API_PREFIX+API_VERSION+"/organizations/{organizationId}/roles/{roleId}/permissions", customMiddleware.Handle(internalApi.UpdatePermissionsByRoleId, http.HandlerFunc(permissionHandler.UpdatePermissionsByRoleId))).Methods(http.MethodPut)

policyTemplateHandler := delivery.NewPolicyTemplateHandler(usecaseFactory)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates", customMiddleware.Handle(internalApi.ListPolicyTemplate, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplate))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates", customMiddleware.Handle(internalApi.CreatePolicyTemplate, http.HandlerFunc(policyTemplateHandler.CreatePolicyTemplate))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}", customMiddleware.Handle(internalApi.DeletePolicyTemplate, http.HandlerFunc(policyTemplateHandler.DeletePolicyTemplate))).Methods(http.MethodDelete)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}", customMiddleware.Handle(internalApi.GetPolicyTemplate, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplate))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}", customMiddleware.Handle(internalApi.UpdatePolicyTemplate, http.HandlerFunc(policyTemplateHandler.UpdatePolicyTemplate))).Methods(http.MethodPatch)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/deploy ", customMiddleware.Handle(internalApi.GetPolicyTemplateDeploy, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplateDeploy))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/statistics", customMiddleware.Handle(internalApi.ListPolicyTemplateStatistics, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplateStatistics))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/versions", customMiddleware.Handle(internalApi.ListPolicyTemplateVersions, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplateVersions))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/versions", customMiddleware.Handle(internalApi.CreatePolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.CreatePolicyTemplateVersion))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/versions/{version}", customMiddleware.Handle(internalApi.DeletePolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.DeletePolicyTemplateVersion))).Methods(http.MethodDelete)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/{policyTemplateId}/versions/{version}", customMiddleware.Handle(internalApi.GetPolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplateVersion))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/kind/{policyTemplateKind}/existence", customMiddleware.Handle(internalApi.ExistsPolicyTemplateKind, http.HandlerFunc(policyTemplateHandler.ExistsPolicyTemplateKind))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policytemplates/name/{policyTemplateName}/existence", customMiddleware.Handle(internalApi.ExistsPolicyTemplateName, http.HandlerFunc(policyTemplateHandler.ExistsPolicyTemplateName))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/policytemplates/rego-compile", customMiddleware.Handle(internalApi.CompileRego, http.HandlerFunc(policyTemplateHandler.RegoCompile))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates", customMiddleware.Handle(internalApi.ListPolicyTemplate, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplate))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates", customMiddleware.Handle(internalApi.CreatePolicyTemplate, http.HandlerFunc(policyTemplateHandler.CreatePolicyTemplate))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}", customMiddleware.Handle(internalApi.DeletePolicyTemplate, http.HandlerFunc(policyTemplateHandler.DeletePolicyTemplate))).Methods(http.MethodDelete)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}", customMiddleware.Handle(internalApi.GetPolicyTemplate, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplate))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}", customMiddleware.Handle(internalApi.UpdatePolicyTemplate, http.HandlerFunc(policyTemplateHandler.UpdatePolicyTemplate))).Methods(http.MethodPatch)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/deploy ", customMiddleware.Handle(internalApi.GetPolicyTemplateDeploy, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplateDeploy))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/statistics", customMiddleware.Handle(internalApi.ListPolicyTemplateStatistics, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplateStatistics))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/versions", customMiddleware.Handle(internalApi.ListPolicyTemplateVersions, http.HandlerFunc(policyTemplateHandler.ListPolicyTemplateVersions))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/versions", customMiddleware.Handle(internalApi.CreatePolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.CreatePolicyTemplateVersion))).Methods(http.MethodPost)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/versions/{version}", customMiddleware.Handle(internalApi.DeletePolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.DeletePolicyTemplateVersion))).Methods(http.MethodDelete)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/{policyTemplateId}/versions/{version}", customMiddleware.Handle(internalApi.GetPolicyTemplateVersion, http.HandlerFunc(policyTemplateHandler.GetPolicyTemplateVersion))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/kind/{policyTemplateKind}/existence", customMiddleware.Handle(internalApi.ExistsPolicyTemplateKind, http.HandlerFunc(policyTemplateHandler.ExistsPolicyTemplateKind))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+ADMINAPI_PREFIX+"/policy-templates/name/{policyTemplateName}/existence", customMiddleware.Handle(internalApi.ExistsPolicyTemplateName, http.HandlerFunc(policyTemplateHandler.ExistsPolicyTemplateName))).Methods(http.MethodGet)
r.Handle(API_PREFIX+API_VERSION+"/policy-templates/rego-compile", customMiddleware.Handle(internalApi.CompileRego, http.HandlerFunc(policyTemplateHandler.RegoCompile))).Methods(http.MethodPost)

// assets
r.PathPrefix("/api/").HandlerFunc(http.NotFound)
Expand Down
8 changes: 4 additions & 4 deletions internal/usecase/policy-template.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ type IPolicyTemplateUsecase interface {

RegoCompile(request *domain.RegoCompileRequest, parseParameter bool) (response *domain.RegoCompileResponse, err error)

UpdatePermittedOrganizations(ctx context.Context,
FillPermittedOrganizations(ctx context.Context,
policyTemplate *model.PolicyTemplate, out *domain.PolicyTemplateResponse) error
UpdatePermittedOrganizationsForList(ctx context.Context,
FillPermittedOrganizationsForList(ctx context.Context,
policyTemplates *[]model.PolicyTemplate, outs *[]domain.PolicyTemplateResponse) error
}

Expand Down Expand Up @@ -104,7 +104,7 @@ func (u *PolicyTemplateUsecase) Fetch(ctx context.Context, pg *pagination.Pagina
return policyTemplates, nil
}

func (u *PolicyTemplateUsecase) UpdatePermittedOrganizations(ctx context.Context,
func (u *PolicyTemplateUsecase) FillPermittedOrganizations(ctx context.Context,
policyTemplate *model.PolicyTemplate, out *domain.PolicyTemplateResponse) error {
organizations, err := u.organizationRepo.Fetch(ctx, nil)

Expand All @@ -117,7 +117,7 @@ func (u *PolicyTemplateUsecase) UpdatePermittedOrganizations(ctx context.Context
return nil
}

func (u *PolicyTemplateUsecase) UpdatePermittedOrganizationsForList(ctx context.Context,
func (u *PolicyTemplateUsecase) FillPermittedOrganizationsForList(ctx context.Context,
policyTemplates *[]model.PolicyTemplate, outs *[]domain.PolicyTemplateResponse) error {

organizations, err := u.organizationRepo.Fetch(ctx, nil)
Expand Down
Loading