Search in sources :

Example 6 with DropPolicy

use of org.onosproject.segmentrouting.policy.api.DropPolicy in project trellis-control by opennetworkinglab.

the class PolicyWebResource method getDropPolicies.

/**
 * Get all Drop Policies.
 *
 * @return 200 OK will a collection of Dop Policies
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("drop")
public Response getDropPolicies() {
    PolicyService policyService = get(PolicyService.class);
    ObjectNode root = mapper().createObjectNode();
    ArrayNode policiesArr = root.putArray(POLICY);
    Set<PolicyType> policyTypes = Set.of(PolicyType.DROP);
    for (PolicyData policyData : policyService.policies(policyTypes)) {
        Policy policy = policyData.policy();
        policiesArr.add(codec(DropPolicy.class).encode((DropPolicy) policy, this));
    }
    return Response.ok(root).build();
}
Also used : DropPolicy(org.onosproject.segmentrouting.policy.api.DropPolicy) Policy(org.onosproject.segmentrouting.policy.api.Policy) RedirectPolicy(org.onosproject.segmentrouting.policy.api.RedirectPolicy) PolicyType(org.onosproject.segmentrouting.policy.api.Policy.PolicyType) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) PolicyService(org.onosproject.segmentrouting.policy.api.PolicyService) PolicyData(org.onosproject.segmentrouting.policy.api.PolicyData) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) DropPolicy(org.onosproject.segmentrouting.policy.api.DropPolicy) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

DropPolicy (org.onosproject.segmentrouting.policy.api.DropPolicy)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 PolicyService (org.onosproject.segmentrouting.policy.api.PolicyService)4 Produces (javax.ws.rs.Produces)3 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Policy (org.onosproject.segmentrouting.policy.api.Policy)2 PolicyType (org.onosproject.segmentrouting.policy.api.Policy.PolicyType)2 PolicyData (org.onosproject.segmentrouting.policy.api.PolicyData)2 RedirectPolicy (org.onosproject.segmentrouting.policy.api.RedirectPolicy)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 InputStream (java.io.InputStream)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Before (org.junit.Before)1 Test (org.junit.Test)1 MockCodecContext (org.onosproject.codec.impl.MockCodecContext)1 PolicyId (org.onosproject.segmentrouting.policy.api.PolicyId)1