mirror of
https://github.com/kopia/kopia.git
synced 2026-03-13 19:57:27 -04:00
33 lines
639 B
Go
33 lines
639 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/kopia/kopia/internal/serverapi"
|
|
)
|
|
|
|
func (s *Server) handlePolicyList(r *http.Request) (interface{}, *apiError) {
|
|
policies, err := s.policyManager.ListPolicies()
|
|
if err != nil {
|
|
return nil, internalServerError(err)
|
|
}
|
|
|
|
resp := &serverapi.PoliciesResponse{
|
|
Policies: []*serverapi.PolicyListEntry{},
|
|
}
|
|
|
|
for _, pol := range policies {
|
|
target := pol.Target()
|
|
if !sourceMatchesURLFilter(target, r.URL.Query()) {
|
|
continue
|
|
}
|
|
resp.Policies = append(resp.Policies, &serverapi.PolicyListEntry{
|
|
ID: pol.ID(),
|
|
Target: target,
|
|
Policy: pol,
|
|
})
|
|
}
|
|
|
|
return resp, nil
|
|
}
|