// ListPolicies lists policies stored by IAM Zero.
// If the `status` query parameter is passed only policies matching the status
// will be returned
ListPolicies lists policies stored by IAM Zero.
If the `status` query parameter is passed only policies matching the status
will be returned
// ListPolicies lists policies stored by IAM Zero . // If the ` status ` query parameter is passed only policies matching the status // will be returned
func (h *Handlers) ListPolicies(w http.ResponseWriter, r *http.Request) {
	ctx := r.Context()
	status := r.URL.Query().Get("status")
	var policies []recommendations.Policy
	if status != "" {
		if ok := recommendations.PolicyStatusIsValid(status); !ok {
			http.Error(w, "policy status must be 'active' or 'resolved'", http.StatusBadRequest)
			return
		}
		policies = h.PolicyStorage.ListForStatus(status)
	} else {
		policies = h.PolicyStorage.List()
	}
	io.RespondJSON(ctx, h.Log, w, policies, http.StatusOK)
}
func ( h * Handlers ) ListPolicies ( w http . ResponseWriter , r * http . Request ) { ctx := r . Context ( ) status := r . URL . Query ( ) . Get ( " " ) var policies [ ] recommendations . Policy if status != " " { if ok := recommendations . PolicyStatusIsValid ( status ) ; ! ok { http . Error ( w , " " , http . StatusBadRequest ) return } policies = h . PolicyStorage . ListForStatus ( status ) } else { policies = h . PolicyStorage . List ( ) } io . RespondJSON ( ctx , h . Log , w , policies , http . StatusOK ) }
ListPolicies lists policies stored by IAM Zero.
ListPolicies lists policies stored by IAM Zero .