// FindPolicy finds a policy by its role and status
FindPolicy finds a policy by its role and status
// FindPolicy finds a policy by its role and status
func (h *Handlers) FindPolicy(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	role := r.URL.Query().Get("role")
	status := r.URL.Query().Get("status")
	if role == "" || status == "" {
		http.Error(w, "role and status must be provided as query parameters", http.StatusBadRequest)
		return
	}
	policy := h.PolicyStorage.FindByRole(storage.FindByRoleQuery{Role: role, Status: status})
	if policy == nil {
		http.Error(w, "policy not found", http.StatusNotFound)
	} else {
		io.RespondJSON(ctx, h.Log, w, policy, http.StatusOK)
	}
}
func ( h * Handlers ) FindPolicy ( w http . ResponseWriter , r * http . Request ) { ctx := r . Context ( ) role := r . URL . Query ( ) . Get ( " " ) status := r . URL . Query ( ) . Get ( " " ) if role == " " || status == " " { http . Error ( w , " " , http . StatusBadRequest ) return } policy := h . PolicyStorage . FindByRole ( storage . FindByRoleQuery { Role : role , Status : status } ) if policy == nil { http . Error ( w , " " , http . StatusNotFound ) } else { io . RespondJSON ( ctx , h . Log , w , policy , http . StatusOK ) } }
FindPolicy finds a policy by its role and status
FindPolicy finds a policy by its role and status