Committed by
Gerrit Code Review
Add Swagger comments and dependencies to appsm with REST APIs
ONOS-2704 and ONOS-2705 Change-Id: I77655af94f8b5aba647a94b3b786a6de8a285d7c
Showing
7 changed files
with
131 additions
and
6 deletions
... | @@ -42,6 +42,11 @@ public class FabricWebResource extends AbstractWebResource { | ... | @@ -42,6 +42,11 @@ public class FabricWebResource extends AbstractWebResource { |
42 | 42 | ||
43 | private static final FabricVlanCodec VLAN_CODEC = new FabricVlanCodec(); | 43 | private static final FabricVlanCodec VLAN_CODEC = new FabricVlanCodec(); |
44 | 44 | ||
45 | + /** | ||
46 | + * Get all CORD fabric VLANs. | ||
47 | + * | ||
48 | + * @return array of cord VLANs in the system. | ||
49 | + */ | ||
45 | @GET | 50 | @GET |
46 | @Produces(MediaType.APPLICATION_JSON) | 51 | @Produces(MediaType.APPLICATION_JSON) |
47 | public Response getVlans() { | 52 | public Response getVlans() { |
... | @@ -53,6 +58,14 @@ public class FabricWebResource extends AbstractWebResource { | ... | @@ -53,6 +58,14 @@ public class FabricWebResource extends AbstractWebResource { |
53 | return ok(result.toString()).build(); | 58 | return ok(result.toString()).build(); |
54 | } | 59 | } |
55 | 60 | ||
61 | + /** | ||
62 | + * Create a CORD fabric VLAN. | ||
63 | + * | ||
64 | + * @param input JSON stream describing new VLAN | ||
65 | + * @return status of the request - CREATED if the JSON is correct, | ||
66 | + * INTERNAL_SERVER_ERROR if the JSON is invalid | ||
67 | + * @throws IOException if the JSON is invalid | ||
68 | + */ | ||
56 | @POST | 69 | @POST |
57 | @Path("add") | 70 | @Path("add") |
58 | @Consumes(MediaType.APPLICATION_JSON) | 71 | @Consumes(MediaType.APPLICATION_JSON) |
... | @@ -66,9 +79,15 @@ public class FabricWebResource extends AbstractWebResource { | ... | @@ -66,9 +79,15 @@ public class FabricWebResource extends AbstractWebResource { |
66 | return Response.ok().build(); | 79 | return Response.ok().build(); |
67 | } | 80 | } |
68 | 81 | ||
82 | + /** | ||
83 | + * Delete a CORD fabric VLAN. | ||
84 | + * | ||
85 | + * @param vlan identifier of the VLAN to remove | ||
86 | + * @return status of the request - OK | ||
87 | + */ | ||
69 | @DELETE | 88 | @DELETE |
70 | @Path("{vlan}") | 89 | @Path("{vlan}") |
71 | - public Response deleteVlan(@PathParam("vlan") String vlan) throws IOException { | 90 | + public Response deleteVlan(@PathParam("vlan") String vlan) { |
72 | VlanId vlanId = VlanId.vlanId(Short.parseShort(vlan)); | 91 | VlanId vlanId = VlanId.vlanId(Short.parseShort(vlan)); |
73 | 92 | ||
74 | FabricService fabricService = get(FabricService.class); | 93 | FabricService fabricService = get(FabricService.class); | ... | ... |
... | @@ -34,11 +34,20 @@ import java.io.IOException; | ... | @@ -34,11 +34,20 @@ import java.io.IOException; |
34 | import java.io.InputStream; | 34 | import java.io.InputStream; |
35 | import java.util.List; | 35 | import java.util.List; |
36 | 36 | ||
37 | +/** | ||
38 | + * Query, create and remove segment routing plicies. | ||
39 | + */ | ||
37 | @Path("policy") | 40 | @Path("policy") |
38 | public class PolicyWebResource extends AbstractWebResource { | 41 | public class PolicyWebResource extends AbstractWebResource { |
39 | 42 | ||
40 | private static final PolicyCodec POLICY_CODEC = new PolicyCodec(); | 43 | private static final PolicyCodec POLICY_CODEC = new PolicyCodec(); |
41 | 44 | ||
45 | + /** | ||
46 | + * Get all segment routing policies. | ||
47 | + * Returns an array of segment routing policies. | ||
48 | + * | ||
49 | + * @return status of OK | ||
50 | + */ | ||
42 | @GET | 51 | @GET |
43 | @Produces(MediaType.APPLICATION_JSON) | 52 | @Produces(MediaType.APPLICATION_JSON) |
44 | public Response getPolicy() { | 53 | public Response getPolicy() { |
... | @@ -50,6 +59,14 @@ public class PolicyWebResource extends AbstractWebResource { | ... | @@ -50,6 +59,14 @@ public class PolicyWebResource extends AbstractWebResource { |
50 | return ok(result.toString()).build(); | 59 | return ok(result.toString()).build(); |
51 | } | 60 | } |
52 | 61 | ||
62 | + /** | ||
63 | + * Create a new segment routing policy. | ||
64 | + * | ||
65 | + * @param input JSON stream for policy to create | ||
66 | + * @return status of the request - OK if the policy is created, | ||
67 | + * INTERNAL_SERVER_ERROR if the JSON is invalid or the policy cannot be created | ||
68 | + * @throws IOException | ||
69 | + */ | ||
53 | @POST | 70 | @POST |
54 | @Consumes(MediaType.APPLICATION_JSON) | 71 | @Consumes(MediaType.APPLICATION_JSON) |
55 | public Response createPolicy(InputStream input) throws IOException { | 72 | public Response createPolicy(InputStream input) throws IOException { |
... | @@ -66,6 +83,14 @@ public class PolicyWebResource extends AbstractWebResource { | ... | @@ -66,6 +83,14 @@ public class PolicyWebResource extends AbstractWebResource { |
66 | } | 83 | } |
67 | } | 84 | } |
68 | 85 | ||
86 | + /** | ||
87 | + * Delete a segment routing policy. | ||
88 | + * | ||
89 | + * @param input JSON stream for policy to delete | ||
90 | + * @return status of the request - OK if the policy is removed, | ||
91 | + * INTERNAL_SERVER_ERROR otherwise | ||
92 | + * @throws IOException if JSON is invalid | ||
93 | + */ | ||
69 | @DELETE | 94 | @DELETE |
70 | @Consumes(MediaType.APPLICATION_JSON) | 95 | @Consumes(MediaType.APPLICATION_JSON) |
71 | public Response removePolicy(InputStream input) throws IOException { | 96 | public Response removePolicy(InputStream input) throws IOException { | ... | ... |
... | @@ -34,11 +34,20 @@ import java.io.IOException; | ... | @@ -34,11 +34,20 @@ import java.io.IOException; |
34 | import java.io.InputStream; | 34 | import java.io.InputStream; |
35 | import java.util.List; | 35 | import java.util.List; |
36 | 36 | ||
37 | +/** | ||
38 | + * Query, create and remove segment routing tunnels. | ||
39 | + */ | ||
37 | @Path("tunnel") | 40 | @Path("tunnel") |
38 | public class TunnelWebResource extends AbstractWebResource { | 41 | public class TunnelWebResource extends AbstractWebResource { |
39 | 42 | ||
40 | private static final TunnelCodec TUNNEL_CODEC = new TunnelCodec(); | 43 | private static final TunnelCodec TUNNEL_CODEC = new TunnelCodec(); |
41 | 44 | ||
45 | + /** | ||
46 | + * Get all segment routing tunnels. | ||
47 | + * Returns an array of segment routing tunnels. | ||
48 | + * | ||
49 | + * @return status of OK | ||
50 | + */ | ||
42 | @GET | 51 | @GET |
43 | @Produces(MediaType.APPLICATION_JSON) | 52 | @Produces(MediaType.APPLICATION_JSON) |
44 | public Response getTunnel() { | 53 | public Response getTunnel() { |
... | @@ -50,6 +59,14 @@ public class TunnelWebResource extends AbstractWebResource { | ... | @@ -50,6 +59,14 @@ public class TunnelWebResource extends AbstractWebResource { |
50 | return ok(result.toString()).build(); | 59 | return ok(result.toString()).build(); |
51 | } | 60 | } |
52 | 61 | ||
62 | + /** | ||
63 | + * Create a new segment routing tunnel. | ||
64 | + * | ||
65 | + * @param input JSON stream for tunnel to create | ||
66 | + * @return status of the request - OK if the tunnel is created, | ||
67 | + * INTERNAL_SERVER_ERROR if the JSON is invalid or the tunnel cannot be created | ||
68 | + * @throws IOException if the JSON is invalid | ||
69 | + */ | ||
53 | @POST | 70 | @POST |
54 | @Consumes(MediaType.APPLICATION_JSON) | 71 | @Consumes(MediaType.APPLICATION_JSON) |
55 | public Response createTunnel(InputStream input) throws IOException { | 72 | public Response createTunnel(InputStream input) throws IOException { |
... | @@ -62,6 +79,14 @@ public class TunnelWebResource extends AbstractWebResource { | ... | @@ -62,6 +79,14 @@ public class TunnelWebResource extends AbstractWebResource { |
62 | return Response.ok().build(); | 79 | return Response.ok().build(); |
63 | } | 80 | } |
64 | 81 | ||
82 | + /** | ||
83 | + * Delete a segment routing tunnel. | ||
84 | + * | ||
85 | + * @param input JSON stream for tunnel to delete | ||
86 | + * @return status of the request - OK if the tunnel is removed, | ||
87 | + * INTERNAL_SERVER_ERROR otherwise | ||
88 | + * @throws IOException if JSON is invalid | ||
89 | + */ | ||
65 | @DELETE | 90 | @DELETE |
66 | @Consumes(MediaType.APPLICATION_JSON) | 91 | @Consumes(MediaType.APPLICATION_JSON) |
67 | public Response removeTunnel(InputStream input) throws IOException { | 92 | public Response removeTunnel(InputStream input) throws IOException { | ... | ... |
... | @@ -34,6 +34,11 @@ | ... | @@ -34,6 +34,11 @@ |
34 | <properties> | 34 | <properties> |
35 | <onos.app.name>org.onosproject.demo</onos.app.name> | 35 | <onos.app.name>org.onosproject.demo</onos.app.name> |
36 | <web.context>/onos/demo</web.context> | 36 | <web.context>/onos/demo</web.context> |
37 | + <api.title>ONOS Flow Throughput Test App API</api.title> | ||
38 | + <api.description> | ||
39 | + APIs for interacting with the flow throughput test application. | ||
40 | + </api.description> | ||
41 | + <api.package>org.onosproject.demo</api.package> | ||
37 | </properties> | 42 | </properties> |
38 | 43 | ||
39 | <dependencies> | 44 | <dependencies> |
... | @@ -82,6 +87,10 @@ | ... | @@ -82,6 +87,10 @@ |
82 | <configuration> | 87 | <configuration> |
83 | <instructions> | 88 | <instructions> |
84 | <_wab>src/main/webapp/</_wab> | 89 | <_wab>src/main/webapp/</_wab> |
90 | + <Include-Resource> | ||
91 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
92 | + {maven-resources} | ||
93 | + </Include-Resource> | ||
85 | <Bundle-SymbolicName> | 94 | <Bundle-SymbolicName> |
86 | ${project.groupId}.${project.artifactId} | 95 | ${project.groupId}.${project.artifactId} |
87 | </Bundle-SymbolicName> | 96 | </Bundle-SymbolicName> | ... | ... |
... | @@ -37,7 +37,13 @@ import java.util.Optional; | ... | @@ -37,7 +37,13 @@ import java.util.Optional; |
37 | public class DemoResource extends BaseResource { | 37 | public class DemoResource extends BaseResource { |
38 | 38 | ||
39 | 39 | ||
40 | - | 40 | + /** |
41 | + * Start the flow test. | ||
42 | + * | ||
43 | + * @param input JSON describing how to run the flow test | ||
44 | + * @return response code OK | ||
45 | + * @throws IOException if the JSON processing fails | ||
46 | + */ | ||
41 | @POST | 47 | @POST |
42 | @Path("flowTest") | 48 | @Path("flowTest") |
43 | @Consumes(MediaType.APPLICATION_JSON) | 49 | @Consumes(MediaType.APPLICATION_JSON) |
... | @@ -49,6 +55,13 @@ public class DemoResource extends BaseResource { | ... | @@ -49,6 +55,13 @@ public class DemoResource extends BaseResource { |
49 | return Response.ok(demo.flowTest(Optional.ofNullable(cfg)).toString()).build(); | 55 | return Response.ok(demo.flowTest(Optional.ofNullable(cfg)).toString()).build(); |
50 | } | 56 | } |
51 | 57 | ||
58 | + /** | ||
59 | + * Set up the flow test. | ||
60 | + * | ||
61 | + * @param input JSON describing how to configure the flow test | ||
62 | + * @return response code OK | ||
63 | + * @throws IOException if the JSON processing fails | ||
64 | + */ | ||
52 | @POST | 65 | @POST |
53 | @Path("setup") | 66 | @Path("setup") |
54 | @Consumes(MediaType.APPLICATION_JSON) | 67 | @Consumes(MediaType.APPLICATION_JSON) |
... | @@ -70,10 +83,15 @@ public class DemoResource extends BaseResource { | ... | @@ -70,10 +83,15 @@ public class DemoResource extends BaseResource { |
70 | return Response.ok(mapper.createObjectNode().toString()).build(); | 83 | return Response.ok(mapper.createObjectNode().toString()).build(); |
71 | } | 84 | } |
72 | 85 | ||
86 | + /** | ||
87 | + * Tear down the flow test. | ||
88 | + * | ||
89 | + * @return response code OK | ||
90 | + */ | ||
73 | @GET | 91 | @GET |
74 | @Path("teardown") | 92 | @Path("teardown") |
75 | @Produces(MediaType.APPLICATION_JSON) | 93 | @Produces(MediaType.APPLICATION_JSON) |
76 | - public Response tearDown() throws IOException { | 94 | + public Response tearDown() { |
77 | ObjectMapper mapper = new ObjectMapper(); | 95 | ObjectMapper mapper = new ObjectMapper(); |
78 | DemoAPI demo = get(DemoAPI.class); | 96 | DemoAPI demo = get(DemoAPI.class); |
79 | demo.tearDown(); | 97 | demo.tearDown(); | ... | ... |
... | @@ -34,6 +34,12 @@ | ... | @@ -34,6 +34,12 @@ |
34 | <properties> | 34 | <properties> |
35 | <onos.app.name>org.onosproject.virtualbng</onos.app.name> | 35 | <onos.app.name>org.onosproject.virtualbng</onos.app.name> |
36 | <web.context>/onos/virtualbng</web.context> | 36 | <web.context>/onos/virtualbng</web.context> |
37 | + <api.version>1.0.0</api.version> | ||
38 | + <api.title>ONOS Virtual BNG Gateway REST API</api.title> | ||
39 | + <api.description> | ||
40 | + APIs for interacting with the Virtual Broadband Network Gateway (BNG) application. | ||
41 | + </api.description> | ||
42 | + <api.package>org.onosproject.virtualbng</api.package> | ||
37 | </properties> | 43 | </properties> |
38 | 44 | ||
39 | <dependencies> | 45 | <dependencies> |
... | @@ -72,6 +78,10 @@ | ... | @@ -72,6 +78,10 @@ |
72 | <configuration> | 78 | <configuration> |
73 | <instructions> | 79 | <instructions> |
74 | <_wab>src/main/webapp/</_wab> | 80 | <_wab>src/main/webapp/</_wab> |
81 | + <Include-Resource> | ||
82 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
83 | + {maven-resources} | ||
84 | + </Include-Resource> | ||
75 | <Bundle-SymbolicName> | 85 | <Bundle-SymbolicName> |
76 | ${project.groupId}.${project.artifactId} | 86 | ${project.groupId}.${project.artifactId} |
77 | </Bundle-SymbolicName> | 87 | </Bundle-SymbolicName> |
... | @@ -98,4 +108,4 @@ | ... | @@ -98,4 +108,4 @@ |
98 | </plugins> | 108 | </plugins> |
99 | </build> | 109 | </build> |
100 | 110 | ||
101 | -</project> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
111 | +</project> | ... | ... |
... | @@ -37,13 +37,21 @@ import org.onosproject.rest.AbstractWebResource; | ... | @@ -37,13 +37,21 @@ import org.onosproject.rest.AbstractWebResource; |
37 | import org.slf4j.Logger; | 37 | import org.slf4j.Logger; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * This class provides REST services to virtual BNG. | 40 | + * REST services to interact with the virtual BNG. |
41 | */ | 41 | */ |
42 | @Path("privateip") | 42 | @Path("privateip") |
43 | public class VbngResource extends AbstractWebResource { | 43 | public class VbngResource extends AbstractWebResource { |
44 | 44 | ||
45 | private final Logger log = getLogger(getClass()); | 45 | private final Logger log = getLogger(getClass()); |
46 | 46 | ||
47 | + /** | ||
48 | + * Create a new virtual BNG connection. | ||
49 | + * | ||
50 | + * @param privateIp IP Address for the BNG private network | ||
51 | + * @param mac MAC address for the host | ||
52 | + * @param hostName name of the host | ||
53 | + * @return public IP address for the new connection | ||
54 | + */ | ||
47 | @POST | 55 | @POST |
48 | @Path("{privateip}/{mac}/{hostname}") | 56 | @Path("{privateip}/{mac}/{hostname}") |
49 | public String privateIpAddNotification(@PathParam("privateip") | 57 | public String privateIpAddNotification(@PathParam("privateip") |
... | @@ -77,6 +85,12 @@ public class VbngResource extends AbstractWebResource { | ... | @@ -77,6 +85,12 @@ public class VbngResource extends AbstractWebResource { |
77 | } | 85 | } |
78 | } | 86 | } |
79 | 87 | ||
88 | + /** | ||
89 | + * Delete a virtual BNG connection. | ||
90 | + * | ||
91 | + * @param privateIp IP Address for the BNG private network | ||
92 | + * @return public IP address for the new connection | ||
93 | + */ | ||
80 | @DELETE | 94 | @DELETE |
81 | @Path("{privateip}") | 95 | @Path("{privateip}") |
82 | public String privateIpDeleteNotification(@PathParam("privateip") | 96 | public String privateIpDeleteNotification(@PathParam("privateip") |
... | @@ -101,6 +115,11 @@ public class VbngResource extends AbstractWebResource { | ... | @@ -101,6 +115,11 @@ public class VbngResource extends AbstractWebResource { |
101 | } | 115 | } |
102 | } | 116 | } |
103 | 117 | ||
118 | + /** | ||
119 | + * Query virtual BNG map. | ||
120 | + * | ||
121 | + * @return IP Address map | ||
122 | + */ | ||
104 | @GET | 123 | @GET |
105 | @Path("map") | 124 | @Path("map") |
106 | @Produces(MediaType.APPLICATION_JSON) | 125 | @Produces(MediaType.APPLICATION_JSON) |
... | @@ -119,4 +138,4 @@ public class VbngResource extends AbstractWebResource { | ... | @@ -119,4 +138,4 @@ public class VbngResource extends AbstractWebResource { |
119 | 138 | ||
120 | return ok(result.toString()).build(); | 139 | return ok(result.toString()).build(); |
121 | } | 140 | } |
122 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
141 | +} | ... | ... |
-
Please register or login to post a comment