Committed by
Gerrit Code Review
ONOS-2486 Adding swagger-based REST API documentation.
Change-Id: I237d973d73549ad30ddc638c1c201f024d344c70
Showing
52 changed files
with
1446 additions
and
203 deletions
... | @@ -39,7 +39,13 @@ | ... | @@ -39,7 +39,13 @@ |
39 | <onos.version>1.3.0-SNAPSHOT</onos.version> | 39 | <onos.version>1.3.0-SNAPSHOT</onos.version> |
40 | <onos.app.name>org.onosproject.acl</onos.app.name> | 40 | <onos.app.name>org.onosproject.acl</onos.app.name> |
41 | <onos.app.origin>DLUT</onos.app.origin> | 41 | <onos.app.origin>DLUT</onos.app.origin> |
42 | - <web.context>/onos/v1/acl</web.context> | 42 | + <web.context>/onos/acl</web.context> |
43 | + <api.version>1.0.0</api.version> | ||
44 | + <api.title>ONOS ACL Application REST API</api.title> | ||
45 | + <api.description> | ||
46 | + APIs for interacting with the ACL application. | ||
47 | + </api.description> | ||
48 | + <api.package>org.onos.acl.impl</api.package> | ||
43 | </properties> | 49 | </properties> |
44 | 50 | ||
45 | <dependencies> | 51 | <dependencies> |
... | @@ -108,6 +114,10 @@ | ... | @@ -108,6 +114,10 @@ |
108 | <configuration> | 114 | <configuration> |
109 | <instructions> | 115 | <instructions> |
110 | <_wab>src/main/webapp/</_wab> | 116 | <_wab>src/main/webapp/</_wab> |
117 | + <Include-Resource> | ||
118 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
119 | + {maven-resources} | ||
120 | + </Include-Resource> | ||
111 | <Bundle-SymbolicName> | 121 | <Bundle-SymbolicName> |
112 | ${project.groupId}.${project.artifactId} | 122 | ${project.groupId}.${project.artifactId} |
113 | </Bundle-SymbolicName> | 123 | </Bundle-SymbolicName> | ... | ... |
... | @@ -40,8 +40,9 @@ import java.io.IOException; | ... | @@ -40,8 +40,9 @@ import java.io.IOException; |
40 | import java.io.InputStream; | 40 | import java.io.InputStream; |
41 | import java.util.List; | 41 | import java.util.List; |
42 | 42 | ||
43 | +// FIXME: This does now follow REST-full principles and should be refactored. | ||
43 | /** | 44 | /** |
44 | - * REST resource for interacting with ACL application. | 45 | + * Manage ACL rules. |
45 | */ | 46 | */ |
46 | @Path("") | 47 | @Path("") |
47 | public class AclWebResource extends AbstractWebResource { | 48 | public class AclWebResource extends AbstractWebResource { | ... | ... |
... | @@ -33,6 +33,12 @@ | ... | @@ -33,6 +33,12 @@ |
33 | <properties> | 33 | <properties> |
34 | <onos.app.name>org.onosproject.cordfabric</onos.app.name> | 34 | <onos.app.name>org.onosproject.cordfabric</onos.app.name> |
35 | <web.context>/onos/cordfabric</web.context> | 35 | <web.context>/onos/cordfabric</web.context> |
36 | + <api.version>1.0.0</api.version> | ||
37 | + <api.title>ONOS CORD Fabric REST API</api.title> | ||
38 | + <api.description> | ||
39 | + APIs for interacting with the CORD Fabric application. | ||
40 | + </api.description> | ||
41 | + <api.package>org.onosproject.cordfabric</api.package> | ||
36 | </properties> | 42 | </properties> |
37 | 43 | ||
38 | <dependencies> | 44 | <dependencies> |
... | @@ -94,6 +100,10 @@ | ... | @@ -94,6 +100,10 @@ |
94 | <configuration> | 100 | <configuration> |
95 | <instructions> | 101 | <instructions> |
96 | <_wab>src/main/webapp/</_wab> | 102 | <_wab>src/main/webapp/</_wab> |
103 | + <Include-Resource> | ||
104 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
105 | + {maven-resources} | ||
106 | + </Include-Resource> | ||
97 | <Bundle-SymbolicName> | 107 | <Bundle-SymbolicName> |
98 | ${project.groupId}.${project.artifactId} | 108 | ${project.groupId}.${project.artifactId} |
99 | </Bundle-SymbolicName> | 109 | </Bundle-SymbolicName> | ... | ... |
... | @@ -33,6 +33,12 @@ | ... | @@ -33,6 +33,12 @@ |
33 | <properties> | 33 | <properties> |
34 | <onos.app.name>org.onosproject.segmentrouting</onos.app.name> | 34 | <onos.app.name>org.onosproject.segmentrouting</onos.app.name> |
35 | <web.context>/onos/segmentrouting</web.context> | 35 | <web.context>/onos/segmentrouting</web.context> |
36 | + <api.version>1.0.0</api.version> | ||
37 | + <api.title>ONOS Segment Routing REST API</api.title> | ||
38 | + <api.description> | ||
39 | + APIs for interacting with the Segment Routing application. | ||
40 | + </api.description> | ||
41 | + <api.package>org.onosproject.segmentrouting.web</api.package> | ||
36 | </properties> | 42 | </properties> |
37 | 43 | ||
38 | <dependencies> | 44 | <dependencies> |
... | @@ -94,6 +100,10 @@ | ... | @@ -94,6 +100,10 @@ |
94 | <configuration> | 100 | <configuration> |
95 | <instructions> | 101 | <instructions> |
96 | <_wab>src/main/webapp/</_wab> | 102 | <_wab>src/main/webapp/</_wab> |
103 | + <Include-Resource> | ||
104 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
105 | + {maven-resources} | ||
106 | + </Include-Resource> | ||
97 | <Bundle-SymbolicName> | 107 | <Bundle-SymbolicName> |
98 | ${project.groupId}.${project.artifactId} | 108 | ${project.groupId}.${project.artifactId} |
99 | </Bundle-SymbolicName> | 109 | </Bundle-SymbolicName> | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.rest; | ||
17 | + | ||
18 | +import org.apache.felix.scr.annotations.Activate; | ||
19 | +import org.apache.felix.scr.annotations.Component; | ||
20 | +import org.apache.felix.scr.annotations.Deactivate; | ||
21 | +import org.apache.felix.scr.annotations.Reference; | ||
22 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
23 | + | ||
24 | +/** | ||
25 | + * Self-registering REST API provider. | ||
26 | + */ | ||
27 | +@Component(immediate = true, componentAbstract = true) | ||
28 | +public abstract class AbstractApiDocRegistrator { | ||
29 | + | ||
30 | + protected final ApiDocProvider provider; | ||
31 | + | ||
32 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
33 | + protected ApiDocService service; | ||
34 | + | ||
35 | + /** | ||
36 | + * Creates registrator for the specified REST API doc provider. | ||
37 | + * | ||
38 | + * @param provider REST API provider | ||
39 | + */ | ||
40 | + protected AbstractApiDocRegistrator(ApiDocProvider provider) { | ||
41 | + this.provider = provider; | ||
42 | + } | ||
43 | + | ||
44 | + @Activate | ||
45 | + protected void activate() { | ||
46 | + service.register(provider); | ||
47 | + } | ||
48 | + | ||
49 | + @Deactivate | ||
50 | + protected void deactivate() { | ||
51 | + service.unregister(provider); | ||
52 | + } | ||
53 | +} |
... | @@ -13,9 +13,7 @@ | ... | @@ -13,9 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.ui.impl; | 16 | +package org.onosproject.rest; |
17 | - | ||
18 | -import org.onlab.rest.BaseResource; | ||
19 | 17 | ||
20 | import java.io.ByteArrayInputStream; | 18 | import java.io.ByteArrayInputStream; |
21 | import java.io.InputStream; | 19 | import java.io.InputStream; |
... | @@ -28,7 +26,7 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -28,7 +26,7 @@ import static com.google.common.base.Preconditions.checkArgument; |
28 | /** | 26 | /** |
29 | * Resource for serving semi-static resources. | 27 | * Resource for serving semi-static resources. |
30 | */ | 28 | */ |
31 | -public class AbstractInjectionResource extends BaseResource { | 29 | +public class AbstractInjectionResource extends AbstractWebResource { |
32 | 30 | ||
33 | /** | 31 | /** |
34 | * Returns the index into the supplied string where the end of the | 32 | * Returns the index into the supplied string where the end of the |
... | @@ -63,7 +61,7 @@ public class AbstractInjectionResource extends BaseResource { | ... | @@ -63,7 +61,7 @@ public class AbstractInjectionResource extends BaseResource { |
63 | protected class StreamEnumeration implements Enumeration<InputStream> { | 61 | protected class StreamEnumeration implements Enumeration<InputStream> { |
64 | private final Iterator<InputStream> iterator; | 62 | private final Iterator<InputStream> iterator; |
65 | 63 | ||
66 | - StreamEnumeration(List<InputStream> streams) { | 64 | + public StreamEnumeration(List<InputStream> streams) { |
67 | this.iterator = streams.iterator(); | 65 | this.iterator = streams.iterator(); |
68 | } | 66 | } |
69 | 67 | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.rest; | ||
17 | + | ||
18 | +import com.google.common.annotations.Beta; | ||
19 | +import org.slf4j.Logger; | ||
20 | +import org.slf4j.LoggerFactory; | ||
21 | + | ||
22 | +import java.io.InputStream; | ||
23 | + | ||
24 | +import static com.google.common.base.Preconditions.checkNotNull; | ||
25 | + | ||
26 | +/** | ||
27 | + * Entity capable of providing REST API documentation resources. | ||
28 | + */ | ||
29 | +@Beta | ||
30 | +public class ApiDocProvider { | ||
31 | + | ||
32 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
33 | + | ||
34 | + private static final String DOCS = "/apidoc/swagger.json"; | ||
35 | + private static final String MODEL = "/apidoc/model.json"; | ||
36 | + | ||
37 | + private final String key; | ||
38 | + private final String name; | ||
39 | + private final ClassLoader classLoader; | ||
40 | + | ||
41 | + /** | ||
42 | + * Creates a new REST API documentation provider. | ||
43 | + * | ||
44 | + * @param key REST API key | ||
45 | + * @param name REST API name | ||
46 | + * @param classLoader class loader | ||
47 | + */ | ||
48 | + public ApiDocProvider(String key, String name, ClassLoader classLoader) { | ||
49 | + this.key = checkNotNull(key, "Key cannot be null"); | ||
50 | + this.name = checkNotNull(name, "Name cannot be null"); | ||
51 | + this.classLoader = checkNotNull(classLoader, "Class loader cannot be null"); | ||
52 | + } | ||
53 | + | ||
54 | + /** | ||
55 | + * Returns the REST API key. | ||
56 | + * | ||
57 | + * @return REST API key | ||
58 | + */ | ||
59 | + public String key() { | ||
60 | + return key; | ||
61 | + } | ||
62 | + | ||
63 | + /** | ||
64 | + * Returns the REST API name. | ||
65 | + * | ||
66 | + * @return REST API name | ||
67 | + */ | ||
68 | + public String name() { | ||
69 | + return name; | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
73 | + * Returns input stream containing Swagger UI compatible JSON. | ||
74 | + * | ||
75 | + * @return input stream with Swagger JSON data | ||
76 | + */ | ||
77 | + public InputStream docs() { | ||
78 | + return get(DOCS); | ||
79 | + } | ||
80 | + | ||
81 | + /** | ||
82 | + * Returns input stream containing JSON model schema. | ||
83 | + * | ||
84 | + * @return input stream with JSON model schema | ||
85 | + */ | ||
86 | + public InputStream model() { | ||
87 | + return get(MODEL); | ||
88 | + } | ||
89 | + | ||
90 | + private InputStream get(String resource) { | ||
91 | + InputStream stream = classLoader.getResourceAsStream(resource); | ||
92 | + if (stream == null) { | ||
93 | + log.warn("Unable to find JSON resource {}", resource); | ||
94 | + } | ||
95 | + return stream; | ||
96 | + } | ||
97 | + | ||
98 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.rest; | ||
17 | + | ||
18 | +import com.google.common.annotations.Beta; | ||
19 | + | ||
20 | +import java.util.Set; | ||
21 | + | ||
22 | +/** | ||
23 | + * Service for registering REST API documentation resources. | ||
24 | + */ | ||
25 | +@Beta | ||
26 | +public interface ApiDocService { | ||
27 | + | ||
28 | + /** | ||
29 | + * Registers the specified REST API documentation provider. | ||
30 | + * | ||
31 | + * @param provider REST API documentation provider | ||
32 | + */ | ||
33 | + void register(ApiDocProvider provider); | ||
34 | + | ||
35 | + /** | ||
36 | + * Unregisters the specified REST API documentation provider. | ||
37 | + * | ||
38 | + * @param provider REST API documentation provider | ||
39 | + */ | ||
40 | + void unregister(ApiDocProvider provider); | ||
41 | + | ||
42 | + /** | ||
43 | + * Returns the set of all registered REST API documentation providers. | ||
44 | + * | ||
45 | + * @return set of registered documentation providers | ||
46 | + */ | ||
47 | + Set<ApiDocProvider> getDocProviders(); | ||
48 | + | ||
49 | + /** | ||
50 | + * Returns the specified REST API documentation provider with the specified | ||
51 | + * key. | ||
52 | + * | ||
53 | + * @param key REST API key | ||
54 | + * @return documentation provider | ||
55 | + */ | ||
56 | + ApiDocProvider getDocProvider(String key); | ||
57 | + | ||
58 | +} |
... | @@ -30,7 +30,6 @@ | ... | @@ -30,7 +30,6 @@ |
30 | <relativePath>tools/build/pom.xml</relativePath> | 30 | <relativePath>tools/build/pom.xml</relativePath> |
31 | </parent> | 31 | </parent> |
32 | 32 | ||
33 | - <groupId>org.onosproject</groupId> | ||
34 | <artifactId>onos</artifactId> | 33 | <artifactId>onos</artifactId> |
35 | <packaging>pom</packaging> | 34 | <packaging>pom</packaging> |
36 | <version>1.3.0-SNAPSHOT</version> | 35 | <version>1.3.0-SNAPSHOT</version> |
... | @@ -43,18 +42,23 @@ | ... | @@ -43,18 +42,23 @@ |
43 | <module>core</module> | 42 | <module>core</module> |
44 | <module>web</module> | 43 | <module>web</module> |
45 | <module>cli</module> | 44 | <module>cli</module> |
45 | + | ||
46 | + <module>openflow</module> | ||
47 | + <module>ovsdb</module> | ||
48 | + <module>pcep</module> | ||
49 | + | ||
46 | <module>providers</module> | 50 | <module>providers</module> |
47 | <module>drivers</module> | 51 | <module>drivers</module> |
48 | - <module>openflow</module> | 52 | + |
49 | <module>apps</module> | 53 | <module>apps</module> |
50 | <module>incubator</module> | 54 | <module>incubator</module> |
51 | <module>features</module> | 55 | <module>features</module> |
52 | - <module>pcep</module> | 56 | + |
53 | <module>tools/package/archetypes</module> | 57 | <module>tools/package/archetypes</module> |
54 | <module>tools/package/branding</module> | 58 | <module>tools/package/branding</module> |
59 | + | ||
55 | <!-- FIXME remove before release --> | 60 | <!-- FIXME remove before release --> |
56 | <module>tools/package/maven-plugin</module> | 61 | <module>tools/package/maven-plugin</module> |
57 | - <module>ovsdb</module> | ||
58 | </modules> | 62 | </modules> |
59 | 63 | ||
60 | <url>http://onosproject.org/</url> | 64 | <url>http://onosproject.org/</url> |
... | @@ -515,9 +519,11 @@ | ... | @@ -515,9 +519,11 @@ |
515 | <artifactId>maven-surefire-plugin</artifactId> | 519 | <artifactId>maven-surefire-plugin</artifactId> |
516 | <version>2.18.1</version> | 520 | <version>2.18.1</version> |
517 | <configuration> | 521 | <configuration> |
518 | - <redirectTestOutputToFile>true</redirectTestOutputToFile> | 522 | + <redirectTestOutputToFile>true |
523 | + </redirectTestOutputToFile> | ||
519 | <printSummary>true</printSummary> | 524 | <printSummary>true</printSummary> |
520 | - <excludedGroups>org.onlab.junit.IntegrationTest</excludedGroups> | 525 | + <excludedGroups>org.onlab.junit.IntegrationTest |
526 | + </excludedGroups> | ||
521 | <rerunFailingTestsCount>1</rerunFailingTestsCount> | 527 | <rerunFailingTestsCount>1</rerunFailingTestsCount> |
522 | </configuration> | 528 | </configuration> |
523 | </plugin> | 529 | </plugin> |
... | @@ -618,7 +624,7 @@ | ... | @@ -618,7 +624,7 @@ |
618 | </execution> | 624 | </execution> |
619 | <execution> | 625 | <execution> |
620 | <id>swagger</id> | 626 | <id>swagger</id> |
621 | - <phase>generate-resources</phase> | 627 | + <phase>generate-sources</phase> |
622 | <goals> | 628 | <goals> |
623 | <goal>swagger</goal> | 629 | <goal>swagger</goal> |
624 | </goals> | 630 | </goals> | ... | ... |
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * Auto-generated by OnosSwaggerMojo. | ||
3 | + * | ||
4 | + * Copyright 2015 Open Networking Laboratory | ||
5 | + * | ||
6 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
7 | + * you may not use this file except in compliance with the License. | ||
8 | + * You may obtain a copy of the License at | ||
9 | + * | ||
10 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | + * | ||
12 | + * Unless required by applicable law or agreed to in writing, software | ||
13 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
15 | + * See the License for the specific language governing permissions and | ||
16 | + * limitations under the License. | ||
17 | + */ | ||
18 | +package ${api.package}; | ||
19 | + | ||
20 | +import org.apache.felix.scr.annotations.Component; | ||
21 | +import org.onosproject.rest.AbstractApiDocRegistrator; | ||
22 | +import org.onosproject.rest.ApiDocProvider; | ||
23 | + | ||
24 | +@Component(immediate = true) | ||
25 | +public class ApiDocRegistrator extends AbstractApiDocRegistrator { | ||
26 | + public ApiDocRegistrator() { | ||
27 | + super(new ApiDocProvider("${web.context}", | ||
28 | + "${api.title}", | ||
29 | + ApiDocRegistrator.class.getClassLoader())); | ||
30 | + } | ||
31 | +} |
... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
29 | <artifactId>onos-rest</artifactId> | 29 | <artifactId>onos-rest</artifactId> |
30 | <packaging>bundle</packaging> | 30 | <packaging>bundle</packaging> |
31 | 31 | ||
32 | - <description>ONOS REST API</description> | 32 | + <description>ONOS Core REST API</description> |
33 | 33 | ||
34 | <dependencies> | 34 | <dependencies> |
35 | <dependency> | 35 | <dependency> |
... | @@ -57,6 +57,12 @@ | ... | @@ -57,6 +57,12 @@ |
57 | 57 | ||
58 | <properties> | 58 | <properties> |
59 | <web.context>/onos/v1</web.context> | 59 | <web.context>/onos/v1</web.context> |
60 | + <api.version>1.0.0</api.version> | ||
61 | + <api.title>${project.description}</api.title> | ||
62 | + <api.description> | ||
63 | + Core APIs for external interactions with various ONOS subsystems. | ||
64 | + </api.description> | ||
65 | + <api.package>org.onosproject.rest.impl</api.package> | ||
60 | </properties> | 66 | </properties> |
61 | 67 | ||
62 | <build> | 68 | <build> |
... | @@ -65,6 +71,43 @@ | ... | @@ -65,6 +71,43 @@ |
65 | <groupId>org.onosproject</groupId> | 71 | <groupId>org.onosproject</groupId> |
66 | <artifactId>onos-maven-plugin</artifactId> | 72 | <artifactId>onos-maven-plugin</artifactId> |
67 | </plugin> | 73 | </plugin> |
74 | + | ||
75 | + <plugin> | ||
76 | + <groupId>org.apache.felix</groupId> | ||
77 | + <artifactId>maven-bundle-plugin</artifactId> | ||
78 | + <extensions>true</extensions> | ||
79 | + <configuration> | ||
80 | + <instructions> | ||
81 | + <_wab>src/main/webapp/</_wab> | ||
82 | + <Include-Resource> | ||
83 | + WEB-INF/classes/apidoc/swagger.json=target/swagger.json, | ||
84 | + {maven-resources} | ||
85 | + </Include-Resource> | ||
86 | + <Bundle-SymbolicName> | ||
87 | + ${project.groupId}.${project.artifactId} | ||
88 | + </Bundle-SymbolicName> | ||
89 | + <Import-Package> | ||
90 | + org.slf4j, | ||
91 | + org.osgi.framework, | ||
92 | + javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext, | ||
93 | + com.sun.jersey.api, | ||
94 | + com.sun.jersey.spi.container.servlet, | ||
95 | + com.sun.jersey.server.impl.container.servlet, | ||
96 | + com.fasterxml.jackson.databind, | ||
97 | + com.fasterxml.jackson.databind.node, | ||
98 | + com.google.common.base.*, | ||
99 | + com.google.common.collect.*, | ||
100 | + com.google.common.io.*, | ||
101 | + org.onlab.util.*, | ||
102 | + org.onlab.osgi.*, | ||
103 | + org.onlab.packet.*, | ||
104 | + org.onlab.rest.*, | ||
105 | + org.onosproject.* | ||
106 | + </Import-Package> | ||
107 | + <Web-ContextPath>${web.context}</Web-ContextPath> | ||
108 | + </instructions> | ||
109 | + </configuration> | ||
110 | + </plugin> | ||
68 | </plugins> | 111 | </plugins> |
69 | </build> | 112 | </build> |
70 | 113 | ... | ... |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.rest.impl; | ||
17 | + | ||
18 | +import com.google.common.collect.ImmutableSet; | ||
19 | +import com.google.common.collect.Maps; | ||
20 | +import org.apache.felix.scr.annotations.Activate; | ||
21 | +import org.apache.felix.scr.annotations.Component; | ||
22 | +import org.apache.felix.scr.annotations.Deactivate; | ||
23 | +import org.apache.felix.scr.annotations.Service; | ||
24 | +import org.onosproject.rest.ApiDocProvider; | ||
25 | +import org.onosproject.rest.ApiDocService; | ||
26 | +import org.slf4j.Logger; | ||
27 | +import org.slf4j.LoggerFactory; | ||
28 | + | ||
29 | +import java.util.Map; | ||
30 | +import java.util.Set; | ||
31 | + | ||
32 | +/** | ||
33 | + * Implementation of the REST API documentation tracker. | ||
34 | + */ | ||
35 | +@Component(immediate = true) | ||
36 | +@Service | ||
37 | +public class ApiDocManager implements ApiDocService { | ||
38 | + | ||
39 | + private final Logger log = LoggerFactory.getLogger(getClass()); | ||
40 | + | ||
41 | + // Set of doc providers | ||
42 | + private final Map<String, ApiDocProvider> providers = Maps.newConcurrentMap(); | ||
43 | + | ||
44 | + @Activate | ||
45 | + public void activate() { | ||
46 | + log.info("Started"); | ||
47 | + } | ||
48 | + | ||
49 | + @Deactivate | ||
50 | + public void deactivate() { | ||
51 | + log.info("Stopped"); | ||
52 | + } | ||
53 | + | ||
54 | + @Override | ||
55 | + public void register(ApiDocProvider provider) { | ||
56 | + providers.put(provider.key(), provider); | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public void unregister(ApiDocProvider provider) { | ||
61 | + providers.remove(provider.name()); | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public Set<ApiDocProvider> getDocProviders() { | ||
66 | + return ImmutableSet.copyOf(providers.values()); | ||
67 | + } | ||
68 | + | ||
69 | + @Override | ||
70 | + public ApiDocProvider getDocProvider(String key) { | ||
71 | + return providers.get(key); | ||
72 | + } | ||
73 | +} |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/** | ||
18 | + * REST API related service. | ||
19 | + */ | ||
20 | +package org.onosproject.rest.impl; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2015 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.rest.resources; | ||
17 | + | ||
18 | +import com.fasterxml.jackson.databind.node.ArrayNode; | ||
19 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
20 | +import org.onosproject.rest.AbstractInjectionResource; | ||
21 | +import org.onosproject.rest.ApiDocService; | ||
22 | + | ||
23 | +import javax.ws.rs.GET; | ||
24 | +import javax.ws.rs.Path; | ||
25 | +import javax.ws.rs.PathParam; | ||
26 | +import javax.ws.rs.core.Response; | ||
27 | +import java.io.ByteArrayInputStream; | ||
28 | +import java.io.IOException; | ||
29 | +import java.io.InputStream; | ||
30 | +import java.io.SequenceInputStream; | ||
31 | + | ||
32 | +import static com.google.common.collect.ImmutableList.of; | ||
33 | +import static com.google.common.io.ByteStreams.toByteArray; | ||
34 | +import static javax.ws.rs.core.MediaType.*; | ||
35 | +import static org.onlab.util.Tools.nullIsNotFound; | ||
36 | + | ||
37 | +/** | ||
38 | + * REST API documentation. | ||
39 | + */ | ||
40 | +@Path("docs") | ||
41 | +public class ApiDocResource extends AbstractInjectionResource { | ||
42 | + | ||
43 | + private static final String CONTENT_TYPE = "Content-Type"; | ||
44 | + private static final String STYLESHEET = "text/css"; | ||
45 | + private static final String SCRIPT = "text/javascript"; | ||
46 | + private static final String DOCS = "/docs/"; | ||
47 | + | ||
48 | + private static final String INJECT_START = "<!-- {API-START} -->"; | ||
49 | + private static final String INJECT_END = "<!-- {API-END} -->"; | ||
50 | + | ||
51 | + /** | ||
52 | + * Get all registered REST API docs. | ||
53 | + * Returns array of all registered API docs. | ||
54 | + * | ||
55 | + * @return 200 OK | ||
56 | + */ | ||
57 | + @GET | ||
58 | + @Path("apis") | ||
59 | + public Response getApiList() { | ||
60 | + ObjectNode root = mapper().createObjectNode(); | ||
61 | + ArrayNode apis = newArray(root, "apis"); | ||
62 | + get(ApiDocService.class).getDocProviders().forEach(p -> apis.add(p.name())); | ||
63 | + return ok(root.toString()).build(); | ||
64 | + } | ||
65 | + | ||
66 | + /** | ||
67 | + * Get Swagger UI JSON. | ||
68 | + * | ||
69 | + * @param key REST API web context | ||
70 | + * @return 200 OK | ||
71 | + */ | ||
72 | + @GET | ||
73 | + @Path("apis/{key: .*?}/swagger.json") | ||
74 | + public Response getApi(@PathParam("key") String key) { | ||
75 | + String k = key.startsWith("/") ? key : "/" + key; | ||
76 | + InputStream stream = nullIsNotFound(get(ApiDocService.class).getDocProvider(k), | ||
77 | + "REST API not found for " + k).docs(); | ||
78 | + return ok(nullIsNotFound(stream, "REST API docs not found for " + k)) | ||
79 | + .header(CONTENT_TYPE, APPLICATION_JSON).build(); | ||
80 | + } | ||
81 | + | ||
82 | + /** | ||
83 | + * Get REST API model schema. | ||
84 | + * | ||
85 | + * @param key REST API web context | ||
86 | + * @return 200 OK | ||
87 | + */ | ||
88 | + @GET | ||
89 | + @Path("apis/{key: .*?}/model.json") | ||
90 | + public Response getApiModel(@PathParam("name") String key) { | ||
91 | + String k = key.startsWith("/") ? key : "/" + key; | ||
92 | + InputStream stream = nullIsNotFound(get(ApiDocService.class).getDocProvider(k), | ||
93 | + "REST API not found for " + k).model(); | ||
94 | + return ok(nullIsNotFound(stream, "REST API model not found for " + k)) | ||
95 | + .header(CONTENT_TYPE, APPLICATION_JSON).build(); | ||
96 | + } | ||
97 | + | ||
98 | + /** | ||
99 | + * Get Swagger UI main index page. | ||
100 | + * | ||
101 | + * @return 200 OK | ||
102 | + */ | ||
103 | + @GET | ||
104 | + @Path("/") | ||
105 | + public Response getDefault() throws IOException { | ||
106 | + return getIndex(); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Get Swagger UI main index page. | ||
111 | + * | ||
112 | + * @return 200 OK | ||
113 | + */ | ||
114 | + @GET | ||
115 | + @Path("index.html") | ||
116 | + public Response getIndex() throws IOException { | ||
117 | + InputStream stream = getClass().getClassLoader().getResourceAsStream(DOCS + "index.html"); | ||
118 | + nullIsNotFound(stream, "index.html not found"); | ||
119 | + | ||
120 | + String index = new String(toByteArray(stream)); | ||
121 | + | ||
122 | + int p1s = split(index, 0, INJECT_START); | ||
123 | + int p1e = split(index, p1s, INJECT_END); | ||
124 | + int p2s = split(index, p1e, null); | ||
125 | + | ||
126 | + StreamEnumeration streams = | ||
127 | + new StreamEnumeration(of(stream(index, 0, p1s), | ||
128 | + includeOptions(get(ApiDocService.class)), | ||
129 | + stream(index, p1e, p2s))); | ||
130 | + | ||
131 | + return ok(new SequenceInputStream(streams)) | ||
132 | + .header(CONTENT_TYPE, TEXT_HTML).build(); | ||
133 | + } | ||
134 | + | ||
135 | + private InputStream includeOptions(ApiDocService service) { | ||
136 | + StringBuilder sb = new StringBuilder(); | ||
137 | + service.getDocProviders().forEach(p -> { | ||
138 | + sb.append("<option value=\"").append(p.key()).append("\"") | ||
139 | + .append(p.key().equals("/onos/v1") ? " selected>" : ">") | ||
140 | + .append(p.name()) | ||
141 | + .append("</option>"); | ||
142 | + }); | ||
143 | + return new ByteArrayInputStream(sb.toString().getBytes()); | ||
144 | + } | ||
145 | + | ||
146 | + /** | ||
147 | + * Get Swagger UI resource. | ||
148 | + * | ||
149 | + * @return 200 OK | ||
150 | + */ | ||
151 | + @GET | ||
152 | + @Path("{resource: .*}") | ||
153 | + public Response getResource(@PathParam("resource") String resource) throws IOException { | ||
154 | + InputStream stream = getClass().getClassLoader().getResourceAsStream(DOCS + resource); | ||
155 | + return ok(nullIsNotFound(stream, resource + " not found")) | ||
156 | + .header(CONTENT_TYPE, contentType(resource)).build(); | ||
157 | + } | ||
158 | + | ||
159 | + static String contentType(String resource) { | ||
160 | + return resource.endsWith(".html") ? TEXT_HTML : | ||
161 | + resource.endsWith(".css") ? STYLESHEET : | ||
162 | + resource.endsWith(".js") ? SCRIPT : | ||
163 | + APPLICATION_OCTET_STREAM; | ||
164 | + } | ||
165 | +} |
... | @@ -35,30 +35,52 @@ import java.io.InputStream; | ... | @@ -35,30 +35,52 @@ import java.io.InputStream; |
35 | import java.util.Set; | 35 | import java.util.Set; |
36 | 36 | ||
37 | /** | 37 | /** |
38 | - * REST resource for interacting with the inventory of applications. | 38 | + * Manage inventory of applications. |
39 | */ | 39 | */ |
40 | @Path("applications") | 40 | @Path("applications") |
41 | public class ApplicationsWebResource extends AbstractWebResource { | 41 | public class ApplicationsWebResource extends AbstractWebResource { |
42 | 42 | ||
43 | + /** | ||
44 | + * Get all installed applications. | ||
45 | + * Returns array of all installed applications. | ||
46 | + * | ||
47 | + * @return 200 OK | ||
48 | + */ | ||
43 | @GET | 49 | @GET |
44 | - public Response getApplications() { | 50 | + public Response getApps() { |
45 | ApplicationAdminService service = get(ApplicationAdminService.class); | 51 | ApplicationAdminService service = get(ApplicationAdminService.class); |
46 | Set<Application> apps = service.getApplications(); | 52 | Set<Application> apps = service.getApplications(); |
47 | return ok(encodeArray(Application.class, "applications", apps)).build(); | 53 | return ok(encodeArray(Application.class, "applications", apps)).build(); |
48 | } | 54 | } |
49 | 55 | ||
56 | + /** | ||
57 | + * Get application details. | ||
58 | + * Returns details of the specified application. | ||
59 | + * | ||
60 | + * @param name application name | ||
61 | + * @return 200 OK; 404; 401 | ||
62 | + */ | ||
50 | @GET | 63 | @GET |
51 | @Path("{name}") | 64 | @Path("{name}") |
52 | - public Response getApplication(@PathParam("name") String name) { | 65 | + public Response getApp(@PathParam("name") String name) { |
53 | ApplicationAdminService service = get(ApplicationAdminService.class); | 66 | ApplicationAdminService service = get(ApplicationAdminService.class); |
54 | ApplicationId appId = service.getId(name); | 67 | ApplicationId appId = service.getId(name); |
55 | return response(service, appId); | 68 | return response(service, appId); |
56 | } | 69 | } |
57 | 70 | ||
71 | + /** | ||
72 | + * Install a new application. | ||
73 | + * Uploads application archive stream and optionally activates the | ||
74 | + * application. | ||
75 | + * | ||
76 | + * @param activate true to activate app also | ||
77 | + * @param stream application archive stream | ||
78 | + * @return 200 OK; 404; 401 | ||
79 | + */ | ||
58 | @POST | 80 | @POST |
59 | @Consumes(MediaType.APPLICATION_OCTET_STREAM) | 81 | @Consumes(MediaType.APPLICATION_OCTET_STREAM) |
60 | @Produces(MediaType.APPLICATION_JSON) | 82 | @Produces(MediaType.APPLICATION_JSON) |
61 | - public Response installApplication(@QueryParam("activate") | 83 | + public Response installApp(@QueryParam("activate") |
62 | @DefaultValue("false") boolean activate, | 84 | @DefaultValue("false") boolean activate, |
63 | InputStream stream) { | 85 | InputStream stream) { |
64 | ApplicationAdminService service = get(ApplicationAdminService.class); | 86 | ApplicationAdminService service = get(ApplicationAdminService.class); |
... | @@ -69,30 +91,51 @@ public class ApplicationsWebResource extends AbstractWebResource { | ... | @@ -69,30 +91,51 @@ public class ApplicationsWebResource extends AbstractWebResource { |
69 | return ok(codec(Application.class).encode(app, this)).build(); | 91 | return ok(codec(Application.class).encode(app, this)).build(); |
70 | } | 92 | } |
71 | 93 | ||
94 | + /** | ||
95 | + * Uninstall application. | ||
96 | + * Uninstalls the specified application deactivating it first if necessary. | ||
97 | + * | ||
98 | + * @param name application name | ||
99 | + * @return 200 OK; 404; 401 | ||
100 | + */ | ||
72 | @DELETE | 101 | @DELETE |
73 | @Produces(MediaType.APPLICATION_JSON) | 102 | @Produces(MediaType.APPLICATION_JSON) |
74 | @Path("{name}") | 103 | @Path("{name}") |
75 | - public Response uninstallApplication(@PathParam("name") String name) { | 104 | + public Response uninstallApp(@PathParam("name") String name) { |
76 | ApplicationAdminService service = get(ApplicationAdminService.class); | 105 | ApplicationAdminService service = get(ApplicationAdminService.class); |
77 | ApplicationId appId = service.getId(name); | 106 | ApplicationId appId = service.getId(name); |
78 | service.uninstall(appId); | 107 | service.uninstall(appId); |
79 | return Response.ok().build(); | 108 | return Response.ok().build(); |
80 | } | 109 | } |
81 | 110 | ||
111 | + /** | ||
112 | + * Activate application. | ||
113 | + * Activates the specified application. | ||
114 | + * | ||
115 | + * @param name application name | ||
116 | + * @return 200 OK; 404; 401 | ||
117 | + */ | ||
82 | @POST | 118 | @POST |
83 | @Produces(MediaType.APPLICATION_JSON) | 119 | @Produces(MediaType.APPLICATION_JSON) |
84 | @Path("{name}/active") | 120 | @Path("{name}/active") |
85 | - public Response activateApplication(@PathParam("name") String name) { | 121 | + public Response activateApp(@PathParam("name") String name) { |
86 | ApplicationAdminService service = get(ApplicationAdminService.class); | 122 | ApplicationAdminService service = get(ApplicationAdminService.class); |
87 | ApplicationId appId = service.getId(name); | 123 | ApplicationId appId = service.getId(name); |
88 | service.activate(appId); | 124 | service.activate(appId); |
89 | return response(service, appId); | 125 | return response(service, appId); |
90 | } | 126 | } |
91 | 127 | ||
128 | + /** | ||
129 | + * De-activate application. | ||
130 | + * De-activates the specified application. | ||
131 | + * | ||
132 | + * @param name application name | ||
133 | + * @return 200 OK; 404; 401 | ||
134 | + */ | ||
92 | @DELETE | 135 | @DELETE |
93 | @Produces(MediaType.APPLICATION_JSON) | 136 | @Produces(MediaType.APPLICATION_JSON) |
94 | @Path("{name}/active") | 137 | @Path("{name}/active") |
95 | - public Response deactivateApplication(@PathParam("name") String name) { | 138 | + public Response deactivateApp(@PathParam("name") String name) { |
96 | ApplicationAdminService service = get(ApplicationAdminService.class); | 139 | ApplicationAdminService service = get(ApplicationAdminService.class); |
97 | ApplicationId appId = service.getId(name); | 140 | ApplicationId appId = service.getId(name); |
98 | service.deactivate(appId); | 141 | service.deactivate(appId); | ... | ... |
... | @@ -37,19 +37,32 @@ import java.util.List; | ... | @@ -37,19 +37,32 @@ import java.util.List; |
37 | import static org.onlab.util.Tools.nullIsNotFound; | 37 | import static org.onlab.util.Tools.nullIsNotFound; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * REST resource for interacting with the ONOS cluster subsystem. | 40 | + * Manage cluster of ONOS instances. |
41 | */ | 41 | */ |
42 | @Path("cluster") | 42 | @Path("cluster") |
43 | public class ClusterWebResource extends AbstractWebResource { | 43 | public class ClusterWebResource extends AbstractWebResource { |
44 | 44 | ||
45 | public static final String NODE_NOT_FOUND = "Node is not found"; | 45 | public static final String NODE_NOT_FOUND = "Node is not found"; |
46 | 46 | ||
47 | + /** | ||
48 | + * Get all cluster nodes. | ||
49 | + * Returns array of all cluster nodes. | ||
50 | + * | ||
51 | + * @return 200 OK | ||
52 | + */ | ||
47 | @GET | 53 | @GET |
48 | public Response getClusterNodes() { | 54 | public Response getClusterNodes() { |
49 | Iterable<ControllerNode> nodes = get(ClusterService.class).getNodes(); | 55 | Iterable<ControllerNode> nodes = get(ClusterService.class).getNodes(); |
50 | return ok(encodeArray(ControllerNode.class, "nodes", nodes)).build(); | 56 | return ok(encodeArray(ControllerNode.class, "nodes", nodes)).build(); |
51 | } | 57 | } |
52 | 58 | ||
59 | + /** | ||
60 | + * Get cluster node details. | ||
61 | + * Returns details of the specified cluster node. | ||
62 | + * | ||
63 | + * @param id cluster node identifier | ||
64 | + * @return 200 OK | ||
65 | + */ | ||
53 | @GET | 66 | @GET |
54 | @Path("{id}") | 67 | @Path("{id}") |
55 | public Response getClusterNode(@PathParam("id") String id) { | 68 | public Response getClusterNode(@PathParam("id") String id) { |
... | @@ -58,6 +71,13 @@ public class ClusterWebResource extends AbstractWebResource { | ... | @@ -58,6 +71,13 @@ public class ClusterWebResource extends AbstractWebResource { |
58 | return ok(codec(ControllerNode.class).encode(node, this)).build(); | 71 | return ok(codec(ControllerNode.class).encode(node, this)).build(); |
59 | } | 72 | } |
60 | 73 | ||
74 | + /** | ||
75 | + * Forms cluster of ONOS instances. | ||
76 | + * Forms ONOS cluster using the uploaded JSON definition. | ||
77 | + * | ||
78 | + * @param config cluster definition | ||
79 | + * @return 200 OK | ||
80 | + */ | ||
61 | @POST | 81 | @POST |
62 | @Path("configuration") | 82 | @Path("configuration") |
63 | public Response formCluster(InputStream config) throws IOException { | 83 | public Response formCluster(InputStream config) throws IOException { | ... | ... |
... | @@ -33,11 +33,17 @@ import java.util.Set; | ... | @@ -33,11 +33,17 @@ import java.util.Set; |
33 | import static org.onlab.util.Tools.nullIsNotFound; | 33 | import static org.onlab.util.Tools.nullIsNotFound; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | - * REST resource for cluster-wide component configuration. | 36 | + * Manage component configurations. |
37 | */ | 37 | */ |
38 | @Path("configuration") | 38 | @Path("configuration") |
39 | public class ComponentConfigWebResource extends AbstractWebResource { | 39 | public class ComponentConfigWebResource extends AbstractWebResource { |
40 | 40 | ||
41 | + /** | ||
42 | + * Get all component configurations. | ||
43 | + * Returns collection of all registered component configurations. | ||
44 | + * | ||
45 | + * @return 200 OK | ||
46 | + */ | ||
41 | @GET | 47 | @GET |
42 | public Response getComponentConfigs() { | 48 | public Response getComponentConfigs() { |
43 | ComponentConfigService service = get(ComponentConfigService.class); | 49 | ComponentConfigService service = get(ComponentConfigService.class); |
... | @@ -47,6 +53,12 @@ public class ComponentConfigWebResource extends AbstractWebResource { | ... | @@ -47,6 +53,12 @@ public class ComponentConfigWebResource extends AbstractWebResource { |
47 | return ok(root).build(); | 53 | return ok(root).build(); |
48 | } | 54 | } |
49 | 55 | ||
56 | + /** | ||
57 | + * Get configuration of the specified component. | ||
58 | + * | ||
59 | + * @param component component name | ||
60 | + * @return 200 OK | ||
61 | + */ | ||
50 | @GET | 62 | @GET |
51 | @Path("{component}") | 63 | @Path("{component}") |
52 | public Response getComponentConfigs(@PathParam("component") String component) { | 64 | public Response getComponentConfigs(@PathParam("component") String component) { |
... | @@ -65,9 +77,16 @@ public class ComponentConfigWebResource extends AbstractWebResource { | ... | @@ -65,9 +77,16 @@ public class ComponentConfigWebResource extends AbstractWebResource { |
65 | props.forEach(p -> compNode.put(p.name(), p.value())); | 77 | props.forEach(p -> compNode.put(p.name(), p.value())); |
66 | } | 78 | } |
67 | 79 | ||
80 | + /** | ||
81 | + * Selectively set configuration properties. | ||
82 | + * Sets only the properties present in the JSON request. | ||
83 | + * | ||
84 | + * @param component component name | ||
85 | + * @return 200 OK | ||
86 | + */ | ||
68 | @POST | 87 | @POST |
69 | @Path("{component}") | 88 | @Path("{component}") |
70 | - public Response setComponentConfigs(@PathParam("component") String component, | 89 | + public Response setConfigs(@PathParam("component") String component, |
71 | InputStream request) throws IOException { | 90 | InputStream request) throws IOException { |
72 | ComponentConfigService service = get(ComponentConfigService.class); | 91 | ComponentConfigService service = get(ComponentConfigService.class); |
73 | ObjectNode props = (ObjectNode) mapper().readTree(request); | 92 | ObjectNode props = (ObjectNode) mapper().readTree(request); |
... | @@ -76,9 +95,16 @@ public class ComponentConfigWebResource extends AbstractWebResource { | ... | @@ -76,9 +95,16 @@ public class ComponentConfigWebResource extends AbstractWebResource { |
76 | return Response.noContent().build(); | 95 | return Response.noContent().build(); |
77 | } | 96 | } |
78 | 97 | ||
98 | + /** | ||
99 | + * Selectively clear configuration properties. | ||
100 | + * Clears only the properties present in the JSON request. | ||
101 | + * | ||
102 | + * @param component component name | ||
103 | + * @return 200 OK | ||
104 | + */ | ||
79 | @DELETE | 105 | @DELETE |
80 | @Path("{component}") | 106 | @Path("{component}") |
81 | - public Response unsetComponentConfigs(@PathParam("component") String component, | 107 | + public Response unsetConfigs(@PathParam("component") String component, |
82 | InputStream request) throws IOException { | 108 | InputStream request) throws IOException { |
83 | ComponentConfigService service = get(ComponentConfigService.class); | 109 | ComponentConfigService service = get(ComponentConfigService.class); |
84 | ObjectNode props = (ObjectNode) mapper().readTree(request); | 110 | ObjectNode props = (ObjectNode) mapper().readTree(request); | ... | ... |
... | @@ -37,14 +37,20 @@ import java.io.InputStream; | ... | @@ -37,14 +37,20 @@ import java.io.InputStream; |
37 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | 37 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; |
38 | 38 | ||
39 | /** | 39 | /** |
40 | - * Resource that acts as an ancillary provider for uploading pre-configured | 40 | + * Inject devices, ports, links and end-station hosts. |
41 | - * devices, ports and links. | ||
42 | */ | 41 | */ |
43 | @Path("config") | 42 | @Path("config") |
44 | public class ConfigWebResource extends BaseResource { | 43 | public class ConfigWebResource extends BaseResource { |
45 | 44 | ||
46 | private static Logger log = LoggerFactory.getLogger(ConfigWebResource.class); | 45 | private static Logger log = LoggerFactory.getLogger(ConfigWebResource.class); |
47 | 46 | ||
47 | + /** | ||
48 | + * Upload device, port, link and host data. | ||
49 | + * | ||
50 | + * @param input JSON blob | ||
51 | + * @return 200 OK | ||
52 | + * @throws IOException | ||
53 | + */ | ||
48 | @POST | 54 | @POST |
49 | @Path("topology") | 55 | @Path("topology") |
50 | @Consumes(MediaType.APPLICATION_JSON) | 56 | @Consumes(MediaType.APPLICATION_JSON) | ... | ... |
... | @@ -34,19 +34,32 @@ import static org.onlab.util.Tools.nullIsNotFound; | ... | @@ -34,19 +34,32 @@ import static org.onlab.util.Tools.nullIsNotFound; |
34 | import static org.onosproject.net.DeviceId.deviceId; | 34 | import static org.onosproject.net.DeviceId.deviceId; |
35 | 35 | ||
36 | /** | 36 | /** |
37 | - * REST resource for interacting with the inventory of infrastructure devices. | 37 | + * Manage inventory of infrastructure devices. |
38 | */ | 38 | */ |
39 | @Path("devices") | 39 | @Path("devices") |
40 | public class DevicesWebResource extends AbstractWebResource { | 40 | public class DevicesWebResource extends AbstractWebResource { |
41 | 41 | ||
42 | public static final String DEVICE_NOT_FOUND = "Device is not found"; | 42 | public static final String DEVICE_NOT_FOUND = "Device is not found"; |
43 | 43 | ||
44 | + /** | ||
45 | + * Get all infrastructure devices. | ||
46 | + * Returns array of all discovered infrastructure devices. | ||
47 | + * | ||
48 | + * @return 200 OK | ||
49 | + */ | ||
44 | @GET | 50 | @GET |
45 | public Response getDevices() { | 51 | public Response getDevices() { |
46 | Iterable<Device> devices = get(DeviceService.class).getDevices(); | 52 | Iterable<Device> devices = get(DeviceService.class).getDevices(); |
47 | return ok(encodeArray(Device.class, "devices", devices)).build(); | 53 | return ok(encodeArray(Device.class, "devices", devices)).build(); |
48 | } | 54 | } |
49 | 55 | ||
56 | + /** | ||
57 | + * Get details of infrastructure device. | ||
58 | + * Returns details of the specified infrastructure device. | ||
59 | + * | ||
60 | + * @param id device identifier | ||
61 | + * @return 200 OK | ||
62 | + */ | ||
50 | @GET | 63 | @GET |
51 | @Path("{id}") | 64 | @Path("{id}") |
52 | public Response getDevice(@PathParam("id") String id) { | 65 | public Response getDevice(@PathParam("id") String id) { |
... | @@ -55,6 +68,14 @@ public class DevicesWebResource extends AbstractWebResource { | ... | @@ -55,6 +68,14 @@ public class DevicesWebResource extends AbstractWebResource { |
55 | return ok(codec(Device.class).encode(device, this)).build(); | 68 | return ok(codec(Device.class).encode(device, this)).build(); |
56 | } | 69 | } |
57 | 70 | ||
71 | + /** | ||
72 | + * Remove infrastructure device. | ||
73 | + * Administratively deletes the specified device from the inventory of | ||
74 | + * known devices. | ||
75 | + * | ||
76 | + * @param id device identifier | ||
77 | + * @return 200 OK | ||
78 | + */ | ||
58 | @DELETE | 79 | @DELETE |
59 | @Path("{id}") | 80 | @Path("{id}") |
60 | public Response removeDevice(@PathParam("id") String id) { | 81 | public Response removeDevice(@PathParam("id") String id) { |
... | @@ -64,6 +85,13 @@ public class DevicesWebResource extends AbstractWebResource { | ... | @@ -64,6 +85,13 @@ public class DevicesWebResource extends AbstractWebResource { |
64 | return ok(codec(Device.class).encode(device, this)).build(); | 85 | return ok(codec(Device.class).encode(device, this)).build(); |
65 | } | 86 | } |
66 | 87 | ||
88 | + /** | ||
89 | + * Get ports of infrastructure device. | ||
90 | + * Returns details of the specified infrastructure device. | ||
91 | + * | ||
92 | + * @param id device identifier | ||
93 | + * @return 200 OK | ||
94 | + */ | ||
67 | @GET | 95 | @GET |
68 | @Path("{id}/ports") | 96 | @Path("{id}/ports") |
69 | public Response getDevicePorts(@PathParam("id") String id) { | 97 | public Response getDevicePorts(@PathParam("id") String id) { | ... | ... |
... | @@ -45,7 +45,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; | ... | @@ -45,7 +45,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; |
45 | import com.fasterxml.jackson.databind.node.ObjectNode; | 45 | import com.fasterxml.jackson.databind.node.ObjectNode; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | - * REST resource for interacting with the inventory of flows. | 48 | + * Query and program flow rules. |
49 | */ | 49 | */ |
50 | 50 | ||
51 | @Path("flows") | 51 | @Path("flows") |
... | @@ -57,14 +57,13 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -57,14 +57,13 @@ public class FlowsWebResource extends AbstractWebResource { |
57 | final ArrayNode flowsNode = root.putArray("flows"); | 57 | final ArrayNode flowsNode = root.putArray("flows"); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | - * Gets an array containing all the intents in the system. | 60 | + * Get all flow entries. Returns array of all flow rules in the system. |
61 | * | 61 | * |
62 | * @return array of all the intents in the system | 62 | * @return array of all the intents in the system |
63 | */ | 63 | */ |
64 | @GET | 64 | @GET |
65 | @Produces(MediaType.APPLICATION_JSON) | 65 | @Produces(MediaType.APPLICATION_JSON) |
66 | public Response getFlows() { | 66 | public Response getFlows() { |
67 | - | ||
68 | final Iterable<Device> devices = get(DeviceService.class).getDevices(); | 67 | final Iterable<Device> devices = get(DeviceService.class).getDevices(); |
69 | for (final Device device : devices) { | 68 | for (final Device device : devices) { |
70 | final Iterable<FlowEntry> deviceEntries = service.getFlowEntries(device.id()); | 69 | final Iterable<FlowEntry> deviceEntries = service.getFlowEntries(device.id()); |
... | @@ -79,9 +78,10 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -79,9 +78,10 @@ public class FlowsWebResource extends AbstractWebResource { |
79 | } | 78 | } |
80 | 79 | ||
81 | /** | 80 | /** |
82 | - * Gets the flows for a device, where the device is specified by Id. | 81 | + * Get flow entries of a device. Returns array of all flow rules for the |
82 | + * specified device. | ||
83 | * | 83 | * |
84 | - * @param deviceId Id of device to look up | 84 | + * @param deviceId device identifier |
85 | * @return flow data as an array | 85 | * @return flow data as an array |
86 | */ | 86 | */ |
87 | @GET | 87 | @GET |
... | @@ -101,10 +101,11 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -101,10 +101,11 @@ public class FlowsWebResource extends AbstractWebResource { |
101 | } | 101 | } |
102 | 102 | ||
103 | /** | 103 | /** |
104 | - * Gets the flows for a device, where the device is specified by Id. | 104 | + * Get flow rule. Returns the flow entry specified by the device id and |
105 | + * flow rule id. | ||
105 | * | 106 | * |
106 | - * @param deviceId Id of device to look up | 107 | + * @param deviceId device identifier |
107 | - * @param flowId Id of flow to look up | 108 | + * @param flowId flow rule identifier |
108 | * @return flow data as an array | 109 | * @return flow data as an array |
109 | */ | 110 | */ |
110 | @GET | 111 | @GET |
... | @@ -127,10 +128,11 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -127,10 +128,11 @@ public class FlowsWebResource extends AbstractWebResource { |
127 | } | 128 | } |
128 | 129 | ||
129 | /** | 130 | /** |
130 | - * Creates a flow rule from a POST of a JSON string and attempts to apply it. | 131 | + * Create new flow rule. Creates and installs a new flow rule for the |
132 | + * specified device. | ||
131 | * | 133 | * |
132 | * @param deviceId device identifier | 134 | * @param deviceId device identifier |
133 | - * @param stream input JSON | 135 | + * @param stream flow rule JSON |
134 | * @return status of the request - CREATED if the JSON is correct, | 136 | * @return status of the request - CREATED if the JSON is correct, |
135 | * BAD_REQUEST if the JSON is invalid | 137 | * BAD_REQUEST if the JSON is invalid |
136 | */ | 138 | */ |
... | @@ -163,10 +165,10 @@ public class FlowsWebResource extends AbstractWebResource { | ... | @@ -163,10 +165,10 @@ public class FlowsWebResource extends AbstractWebResource { |
163 | } | 165 | } |
164 | 166 | ||
165 | /** | 167 | /** |
166 | - * Removes the flows for a given device with the given flow id. | 168 | + * Remove flow rule. Removes the specified flow rule. |
167 | * | 169 | * |
168 | - * @param deviceId Id of device to look up | 170 | + * @param deviceId device identifier |
169 | - * @param flowId Id of flow to look up | 171 | + * @param flowId flow rule identifier |
170 | */ | 172 | */ |
171 | @DELETE | 173 | @DELETE |
172 | @Produces(MediaType.APPLICATION_JSON) | 174 | @Produces(MediaType.APPLICATION_JSON) | ... | ... |
... | @@ -56,7 +56,7 @@ import static org.onlab.util.Tools.nullIsNotFound; | ... | @@ -56,7 +56,7 @@ import static org.onlab.util.Tools.nullIsNotFound; |
56 | import static org.onosproject.net.HostId.hostId; | 56 | import static org.onosproject.net.HostId.hostId; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | - * REST resource for interacting with the inventory of hosts. | 59 | + * Manage inventory of end-station hosts. |
60 | */ | 60 | */ |
61 | @Path("hosts") | 61 | @Path("hosts") |
62 | public class HostsWebResource extends AbstractWebResource { | 62 | public class HostsWebResource extends AbstractWebResource { |
... | @@ -65,6 +65,12 @@ public class HostsWebResource extends AbstractWebResource { | ... | @@ -65,6 +65,12 @@ public class HostsWebResource extends AbstractWebResource { |
65 | UriInfo uriInfo; | 65 | UriInfo uriInfo; |
66 | public static final String HOST_NOT_FOUND = "Host is not found"; | 66 | public static final String HOST_NOT_FOUND = "Host is not found"; |
67 | 67 | ||
68 | + /** | ||
69 | + * Get all end-station hosts. | ||
70 | + * Returns array of all known end-station hosts. | ||
71 | + * | ||
72 | + * @return 200 OK | ||
73 | + */ | ||
68 | @GET | 74 | @GET |
69 | @Produces(MediaType.APPLICATION_JSON) | 75 | @Produces(MediaType.APPLICATION_JSON) |
70 | public Response getHosts() { | 76 | public Response getHosts() { |
... | @@ -73,6 +79,13 @@ public class HostsWebResource extends AbstractWebResource { | ... | @@ -73,6 +79,13 @@ public class HostsWebResource extends AbstractWebResource { |
73 | return ok(root).build(); | 79 | return ok(root).build(); |
74 | } | 80 | } |
75 | 81 | ||
82 | + /** | ||
83 | + * Get details of end-station host. | ||
84 | + * Returns detailed properties of the specified end-station host. | ||
85 | + * | ||
86 | + * @param id host identifier | ||
87 | + * @return 200 OK | ||
88 | + */ | ||
76 | @GET | 89 | @GET |
77 | @Produces(MediaType.APPLICATION_JSON) | 90 | @Produces(MediaType.APPLICATION_JSON) |
78 | @Path("{id}") | 91 | @Path("{id}") |
... | @@ -83,6 +96,14 @@ public class HostsWebResource extends AbstractWebResource { | ... | @@ -83,6 +96,14 @@ public class HostsWebResource extends AbstractWebResource { |
83 | return ok(root).build(); | 96 | return ok(root).build(); |
84 | } | 97 | } |
85 | 98 | ||
99 | + /** | ||
100 | + * Get details of end-station host with MAC/VLAN. | ||
101 | + * Returns detailed properties of the specified end-station host. | ||
102 | + * | ||
103 | + * @param mac host MAC address | ||
104 | + * @param vlan host VLAN identifier | ||
105 | + * @return 200 OK | ||
106 | + */ | ||
86 | @GET | 107 | @GET |
87 | @Produces(MediaType.APPLICATION_JSON) | 108 | @Produces(MediaType.APPLICATION_JSON) |
88 | @Path("{mac}/{vlan}") | 109 | @Path("{mac}/{vlan}") |
... | @@ -157,6 +178,7 @@ public class HostsWebResource extends AbstractWebResource { | ... | @@ -157,6 +178,7 @@ public class HostsWebResource extends AbstractWebResource { |
157 | 178 | ||
158 | /** | 179 | /** |
159 | * Creates and adds new host based on given data and returns its host ID. | 180 | * Creates and adds new host based on given data and returns its host ID. |
181 | + * | ||
160 | * @param node JsonNode containing host information | 182 | * @param node JsonNode containing host information |
161 | * @return host ID of new host created | 183 | * @return host ID of new host created |
162 | */ | 184 | */ | ... | ... |
... | @@ -55,9 +55,8 @@ import static org.onosproject.net.intent.IntentState.WITHDRAWN; | ... | @@ -55,9 +55,8 @@ import static org.onosproject.net.intent.IntentState.WITHDRAWN; |
55 | import static org.slf4j.LoggerFactory.getLogger; | 55 | import static org.slf4j.LoggerFactory.getLogger; |
56 | 56 | ||
57 | /** | 57 | /** |
58 | - * REST resource for interacting with the inventory of intents. | 58 | + * Query, submit and withdraw network intents. |
59 | */ | 59 | */ |
60 | - | ||
61 | @Path("intents") | 60 | @Path("intents") |
62 | public class IntentsWebResource extends AbstractWebResource { | 61 | public class IntentsWebResource extends AbstractWebResource { |
63 | @Context | 62 | @Context |
... | @@ -69,7 +68,8 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -69,7 +68,8 @@ public class IntentsWebResource extends AbstractWebResource { |
69 | public static final String INTENT_NOT_FOUND = "Intent is not found"; | 68 | public static final String INTENT_NOT_FOUND = "Intent is not found"; |
70 | 69 | ||
71 | /** | 70 | /** |
72 | - * Gets an array containing all the intents in the system. | 71 | + * Get all intents. |
72 | + * Returns array containing all the intents in the system. | ||
73 | * | 73 | * |
74 | * @return array of all the intents in the system | 74 | * @return array of all the intents in the system |
75 | */ | 75 | */ |
... | @@ -82,10 +82,11 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -82,10 +82,11 @@ public class IntentsWebResource extends AbstractWebResource { |
82 | } | 82 | } |
83 | 83 | ||
84 | /** | 84 | /** |
85 | - * Gets a single intent by Id. | 85 | + * Get intent by application and key. |
86 | + * Returns details of the specified intent. | ||
86 | * | 87 | * |
87 | - * @param appId the Application ID | 88 | + * @param appId application identifier |
88 | - * @param key the Intent key value to look up | 89 | + * @param key intent key |
89 | * @return intent data | 90 | * @return intent data |
90 | */ | 91 | */ |
91 | @GET | 92 | @GET |
... | @@ -133,23 +134,53 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -133,23 +134,53 @@ public class IntentsWebResource extends AbstractWebResource { |
133 | } | 134 | } |
134 | 135 | ||
135 | /** | 136 | /** |
136 | - * Uninstalls a single intent by Id. | 137 | + * Submit a new intent. |
138 | + * Creates and submits intent from the JSON request. | ||
137 | * | 139 | * |
138 | - * @param appId the Application ID | 140 | + * @param stream input JSON |
139 | - * @param keyString the Intent key value to look up | 141 | + * @return status of the request - CREATED if the JSON is correct, |
142 | + * BAD_REQUEST if the JSON is invalid | ||
143 | + */ | ||
144 | + @POST | ||
145 | + @Consumes(MediaType.APPLICATION_JSON) | ||
146 | + @Produces(MediaType.APPLICATION_JSON) | ||
147 | + public Response createIntent(InputStream stream) { | ||
148 | + try { | ||
149 | + IntentService service = get(IntentService.class); | ||
150 | + ObjectNode root = (ObjectNode) mapper().readTree(stream); | ||
151 | + Intent intent = codec(Intent.class).decode(root, this); | ||
152 | + service.submit(intent); | ||
153 | + UriBuilder locationBuilder = uriInfo.getBaseUriBuilder() | ||
154 | + .path("intents") | ||
155 | + .path(Short.toString(intent.appId().id())) | ||
156 | + .path(Long.toString(intent.id().fingerprint())); | ||
157 | + return Response | ||
158 | + .created(locationBuilder.build()) | ||
159 | + .build(); | ||
160 | + } catch (IOException ioe) { | ||
161 | + throw new IllegalArgumentException(ioe); | ||
162 | + } | ||
163 | + } | ||
164 | + | ||
165 | + /** | ||
166 | + * Withdraw intent. | ||
167 | + * Withdraws the specified intent from the system. | ||
168 | + * | ||
169 | + * @param appId application identifier | ||
170 | + * @param key intent key | ||
140 | */ | 171 | */ |
141 | @DELETE | 172 | @DELETE |
142 | @Path("{appId}/{key}") | 173 | @Path("{appId}/{key}") |
143 | public void deleteIntentById(@PathParam("appId") String appId, | 174 | public void deleteIntentById(@PathParam("appId") String appId, |
144 | - @PathParam("key") String keyString) { | 175 | + @PathParam("key") String key) { |
145 | final ApplicationId app = get(CoreService.class).getAppId(appId); | 176 | final ApplicationId app = get(CoreService.class).getAppId(appId); |
146 | 177 | ||
147 | - Intent intent = get(IntentService.class).getIntent(Key.of(keyString, app)); | 178 | + Intent intent = get(IntentService.class).getIntent(Key.of(key, app)); |
148 | IntentService service = get(IntentService.class); | 179 | IntentService service = get(IntentService.class); |
149 | 180 | ||
150 | if (intent == null) { | 181 | if (intent == null) { |
151 | intent = service | 182 | intent = service |
152 | - .getIntent(Key.of(Long.decode(keyString), app)); | 183 | + .getIntent(Key.of(Long.decode(key), app)); |
153 | } | 184 | } |
154 | if (intent == null) { | 185 | if (intent == null) { |
155 | // No such intent. REST standards recommend a positive status code | 186 | // No such intent. REST standards recommend a positive status code |
... | @@ -158,12 +189,12 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -158,12 +189,12 @@ public class IntentsWebResource extends AbstractWebResource { |
158 | } | 189 | } |
159 | 190 | ||
160 | 191 | ||
161 | - Key key = intent.key(); | 192 | + Key k = intent.key(); |
162 | 193 | ||
163 | // set up latch and listener to track uninstall progress | 194 | // set up latch and listener to track uninstall progress |
164 | CountDownLatch latch = new CountDownLatch(1); | 195 | CountDownLatch latch = new CountDownLatch(1); |
165 | 196 | ||
166 | - IntentListener listener = new DeleteListener(key, latch); | 197 | + IntentListener listener = new DeleteListener(k, latch); |
167 | service.addListener(listener); | 198 | service.addListener(listener); |
168 | 199 | ||
169 | try { | 200 | try { |
... | @@ -173,10 +204,10 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -173,10 +204,10 @@ public class IntentsWebResource extends AbstractWebResource { |
173 | try { | 204 | try { |
174 | latch.await(WITHDRAW_EVENT_TIMEOUT_SECONDS, TimeUnit.SECONDS); | 205 | latch.await(WITHDRAW_EVENT_TIMEOUT_SECONDS, TimeUnit.SECONDS); |
175 | } catch (InterruptedException e) { | 206 | } catch (InterruptedException e) { |
176 | - log.info("REST Delete operation timed out waiting for intent {}", key); | 207 | + log.info("REST Delete operation timed out waiting for intent {}", k); |
177 | } | 208 | } |
178 | // double check the state | 209 | // double check the state |
179 | - IntentState state = service.getIntentState(key); | 210 | + IntentState state = service.getIntentState(k); |
180 | if (state == WITHDRAWN || state == FAILED) { | 211 | if (state == WITHDRAWN || state == FAILED) { |
181 | service.purge(intent); | 212 | service.purge(intent); |
182 | } | 213 | } |
... | @@ -187,32 +218,4 @@ public class IntentsWebResource extends AbstractWebResource { | ... | @@ -187,32 +218,4 @@ public class IntentsWebResource extends AbstractWebResource { |
187 | } | 218 | } |
188 | } | 219 | } |
189 | 220 | ||
190 | - /** | ||
191 | - * Creates an intent from a POST of a JSON string and attempts to apply it. | ||
192 | - * | ||
193 | - * @param stream input JSON | ||
194 | - * @return status of the request - CREATED if the JSON is correct, | ||
195 | - * BAD_REQUEST if the JSON is invalid | ||
196 | - */ | ||
197 | - @POST | ||
198 | - @Consumes(MediaType.APPLICATION_JSON) | ||
199 | - @Produces(MediaType.APPLICATION_JSON) | ||
200 | - public Response createIntent(InputStream stream) { | ||
201 | - try { | ||
202 | - IntentService service = get(IntentService.class); | ||
203 | - ObjectNode root = (ObjectNode) mapper().readTree(stream); | ||
204 | - Intent intent = codec(Intent.class).decode(root, this); | ||
205 | - service.submit(intent); | ||
206 | - UriBuilder locationBuilder = uriInfo.getBaseUriBuilder() | ||
207 | - .path("intents") | ||
208 | - .path(Short.toString(intent.appId().id())) | ||
209 | - .path(Long.toString(intent.id().fingerprint())); | ||
210 | - return Response | ||
211 | - .created(locationBuilder.build()) | ||
212 | - .build(); | ||
213 | - } catch (IOException ioe) { | ||
214 | - throw new IllegalArgumentException(ioe); | ||
215 | - } | ||
216 | - } | ||
217 | - | ||
218 | } | 221 | } | ... | ... |
... | @@ -30,7 +30,7 @@ import static org.onosproject.net.DeviceId.deviceId; | ... | @@ -30,7 +30,7 @@ import static org.onosproject.net.DeviceId.deviceId; |
30 | import static org.onosproject.net.PortNumber.portNumber; | 30 | import static org.onosproject.net.PortNumber.portNumber; |
31 | 31 | ||
32 | /** | 32 | /** |
33 | - * REST resource for interacting with the inventory of infrastructure links. | 33 | + * Manage inventory of infrastructure links. |
34 | */ | 34 | */ |
35 | @Path("links") | 35 | @Path("links") |
36 | public class LinksWebResource extends AbstractWebResource { | 36 | public class LinksWebResource extends AbstractWebResource { |
... | @@ -41,6 +41,15 @@ public class LinksWebResource extends AbstractWebResource { | ... | @@ -41,6 +41,15 @@ public class LinksWebResource extends AbstractWebResource { |
41 | EGRESS | 41 | EGRESS |
42 | } | 42 | } |
43 | 43 | ||
44 | + /** | ||
45 | + * Get infrastructure links. | ||
46 | + * Returns array of all links, or links for the specified device or port. | ||
47 | + * | ||
48 | + * @param deviceId (optional) device identifier | ||
49 | + * @param port (optional) port number | ||
50 | + * @param direction (optional) direction qualifier | ||
51 | + * @return 200 OK | ||
52 | + */ | ||
44 | @GET | 53 | @GET |
45 | public Response getLinks(@QueryParam("device") String deviceId, | 54 | public Response getLinks(@QueryParam("device") String deviceId, |
46 | @QueryParam("port") String port, | 55 | @QueryParam("port") String port, | ... | ... |
... | @@ -33,13 +33,13 @@ import java.io.IOException; | ... | @@ -33,13 +33,13 @@ import java.io.IOException; |
33 | import java.io.InputStream; | 33 | import java.io.InputStream; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | - * REST resource for injecting and retrieving common network configuration. | 36 | + * Manage network configurations. |
37 | */ | 37 | */ |
38 | @Path("network/configuration") | 38 | @Path("network/configuration") |
39 | public class NetworkConfigWebResource extends AbstractWebResource { | 39 | public class NetworkConfigWebResource extends AbstractWebResource { |
40 | 40 | ||
41 | /** | 41 | /** |
42 | - * Returns entire network configuration base. | 42 | + * Get entire network configuration base. |
43 | * | 43 | * |
44 | * @return network configuration JSON | 44 | * @return network configuration JSON |
45 | */ | 45 | */ |
... | @@ -55,7 +55,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -55,7 +55,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
55 | } | 55 | } |
56 | 56 | ||
57 | /** | 57 | /** |
58 | - * Returns the network configuration for the specified subject class. | 58 | + * Get all network configuration for a subject class. |
59 | * | 59 | * |
60 | * @param subjectKey subject class key | 60 | * @param subjectKey subject class key |
61 | * @return network configuration JSON | 61 | * @return network configuration JSON |
... | @@ -72,7 +72,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -72,7 +72,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
72 | } | 72 | } |
73 | 73 | ||
74 | /** | 74 | /** |
75 | - * Returns the network configuration for the specified subject. | 75 | + * Get all network configuration for a subject. |
76 | * | 76 | * |
77 | * @param subjectKey subject class key | 77 | * @param subjectKey subject class key |
78 | * @param subject subject key | 78 | * @param subject subject key |
... | @@ -92,8 +92,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -92,8 +92,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
92 | } | 92 | } |
93 | 93 | ||
94 | /** | 94 | /** |
95 | - * Returns the network configuration for the specified subject and given | 95 | + * Get specific network configuration for a subject. |
96 | - * configuration class. | ||
97 | * | 96 | * |
98 | * @param subjectKey subject class key | 97 | * @param subjectKey subject class key |
99 | * @param subject subject key | 98 | * @param subject subject key |
... | @@ -126,7 +125,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -126,7 +125,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
126 | 125 | ||
127 | 126 | ||
128 | /** | 127 | /** |
129 | - * Uploads network configuration in bulk. | 128 | + * Upload bulk network configuration. |
130 | * | 129 | * |
131 | * @param request network configuration JSON rooted at the top node | 130 | * @param request network configuration JSON rooted at the top node |
132 | * @throws IOException if unable to parse the request | 131 | * @throws IOException if unable to parse the request |
... | @@ -145,7 +144,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -145,7 +144,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
145 | } | 144 | } |
146 | 145 | ||
147 | /** | 146 | /** |
148 | - * Uploads network configuration for the specified subject class. | 147 | + * Upload multiple network configurations for a subject class. |
149 | * | 148 | * |
150 | * @param subjectKey subject class key | 149 | * @param subjectKey subject class key |
151 | * @param request network configuration JSON rooted at the top node | 150 | * @param request network configuration JSON rooted at the top node |
... | @@ -165,7 +164,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -165,7 +164,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
165 | } | 164 | } |
166 | 165 | ||
167 | /** | 166 | /** |
168 | - * Uploads network configuration for the specified subject. | 167 | + * Upload mutliple network configurations for a subject. |
169 | * | 168 | * |
170 | * @param subjectKey subject class key | 169 | * @param subjectKey subject class key |
171 | * @param subject subject key | 170 | * @param subject subject key |
... | @@ -189,8 +188,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -189,8 +188,7 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
189 | } | 188 | } |
190 | 189 | ||
191 | /** | 190 | /** |
192 | - * Uploads network configuration for the specified subject and given | 191 | + * Upload specific network configuration for a subject. |
193 | - * configuration class. | ||
194 | * | 192 | * |
195 | * @param subjectKey subject class key | 193 | * @param subjectKey subject class key |
196 | * @param subject subject key | 194 | * @param subject subject key |
... | @@ -232,79 +230,76 @@ public class NetworkConfigWebResource extends AbstractWebResource { | ... | @@ -232,79 +230,76 @@ public class NetworkConfigWebResource extends AbstractWebResource { |
232 | 230 | ||
233 | 231 | ||
234 | /** | 232 | /** |
235 | - * Clears network configuration for the specified subject. | 233 | + * Clear entire network configuration base. |
236 | * | 234 | * |
237 | - * @param subjectKey subject class key | ||
238 | - * @param subject subject key | ||
239 | * @return empty response | 235 | * @return empty response |
240 | */ | 236 | */ |
241 | @DELETE | 237 | @DELETE |
242 | - @Path("{subjectKey}/{subject}") | ||
243 | @SuppressWarnings("unchecked") | 238 | @SuppressWarnings("unchecked") |
244 | - public Response delete(@PathParam("subjectKey") String subjectKey, | 239 | + public Response delete() { |
245 | - @PathParam("subject") String subject) { | ||
246 | NetworkConfigService service = get(NetworkConfigService.class); | 240 | NetworkConfigService service = get(NetworkConfigService.class); |
247 | - Object s = service.getSubjectFactory(subjectKey).createSubject(subject); | 241 | + service.getSubjectClasses() |
248 | - service.getConfigs(s).forEach(c -> service.removeConfig(s, c.getClass())); | 242 | + .forEach(subjectClass -> service.getSubjects(subjectClass) |
243 | + .forEach(subject -> service.getConfigs(subject) | ||
244 | + .forEach(config -> service | ||
245 | + .removeConfig(subject, config.getClass())))); | ||
249 | return Response.ok().build(); | 246 | return Response.ok().build(); |
250 | } | 247 | } |
251 | 248 | ||
252 | /** | 249 | /** |
253 | - * Clears network configuration for the specified subject and given | 250 | + * Clear all network configurations for a subject class. |
254 | - * configuration class. | ||
255 | * | 251 | * |
256 | * @param subjectKey subject class key | 252 | * @param subjectKey subject class key |
257 | - * @param subject subject key | ||
258 | - * @param configKey configuration class key | ||
259 | * @return empty response | 253 | * @return empty response |
260 | */ | 254 | */ |
261 | @DELETE | 255 | @DELETE |
262 | - @Path("{subjectKey}/{subject}/{configKey}") | 256 | + @Path("{subjectKey}") |
263 | @SuppressWarnings("unchecked") | 257 | @SuppressWarnings("unchecked") |
264 | - public Response delete(@PathParam("subjectKey") String subjectKey, | 258 | + public Response delete(@PathParam("subjectKey") String subjectKey) { |
265 | - @PathParam("subject") String subject, | ||
266 | - @PathParam("configKey") String configKey) { | ||
267 | NetworkConfigService service = get(NetworkConfigService.class); | 259 | NetworkConfigService service = get(NetworkConfigService.class); |
268 | - service.removeConfig(service.getSubjectFactory(subjectKey).createSubject(subject), | 260 | + service.getSubjects(service.getSubjectFactory(subjectKey).getClass()) |
269 | - service.getConfigClass(subjectKey, configKey)); | 261 | + .forEach(subject -> service.getConfigs(subject) |
262 | + .forEach(config -> service | ||
263 | + .removeConfig(subject, config.getClass()))); | ||
270 | return Response.ok().build(); | 264 | return Response.ok().build(); |
271 | } | 265 | } |
272 | 266 | ||
273 | - | ||
274 | /** | 267 | /** |
275 | - * Clears all network configurations. | 268 | + * Clear all network configurations for a subject. |
276 | * | 269 | * |
270 | + * @param subjectKey subject class key | ||
271 | + * @param subject subject key | ||
277 | * @return empty response | 272 | * @return empty response |
278 | */ | 273 | */ |
279 | @DELETE | 274 | @DELETE |
275 | + @Path("{subjectKey}/{subject}") | ||
280 | @SuppressWarnings("unchecked") | 276 | @SuppressWarnings("unchecked") |
281 | - public Response delete() { | 277 | + public Response delete(@PathParam("subjectKey") String subjectKey, |
278 | + @PathParam("subject") String subject) { | ||
282 | NetworkConfigService service = get(NetworkConfigService.class); | 279 | NetworkConfigService service = get(NetworkConfigService.class); |
283 | - service.getSubjectClasses() | 280 | + Object s = service.getSubjectFactory(subjectKey).createSubject(subject); |
284 | - .forEach(subjectClass -> service.getSubjects(subjectClass) | 281 | + service.getConfigs(s).forEach(c -> service.removeConfig(s, c.getClass())); |
285 | - .forEach(subject -> service.getConfigs(subject) | ||
286 | - .forEach(config -> service | ||
287 | - .removeConfig(subject, config.getClass())))); | ||
288 | return Response.ok().build(); | 282 | return Response.ok().build(); |
289 | } | 283 | } |
290 | 284 | ||
291 | - | ||
292 | - // TODO: this one below doesn't work correctly | ||
293 | /** | 285 | /** |
294 | - * Clears network configuration for the specified subject class. | 286 | + * Clear specific network configuration for a subject. |
295 | * | 287 | * |
296 | * @param subjectKey subject class key | 288 | * @param subjectKey subject class key |
289 | + * @param subject subject key | ||
290 | + * @param configKey configuration class key | ||
297 | * @return empty response | 291 | * @return empty response |
298 | */ | 292 | */ |
299 | @DELETE | 293 | @DELETE |
300 | - @Path("{subjectKey}/") | 294 | + @Path("{subjectKey}/{subject}/{configKey}") |
301 | @SuppressWarnings("unchecked") | 295 | @SuppressWarnings("unchecked") |
302 | - public Response delete(@PathParam("subjectKey") String subjectKey) { | 296 | + public Response delete(@PathParam("subjectKey") String subjectKey, |
297 | + @PathParam("subject") String subject, | ||
298 | + @PathParam("configKey") String configKey) { | ||
303 | NetworkConfigService service = get(NetworkConfigService.class); | 299 | NetworkConfigService service = get(NetworkConfigService.class); |
304 | - service.getSubjects(service.getSubjectFactory(subjectKey).getClass()) | 300 | + service.removeConfig(service.getSubjectFactory(subjectKey).createSubject(subject), |
305 | - .forEach(subject -> service.getConfigs(subject) | 301 | + service.getConfigClass(subjectKey, configKey)); |
306 | - .forEach(config -> service | ||
307 | - .removeConfig(subject, config.getClass()))); | ||
308 | return Response.ok().build(); | 302 | return Response.ok().build(); |
309 | } | 303 | } |
304 | + | ||
310 | } | 305 | } | ... | ... |
... | @@ -33,7 +33,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; | ... | @@ -33,7 +33,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode; |
33 | import org.onosproject.rest.AbstractWebResource; | 33 | import org.onosproject.rest.AbstractWebResource; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | - * REST resource for interacting with path calculations. | 36 | + * Compute paths in the network graph. |
37 | */ | 37 | */ |
38 | @Path("paths") | 38 | @Path("paths") |
39 | public class PathsWebResource extends AbstractWebResource { | 39 | public class PathsWebResource extends AbstractWebResource { |
... | @@ -46,19 +46,15 @@ public class PathsWebResource extends AbstractWebResource { | ... | @@ -46,19 +46,15 @@ public class PathsWebResource extends AbstractWebResource { |
46 | * @return HostId if the id is valid, null otherwise | 46 | * @return HostId if the id is valid, null otherwise |
47 | */ | 47 | */ |
48 | private HostId isHostId(String id) { | 48 | private HostId isHostId(String id) { |
49 | - | 49 | + return id.matches("..:..:..:..:..:../.*") ? HostId.hostId(id) : null; |
50 | - if (!id.matches("..:..:..:..:..:../.*")) { | ||
51 | - return null; | ||
52 | - } | ||
53 | - | ||
54 | - return HostId.hostId(id); | ||
55 | } | 50 | } |
56 | 51 | ||
57 | /** | 52 | /** |
58 | - * Gets the paths between two elements. | 53 | + * Get all shortest paths between any two hosts or devices. |
54 | + * Returns array of all shortest paths between any two elements. | ||
59 | * | 55 | * |
60 | - * @param src source | 56 | + * @param src source identifier |
61 | - * @param dst destination | 57 | + * @param dst destination identifier |
62 | * @return path data | 58 | * @return path data |
63 | */ | 59 | */ |
64 | @GET | 60 | @GET |
... | @@ -81,10 +77,8 @@ public class PathsWebResource extends AbstractWebResource { | ... | @@ -81,10 +77,8 @@ public class PathsWebResource extends AbstractWebResource { |
81 | dstElement = DeviceId.deviceId(dst); | 77 | dstElement = DeviceId.deviceId(dst); |
82 | } | 78 | } |
83 | 79 | ||
84 | - Set<org.onosproject.net.Path> paths = | 80 | + Set<org.onosproject.net.Path> paths = pathService.getPaths(srcElement, dstElement); |
85 | - pathService.getPaths(srcElement, dstElement); | 81 | + ObjectNode root = encodeArray(org.onosproject.net.Path.class, "paths", paths); |
86 | - ObjectNode root = | ||
87 | - encodeArray(org.onosproject.net.Path.class, "paths", paths); | ||
88 | return ok(root).build(); | 82 | return ok(root).build(); |
89 | } | 83 | } |
90 | 84 | ... | ... |
... | @@ -44,7 +44,7 @@ import static org.onosproject.net.DeviceId.deviceId; | ... | @@ -44,7 +44,7 @@ import static org.onosproject.net.DeviceId.deviceId; |
44 | import static org.onosproject.net.PortNumber.portNumber; | 44 | import static org.onosproject.net.PortNumber.portNumber; |
45 | 45 | ||
46 | /** | 46 | /** |
47 | - * Statistics REST APIs. | 47 | + * Query flow statistics. |
48 | */ | 48 | */ |
49 | @Path("statistics") | 49 | @Path("statistics") |
50 | public class StatisticsWebResource extends AbstractWebResource { | 50 | public class StatisticsWebResource extends AbstractWebResource { |
... | @@ -52,7 +52,7 @@ public class StatisticsWebResource extends AbstractWebResource { | ... | @@ -52,7 +52,7 @@ public class StatisticsWebResource extends AbstractWebResource { |
52 | UriInfo uriInfo; | 52 | UriInfo uriInfo; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | - * Gets the Load statistics for all links, or for a specific link. | 55 | + * Get load statistics for all links or for a specific link. |
56 | * | 56 | * |
57 | * @param deviceId (optional) device ID for a specific link | 57 | * @param deviceId (optional) device ID for a specific link |
58 | * @param port (optional) port number for a specified link | 58 | * @param port (optional) port number for a specified link |
... | @@ -77,7 +77,6 @@ public class StatisticsWebResource extends AbstractWebResource { | ... | @@ -77,7 +77,6 @@ public class StatisticsWebResource extends AbstractWebResource { |
77 | JsonCodec<Load> loadCodec = codec(Load.class); | 77 | JsonCodec<Load> loadCodec = codec(Load.class); |
78 | StatisticService statsService = getService(StatisticService.class); | 78 | StatisticService statsService = getService(StatisticService.class); |
79 | 79 | ||
80 | - | ||
81 | StreamSupport.stream(Spliterators.spliteratorUnknownSize( | 80 | StreamSupport.stream(Spliterators.spliteratorUnknownSize( |
82 | links.iterator(), Spliterator.ORDERED), false) | 81 | links.iterator(), Spliterator.ORDERED), false) |
83 | .forEach(link -> { | 82 | .forEach(link -> { | ... | ... |
... | @@ -39,16 +39,15 @@ import java.util.List; | ... | @@ -39,16 +39,15 @@ import java.util.List; |
39 | import static org.onlab.util.Tools.nullIsNotFound; | 39 | import static org.onlab.util.Tools.nullIsNotFound; |
40 | 40 | ||
41 | /** | 41 | /** |
42 | - * REST resource for interacting with the inventory of clusters. | 42 | + * Query network topology graph and its components. |
43 | */ | 43 | */ |
44 | - | ||
45 | @Path("topology") | 44 | @Path("topology") |
46 | public class TopologyWebResource extends AbstractWebResource { | 45 | public class TopologyWebResource extends AbstractWebResource { |
47 | 46 | ||
48 | public static final String CLUSTER_NOT_FOUND = "Cluster is not found"; | 47 | public static final String CLUSTER_NOT_FOUND = "Cluster is not found"; |
49 | 48 | ||
50 | /** | 49 | /** |
51 | - * Gets the topology overview for a REST GET operation. | 50 | + * Get overview of current topology. |
52 | * | 51 | * |
53 | * @return topology overview | 52 | * @return topology overview |
54 | */ | 53 | */ |
... | @@ -61,7 +60,7 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -61,7 +60,7 @@ public class TopologyWebResource extends AbstractWebResource { |
61 | } | 60 | } |
62 | 61 | ||
63 | /** | 62 | /** |
64 | - * Gets the topology clusters overview for a REST GET operation. | 63 | + * Get overview of topology SCCs. |
65 | * | 64 | * |
66 | * @return topology clusters overview | 65 | * @return topology clusters overview |
67 | */ | 66 | */ |
... | @@ -77,7 +76,7 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -77,7 +76,7 @@ public class TopologyWebResource extends AbstractWebResource { |
77 | } | 76 | } |
78 | 77 | ||
79 | /** | 78 | /** |
80 | - * Gets details for a topology cluster for a REST GET operation. | 79 | + * Get details of a specific SCC. |
81 | * | 80 | * |
82 | * @param clusterId id of the cluster to query | 81 | * @param clusterId id of the cluster to query |
83 | * @return topology cluster details | 82 | * @return topology cluster details |
... | @@ -100,7 +99,7 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -100,7 +99,7 @@ public class TopologyWebResource extends AbstractWebResource { |
100 | } | 99 | } |
101 | 100 | ||
102 | /** | 101 | /** |
103 | - * Gets devices for a topology cluster for a REST GET operation. | 102 | + * Get devices in a specific SCC. |
104 | * | 103 | * |
105 | * @param clusterId id of the cluster to query | 104 | * @param clusterId id of the cluster to query |
106 | * @return topology cluster devices | 105 | * @return topology cluster devices |
... | @@ -123,7 +122,7 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -123,7 +122,7 @@ public class TopologyWebResource extends AbstractWebResource { |
123 | } | 122 | } |
124 | 123 | ||
125 | /** | 124 | /** |
126 | - * Gets links for a topology cluster for a REST GET operation. | 125 | + * Get links in specific SCC. |
127 | * | 126 | * |
128 | * @param clusterId id of the cluster to query | 127 | * @param clusterId id of the cluster to query |
129 | * @return topology cluster links | 128 | * @return topology cluster links |
... | @@ -171,18 +170,16 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -171,18 +170,16 @@ public class TopologyWebResource extends AbstractWebResource { |
171 | } | 170 | } |
172 | 171 | ||
173 | /** | 172 | /** |
174 | - * Gets the broadcast flag of a connect point for a REST GET operation. | 173 | + * Test if a connect point is in broadcast set. |
175 | * | 174 | * |
176 | - * @param connectPointString string representation of the connect point to query. | 175 | + * @param connectPointString deviceid:portnumber |
177 | - * Format is deviceid:portnumber | ||
178 | * @return JSON representation of true if the connect point is broadcast, | 176 | * @return JSON representation of true if the connect point is broadcast, |
179 | * false otherwise | 177 | * false otherwise |
180 | */ | 178 | */ |
181 | @GET | 179 | @GET |
182 | @Produces(MediaType.APPLICATION_JSON) | 180 | @Produces(MediaType.APPLICATION_JSON) |
183 | @Path("broadcast/{connectPoint}") | 181 | @Path("broadcast/{connectPoint}") |
184 | - public Response getConnectPointBroadcast( | 182 | + public Response getConnectPointBroadcast(@PathParam("connectPoint") String connectPointString) { |
185 | - @PathParam("connectPoint") String connectPointString) { | ||
186 | Topology topology = get(TopologyService.class).currentTopology(); | 183 | Topology topology = get(TopologyService.class).currentTopology(); |
187 | 184 | ||
188 | DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString)); | 185 | DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString)); |
... | @@ -197,18 +194,16 @@ public class TopologyWebResource extends AbstractWebResource { | ... | @@ -197,18 +194,16 @@ public class TopologyWebResource extends AbstractWebResource { |
197 | } | 194 | } |
198 | 195 | ||
199 | /** | 196 | /** |
200 | - * Gets the infrastructure flag of a connect point for a REST GET operation. | 197 | + * Test if a connect point is infrastructure or edge. |
201 | * | 198 | * |
202 | - * @param connectPointString string representation of the connect point to query. | 199 | + * @param connectPointString deviceid:portnumber |
203 | - * Format is deviceid:portnumber | ||
204 | * @return JSON representation of true if the connect point is broadcast, | 200 | * @return JSON representation of true if the connect point is broadcast, |
205 | * false otherwise | 201 | * false otherwise |
206 | */ | 202 | */ |
207 | @GET | 203 | @GET |
208 | @Produces(MediaType.APPLICATION_JSON) | 204 | @Produces(MediaType.APPLICATION_JSON) |
209 | @Path("infrastructure/{connectPoint}") | 205 | @Path("infrastructure/{connectPoint}") |
210 | - public Response getConnectPointInfrastructure( | 206 | + public Response getConnectPointInfrastructure(@PathParam("connectPoint") String connectPointString) { |
211 | - @PathParam("connectPoint") String connectPointString) { | ||
212 | Topology topology = get(TopologyService.class).currentTopology(); | 207 | Topology topology = get(TopologyService.class).currentTopology(); |
213 | 208 | ||
214 | DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString)); | 209 | DeviceId deviceId = DeviceId.deviceId(getDeviceId(connectPointString)); | ... | ... |
This diff is collapsed. Click to expand it.
1 | +/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ | ||
2 | +html, | ||
3 | +body, | ||
4 | +div, | ||
5 | +span, | ||
6 | +applet, | ||
7 | +object, | ||
8 | +iframe, | ||
9 | +h1, | ||
10 | +h2, | ||
11 | +h3, | ||
12 | +h4, | ||
13 | +h5, | ||
14 | +h6, | ||
15 | +p, | ||
16 | +blockquote, | ||
17 | +pre, | ||
18 | +a, | ||
19 | +abbr, | ||
20 | +acronym, | ||
21 | +address, | ||
22 | +big, | ||
23 | +cite, | ||
24 | +code, | ||
25 | +del, | ||
26 | +dfn, | ||
27 | +em, | ||
28 | +img, | ||
29 | +ins, | ||
30 | +kbd, | ||
31 | +q, | ||
32 | +s, | ||
33 | +samp, | ||
34 | +small, | ||
35 | +strike, | ||
36 | +strong, | ||
37 | +sub, | ||
38 | +sup, | ||
39 | +tt, | ||
40 | +var, | ||
41 | +b, | ||
42 | +u, | ||
43 | +i, | ||
44 | +center, | ||
45 | +dl, | ||
46 | +dt, | ||
47 | +dd, | ||
48 | +ol, | ||
49 | +ul, | ||
50 | +li, | ||
51 | +fieldset, | ||
52 | +form, | ||
53 | +label, | ||
54 | +legend, | ||
55 | +table, | ||
56 | +caption, | ||
57 | +tbody, | ||
58 | +tfoot, | ||
59 | +thead, | ||
60 | +tr, | ||
61 | +th, | ||
62 | +td, | ||
63 | +article, | ||
64 | +aside, | ||
65 | +canvas, | ||
66 | +details, | ||
67 | +embed, | ||
68 | +figure, | ||
69 | +figcaption, | ||
70 | +footer, | ||
71 | +header, | ||
72 | +hgroup, | ||
73 | +menu, | ||
74 | +nav, | ||
75 | +output, | ||
76 | +ruby, | ||
77 | +section, | ||
78 | +summary, | ||
79 | +time, | ||
80 | +mark, | ||
81 | +audio, | ||
82 | +video { | ||
83 | + margin: 0; | ||
84 | + padding: 0; | ||
85 | + border: 0; | ||
86 | + font-size: 100%; | ||
87 | + font: inherit; | ||
88 | + vertical-align: baseline; | ||
89 | +} | ||
90 | +/* HTML5 display-role reset for older browsers */ | ||
91 | +article, | ||
92 | +aside, | ||
93 | +details, | ||
94 | +figcaption, | ||
95 | +figure, | ||
96 | +footer, | ||
97 | +header, | ||
98 | +hgroup, | ||
99 | +menu, | ||
100 | +nav, | ||
101 | +section { | ||
102 | + display: block; | ||
103 | +} | ||
104 | +body { | ||
105 | + line-height: 1; | ||
106 | +} | ||
107 | +ol, | ||
108 | +ul { | ||
109 | + list-style: none; | ||
110 | +} | ||
111 | +blockquote, | ||
112 | +q { | ||
113 | + quotes: none; | ||
114 | +} | ||
115 | +blockquote:before, | ||
116 | +blockquote:after, | ||
117 | +q:before, | ||
118 | +q:after { | ||
119 | + content: ''; | ||
120 | + content: none; | ||
121 | +} | ||
122 | +table { | ||
123 | + border-collapse: collapse; | ||
124 | + border-spacing: 0; | ||
125 | +} |
This diff is collapsed. Click to expand it.
File mode changed
1.56 KB
5.61 KB
web/api/src/main/resources/docs/index.html
0 → 100644
1 | +<!-- Adapted from Swagger UI --> | ||
2 | +<!DOCTYPE html> | ||
3 | +<html> | ||
4 | +<head> | ||
5 | + <title>ONOS API Docs</title> | ||
6 | + <link rel="icon" type="image/png" href="images/onos-logo.png"/> | ||
7 | + | ||
8 | + <link href='css/typography.css' media='screen' rel='stylesheet' type='text/css'/> | ||
9 | + <link href='css/reset.css' media='screen' rel='stylesheet' type='text/css'/> | ||
10 | + <link href='css/screen.css' media='screen' rel='stylesheet' type='text/css'/> | ||
11 | + <link href='css/reset.css' media='print' rel='stylesheet' type='text/css'/> | ||
12 | + <link href='css/print.css' media='print' rel='stylesheet' type='text/css'/> | ||
13 | + <script src='lib/jquery-1.8.0.min.js' type='text/javascript'></script> | ||
14 | + <script src='lib/jquery.slideto.min.js' type='text/javascript'></script> | ||
15 | + <script src='lib/jquery.wiggle.min.js' type='text/javascript'></script> | ||
16 | + <script src='lib/jquery.ba-bbq.min.js' type='text/javascript'></script> | ||
17 | + <script src='lib/handlebars-2.0.0.js' type='text/javascript'></script> | ||
18 | + <script src='lib/underscore-min.js' type='text/javascript'></script> | ||
19 | + <script src='lib/backbone-min.js' type='text/javascript'></script> | ||
20 | + <script src='swagger-ui.js' type='text/javascript'></script> | ||
21 | + <script src='lib/highlight.7.3.pack.js' type='text/javascript'></script> | ||
22 | + <script src='lib/marked.js' type='text/javascript'></script> | ||
23 | + <script src='lib/swagger-oauth.js' type='text/javascript'></script> | ||
24 | + | ||
25 | + <script type="text/javascript"> | ||
26 | + $(function () { | ||
27 | + var url = window.location.search.match(/url=([^&]+)/); | ||
28 | + if (url && url.length > 1) { | ||
29 | + url = decodeURIComponent(url[1]); | ||
30 | + } else { | ||
31 | + url = "/onos/v1/docs/apis/onos/v1/swagger.json"; | ||
32 | + } | ||
33 | + window.swaggerUi = new SwaggerUi({ | ||
34 | + url: url, | ||
35 | + dom_id: "swagger-ui-container", | ||
36 | + supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'], | ||
37 | + onComplete: function(swaggerApi, swaggerUi){ | ||
38 | + if(typeof initOAuth == "function") { | ||
39 | + initOAuth({ | ||
40 | + clientId: "your-client-id", | ||
41 | + realm: "your-realms", | ||
42 | + appName: "your-app-name" | ||
43 | + }); | ||
44 | + } | ||
45 | + | ||
46 | + $('pre code').each(function(i, e) { | ||
47 | + hljs.highlightBlock(e) | ||
48 | + }); | ||
49 | + | ||
50 | + addApiKeyAuthorization(); | ||
51 | + }, | ||
52 | + onFailure: function(data) { | ||
53 | + log("Unable to Load SwaggerUI"); | ||
54 | + }, | ||
55 | + docExpansion: "none", | ||
56 | + apisSorter: "alpha", | ||
57 | + showRequestHeaders: false | ||
58 | + }); | ||
59 | + | ||
60 | + function addApiKeyAuthorization(){ | ||
61 | + var key = encodeURIComponent($('#input_apiKey')[0].value); | ||
62 | + if(key && key.trim() != "") { | ||
63 | + var apiKeyAuth = new SwaggerClient.ApiKeyAuthorization("api_key", key, "query"); | ||
64 | + window.swaggerUi.api.clientAuthorizations.add("api_key", apiKeyAuth); | ||
65 | + log("added key " + key); | ||
66 | + } | ||
67 | + } | ||
68 | + | ||
69 | + $('#input_apiKey').change(addApiKeyAuthorization); | ||
70 | + | ||
71 | + // if you have an apiKey you would like to pre-populate on the page for demonstration purposes... | ||
72 | + /* | ||
73 | + var apiKey = "myApiKeyXXXX123456789"; | ||
74 | + $('#input_apiKey').val(apiKey); | ||
75 | + */ | ||
76 | + | ||
77 | + window.swaggerUi.load(); | ||
78 | + | ||
79 | + function log() { | ||
80 | + if ('console' in window) { | ||
81 | + console.log.apply(console, arguments); | ||
82 | + } | ||
83 | + } | ||
84 | + }); | ||
85 | + | ||
86 | + function selectApi() { | ||
87 | + $('#input_baseUrl').val('/onos/v1/docs/apis' + $('select').val() + '/swagger.json'); | ||
88 | + $('#explore').click(); | ||
89 | + } | ||
90 | + </script> | ||
91 | +</head> | ||
92 | + | ||
93 | +<body class="swagger-section"> | ||
94 | +<div id='header'> | ||
95 | + <div class="swagger-ui-wrap"> | ||
96 | + <a id="logo" href="#"></a> | ||
97 | + <form id='api_selector'> | ||
98 | + <div class='input' id='selector'> | ||
99 | + <select onchange="selectApi()"> | ||
100 | + <!-- {API-START} --> | ||
101 | + <option value="v1">ONOS v1 Core</option> | ||
102 | + <option value="foo">ONOS Foo app</option> | ||
103 | + <option value="bar">ONOS Bar app</option> | ||
104 | + <!-- {API-END} --> | ||
105 | + </select> | ||
106 | + </div> | ||
107 | + <div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div> | ||
108 | + <div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div> | ||
109 | + <div class='input'><a id="explore" href="#">Explore</a></div> | ||
110 | + </form> | ||
111 | + </div> | ||
112 | +</div> | ||
113 | + | ||
114 | +<div id="message-bar" class="swagger-ui-wrap"> </div> | ||
115 | +<div id="swagger-ui-container" class="swagger-ui-wrap"></div> | ||
116 | +<div id="footer" class="swagger-ui-wrap"><a href="http://swagger.io/swagger-ui/">Swagger UI</a> adaptation</div> | ||
117 | +</body> | ||
118 | +</html> |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o<p.length;o++){if(e[p[o]]||p[o]=="no-highlight"){return p[o]}}}function c(q){var o=[];(function p(r,s){for(var t=r.firstChild;t;t=t.nextSibling){if(t.nodeType==3){s+=t.nodeValue.length}else{if(t.nodeName=="BR"){s+=1}else{if(t.nodeType==1){o.push({event:"start",offset:s,node:t});s=p(t,s);o.push({event:"stop",offset:s,node:t})}}}}return s})(q,0);return o}function j(x,v,w){var p=0;var y="";var r=[];function t(){if(x.length&&v.length){if(x[0].offset!=v[0].offset){return(x[0].offset<v[0].offset)?x:v}else{return v[0].event=="start"?x:v}}else{return x.length?x:v}}function s(A){function z(B){return" "+B.nodeName+'="'+l(B.value)+'"'}return"<"+A.nodeName+Array.prototype.map.call(A.attributes,z).join("")+">"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("</"+o.nodeName.toLowerCase()+">")}while(o!=u.node);r.splice(q,1);while(q<r.length){y+=s(r[q]);q++}}}}return y+l(w.substr(p))}function f(q){function o(s,r){return RegExp(s,"m"+(q.cI?"i":"")+(r?"g":""))}function p(y,w){if(y.compiled){return}y.compiled=true;var s=[];if(y.k){var r={};function z(A,t){t.split(" ").forEach(function(B){var C=B.split("|");r[C[0]]=[A,C[1]?Number(C[1]):1];s.push(C[0])})}y.lR=o(y.l||hljs.IR,true);if(typeof y.k=="string"){z("keyword",y.k)}else{for(var x in y.k){if(!y.k.hasOwnProperty(x)){continue}z(x,y.k[x])}}y.k=r}if(w){if(y.bWK){y.b="\\b("+s.join("|")+")\\s"}y.bR=o(y.b?y.b:"\\B|\\b");if(!y.e&&!y.eW){y.e="\\B|\\b"}if(y.e){y.eR=o(y.e)}y.tE=y.e||"";if(y.eW&&w.tE){y.tE+=(y.e?"|":"")+w.tE}}if(y.i){y.iR=o(y.i)}if(y.r===undefined){y.r=1}if(!y.c){y.c=[]}for(var v=0;v<y.c.length;v++){if(y.c[v]=="self"){y.c[v]=y}p(y.c[v],y)}if(y.starts){p(y.starts,w)}var u=[];for(var v=0;v<y.c.length;v++){u.push(y.c[v].b)}if(y.tE){u.push(y.tE)}if(y.i){u.push(y.i)}y.t=u.length?o(u.join("|"),true):{exec:function(t){return null}}}p(q)}function d(D,E){function o(r,M){for(var L=0;L<M.c.length;L++){var K=M.c[L].bR.exec(r);if(K&&K.index==0){return M.c[L]}}}function s(K,r){if(K.e&&K.eR.test(r)){return K}if(K.eW){return s(K.parent,r)}}function t(r,K){return K.i&&K.iR.test(r)}function y(L,r){var K=F.cI?r[0].toLowerCase():r[0];return L.k.hasOwnProperty(K)&&L.k[K]}function G(){var K=l(w);if(!A.k){return K}var r="";var N=0;A.lR.lastIndex=0;var L=A.lR.exec(K);while(L){r+=K.substr(N,L.index-N);var M=y(A,L);if(M){v+=M[1];r+='<span class="'+M[0]+'">'+L[0]+"</span>"}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return'<span class="'+r.language+'">'+r.value+"</span>"}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'<span class="'+L.cN+'">':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+="</span>"}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"<br>")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"<!DOCTYPE",e:">",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"<!--",e:"-->",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"<style(?=\\s|>|$)",e:">",k:{title:"style"},c:[b],starts:{e:"</style>",rE:true,sL:"css"}},{cN:"tag",b:"<script(?=\\s|>|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"</?",e:"/?>",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
1 | +/* | ||
2 | + * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 | ||
3 | + * http://benalman.com/projects/jquery-bbq-plugin/ | ||
4 | + * | ||
5 | + * Copyright (c) 2010 "Cowboy" Ben Alman | ||
6 | + * Dual licensed under the MIT and GPL licenses. | ||
7 | + * http://benalman.com/about/license/ | ||
8 | + */ | ||
9 | +(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this); | ||
10 | +/* | ||
11 | + * jQuery hashchange event - v1.2 - 2/11/2010 | ||
12 | + * http://benalman.com/projects/jquery-hashchange-plugin/ | ||
13 | + * | ||
14 | + * Copyright (c) 2010 "Cowboy" Ben Alman | ||
15 | + * Dual licensed under the MIT and GPL licenses. | ||
16 | + * http://benalman.com/about/license/ | ||
17 | + */ | ||
18 | +(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +(function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery); |
1 | +/* | ||
2 | +jQuery Wiggle | ||
3 | +Author: WonderGroup, Jordan Thomas | ||
4 | +URL: http://labs.wondergroup.com/demos/mini-ui/index.html | ||
5 | +License: MIT (http://en.wikipedia.org/wiki/MIT_License) | ||
6 | +*/ | ||
7 | +jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);} | ||
8 | +if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
This diff is collapsed. Click to expand it.
1 | +var appName; | ||
2 | +var popupMask; | ||
3 | +var popupDialog; | ||
4 | +var clientId; | ||
5 | +var realm; | ||
6 | +var oauth2KeyName; | ||
7 | +var redirect_uri; | ||
8 | + | ||
9 | +function handleLogin() { | ||
10 | + var scopes = []; | ||
11 | + | ||
12 | + var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions; | ||
13 | + if(auths) { | ||
14 | + var key; | ||
15 | + var defs = auths; | ||
16 | + for(key in defs) { | ||
17 | + var auth = defs[key]; | ||
18 | + if(auth.type === 'oauth2' && auth.scopes) { | ||
19 | + oauth2KeyName = key; | ||
20 | + var scope; | ||
21 | + if(Array.isArray(auth.scopes)) { | ||
22 | + // 1.2 support | ||
23 | + var i; | ||
24 | + for(i = 0; i < auth.scopes.length; i++) { | ||
25 | + scopes.push(auth.scopes[i]); | ||
26 | + } | ||
27 | + } | ||
28 | + else { | ||
29 | + // 2.0 support | ||
30 | + for(scope in auth.scopes) { | ||
31 | + scopes.push({scope: scope, description: auth.scopes[scope]}); | ||
32 | + } | ||
33 | + } | ||
34 | + } | ||
35 | + } | ||
36 | + } | ||
37 | + | ||
38 | + if(window.swaggerUi.api | ||
39 | + && window.swaggerUi.api.info) { | ||
40 | + appName = window.swaggerUi.api.info.title; | ||
41 | + } | ||
42 | + | ||
43 | + popupDialog = $( | ||
44 | + [ | ||
45 | + '<div class="api-popup-dialog">', | ||
46 | + '<div class="api-popup-title">Select OAuth2.0 Scopes</div>', | ||
47 | + '<div class="api-popup-content">', | ||
48 | + '<p>Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.', | ||
49 | + '<a href="#">Learn how to use</a>', | ||
50 | + '</p>', | ||
51 | + '<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>', | ||
52 | + '<ul class="api-popup-scopes">', | ||
53 | + '</ul>', | ||
54 | + '<p class="error-msg"></p>', | ||
55 | + '<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>', | ||
56 | + '</div>', | ||
57 | + '</div>'].join('')); | ||
58 | + $(document.body).append(popupDialog); | ||
59 | + | ||
60 | + popup = popupDialog.find('ul.api-popup-scopes').empty(); | ||
61 | + for (i = 0; i < scopes.length; i ++) { | ||
62 | + scope = scopes[i]; | ||
63 | + str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope; | ||
64 | + if (scope.description) { | ||
65 | + str += '<br/><span class="api-scope-desc">' + scope.description + '</span>'; | ||
66 | + } | ||
67 | + str += '</label></li>'; | ||
68 | + popup.append(str); | ||
69 | + } | ||
70 | + | ||
71 | + var $win = $(window), | ||
72 | + dw = $win.width(), | ||
73 | + dh = $win.height(), | ||
74 | + st = $win.scrollTop(), | ||
75 | + dlgWd = popupDialog.outerWidth(), | ||
76 | + dlgHt = popupDialog.outerHeight(), | ||
77 | + top = (dh -dlgHt)/2 + st, | ||
78 | + left = (dw - dlgWd)/2; | ||
79 | + | ||
80 | + popupDialog.css({ | ||
81 | + top: (top < 0? 0 : top) + 'px', | ||
82 | + left: (left < 0? 0 : left) + 'px' | ||
83 | + }); | ||
84 | + | ||
85 | + popupDialog.find('button.api-popup-cancel').click(function() { | ||
86 | + popupMask.hide(); | ||
87 | + popupDialog.hide(); | ||
88 | + popupDialog.empty(); | ||
89 | + popupDialog = []; | ||
90 | + }); | ||
91 | + | ||
92 | + $('button.api-popup-authbtn').unbind(); | ||
93 | + popupDialog.find('button.api-popup-authbtn').click(function() { | ||
94 | + popupMask.hide(); | ||
95 | + popupDialog.hide(); | ||
96 | + | ||
97 | + var authSchemes = window.swaggerUi.api.authSchemes; | ||
98 | + var host = window.location; | ||
99 | + var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); | ||
100 | + var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; | ||
101 | + var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; | ||
102 | + var url = null; | ||
103 | + | ||
104 | + for (var key in authSchemes) { | ||
105 | + if (authSchemes.hasOwnProperty(key)) { | ||
106 | + var flow = authSchemes[key].flow; | ||
107 | + | ||
108 | + if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) { | ||
109 | + var dets = authSchemes[key]; | ||
110 | + url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code'); | ||
111 | + window.swaggerUi.tokenName = dets.tokenName || 'access_token'; | ||
112 | + window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); | ||
113 | + } | ||
114 | + else if(authSchemes[key].grantTypes) { | ||
115 | + // 1.2 support | ||
116 | + var o = authSchemes[key].grantTypes; | ||
117 | + for(var t in o) { | ||
118 | + if(o.hasOwnProperty(t) && t === 'implicit') { | ||
119 | + var dets = o[t]; | ||
120 | + var ep = dets.loginEndpoint.url; | ||
121 | + url = dets.loginEndpoint.url + '?response_type=token'; | ||
122 | + window.swaggerUi.tokenName = dets.tokenName; | ||
123 | + } | ||
124 | + else if (o.hasOwnProperty(t) && t === 'accessCode') { | ||
125 | + var dets = o[t]; | ||
126 | + var ep = dets.tokenRequestEndpoint.url; | ||
127 | + url = dets.tokenRequestEndpoint.url + '?response_type=code'; | ||
128 | + window.swaggerUi.tokenName = dets.tokenName; | ||
129 | + } | ||
130 | + } | ||
131 | + } | ||
132 | + } | ||
133 | + } | ||
134 | + var scopes = [] | ||
135 | + var o = $('.api-popup-scopes').find('input:checked'); | ||
136 | + | ||
137 | + for(k =0; k < o.length; k++) { | ||
138 | + var scope = $(o[k]).attr('scope'); | ||
139 | + | ||
140 | + if (scopes.indexOf(scope) === -1) | ||
141 | + scopes.push(scope); | ||
142 | + } | ||
143 | + | ||
144 | + // Implicit auth recommends a state parameter. | ||
145 | + var state = Math.random (); | ||
146 | + | ||
147 | + window.enabledScopes=scopes; | ||
148 | + | ||
149 | + redirect_uri = redirectUrl; | ||
150 | + | ||
151 | + url += '&redirect_uri=' + encodeURIComponent(redirectUrl); | ||
152 | + url += '&realm=' + encodeURIComponent(realm); | ||
153 | + url += '&client_id=' + encodeURIComponent(clientId); | ||
154 | + url += '&scope=' + encodeURIComponent(scopes.join(' ')); | ||
155 | + url += '&state=' + encodeURIComponent(state); | ||
156 | + | ||
157 | + window.open(url); | ||
158 | + }); | ||
159 | + | ||
160 | + popupMask.show(); | ||
161 | + popupDialog.show(); | ||
162 | + return; | ||
163 | +} | ||
164 | + | ||
165 | + | ||
166 | +function handleLogout() { | ||
167 | + for(key in window.authorizations.authz){ | ||
168 | + window.authorizations.remove(key) | ||
169 | + } | ||
170 | + window.enabledScopes = null; | ||
171 | + $('.api-ic.ic-on').addClass('ic-off'); | ||
172 | + $('.api-ic.ic-on').removeClass('ic-on'); | ||
173 | + | ||
174 | + // set the info box | ||
175 | + $('.api-ic.ic-warning').addClass('ic-error'); | ||
176 | + $('.api-ic.ic-warning').removeClass('ic-warning'); | ||
177 | +} | ||
178 | + | ||
179 | +function initOAuth(opts) { | ||
180 | + var o = (opts||{}); | ||
181 | + var errors = []; | ||
182 | + | ||
183 | + appName = (o.appName||errors.push('missing appName')); | ||
184 | + popupMask = (o.popupMask||$('#api-common-mask')); | ||
185 | + popupDialog = (o.popupDialog||$('.api-popup-dialog')); | ||
186 | + clientId = (o.clientId||errors.push('missing client id')); | ||
187 | + realm = (o.realm||errors.push('missing realm')); | ||
188 | + | ||
189 | + if(errors.length > 0){ | ||
190 | + log('auth unable initialize oauth: ' + errors); | ||
191 | + return; | ||
192 | + } | ||
193 | + | ||
194 | + $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); | ||
195 | + $('.api-ic').unbind(); | ||
196 | + $('.api-ic').click(function(s) { | ||
197 | + if($(s.target).hasClass('ic-off')) | ||
198 | + handleLogin(); | ||
199 | + else { | ||
200 | + handleLogout(); | ||
201 | + } | ||
202 | + false; | ||
203 | + }); | ||
204 | +} | ||
205 | + | ||
206 | +window.processOAuthCode = function processOAuthCode(data) { | ||
207 | + var params = { | ||
208 | + 'client_id': clientId, | ||
209 | + 'code': data.code, | ||
210 | + 'grant_type': 'authorization_code', | ||
211 | + 'redirect_uri': redirect_uri | ||
212 | + } | ||
213 | + $.ajax( | ||
214 | + { | ||
215 | + url : window.swaggerUi.tokenUrl, | ||
216 | + type: "POST", | ||
217 | + data: params, | ||
218 | + success:function(data, textStatus, jqXHR) | ||
219 | + { | ||
220 | + onOAuthComplete(data); | ||
221 | + }, | ||
222 | + error: function(jqXHR, textStatus, errorThrown) | ||
223 | + { | ||
224 | + onOAuthComplete(""); | ||
225 | + } | ||
226 | + }); | ||
227 | +} | ||
228 | + | ||
229 | +window.onOAuthComplete = function onOAuthComplete(token) { | ||
230 | + if(token) { | ||
231 | + if(token.error) { | ||
232 | + var checkbox = $('input[type=checkbox],.secured') | ||
233 | + checkbox.each(function(pos){ | ||
234 | + checkbox[pos].checked = false; | ||
235 | + }); | ||
236 | + alert(token.error); | ||
237 | + } | ||
238 | + else { | ||
239 | + var b = token[window.swaggerUi.tokenName]; | ||
240 | + if(b){ | ||
241 | + // if all roles are satisfied | ||
242 | + var o = null; | ||
243 | + $.each($('.auth #api_information_panel'), function(k, v) { | ||
244 | + var children = v; | ||
245 | + if(children && children.childNodes) { | ||
246 | + var requiredScopes = []; | ||
247 | + $.each((children.childNodes), function (k1, v1){ | ||
248 | + var inner = v1.innerHTML; | ||
249 | + if(inner) | ||
250 | + requiredScopes.push(inner); | ||
251 | + }); | ||
252 | + var diff = []; | ||
253 | + for(var i=0; i < requiredScopes.length; i++) { | ||
254 | + var s = requiredScopes[i]; | ||
255 | + if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) { | ||
256 | + diff.push(s); | ||
257 | + } | ||
258 | + } | ||
259 | + if(diff.length > 0){ | ||
260 | + o = v.parentNode; | ||
261 | + $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); | ||
262 | + $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); | ||
263 | + | ||
264 | + // sorry, not all scopes are satisfied | ||
265 | + $(o).find('.api-ic').addClass('ic-warning'); | ||
266 | + $(o).find('.api-ic').removeClass('ic-error'); | ||
267 | + } | ||
268 | + else { | ||
269 | + o = v.parentNode; | ||
270 | + $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); | ||
271 | + $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); | ||
272 | + | ||
273 | + // all scopes are satisfied | ||
274 | + $(o).find('.api-ic').addClass('ic-info'); | ||
275 | + $(o).find('.api-ic').removeClass('ic-warning'); | ||
276 | + $(o).find('.api-ic').removeClass('ic-error'); | ||
277 | + } | ||
278 | + } | ||
279 | + }); | ||
280 | + window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); | ||
281 | + } | ||
282 | + } | ||
283 | + } | ||
284 | +} |
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
... | @@ -61,6 +61,7 @@ | ... | @@ -61,6 +61,7 @@ |
61 | org.onosproject.rest.exceptions.IllegalStateExceptionMapper, | 61 | org.onosproject.rest.exceptions.IllegalStateExceptionMapper, |
62 | org.onosproject.rest.resources.JsonBodyWriter, | 62 | org.onosproject.rest.resources.JsonBodyWriter, |
63 | 63 | ||
64 | + org.onosproject.rest.resources.ApiDocResource, | ||
64 | org.onosproject.rest.resources.ApplicationsWebResource, | 65 | org.onosproject.rest.resources.ApplicationsWebResource, |
65 | org.onosproject.rest.resources.ComponentConfigWebResource, | 66 | org.onosproject.rest.resources.ComponentConfigWebResource, |
66 | org.onosproject.rest.resources.NetworkConfigWebResource, | 67 | org.onosproject.rest.resources.NetworkConfigWebResource, | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.ui.impl; | ... | @@ -18,6 +18,7 @@ package org.onosproject.ui.impl; |
18 | import com.google.common.collect.ImmutableList; | 18 | import com.google.common.collect.ImmutableList; |
19 | import com.google.common.collect.ImmutableList.Builder; | 19 | import com.google.common.collect.ImmutableList.Builder; |
20 | import org.onlab.osgi.ServiceNotFoundException; | 20 | import org.onlab.osgi.ServiceNotFoundException; |
21 | +import org.onosproject.rest.AbstractInjectionResource; | ||
21 | import org.onosproject.ui.UiExtensionService; | 22 | import org.onosproject.ui.UiExtensionService; |
22 | 23 | ||
23 | import javax.ws.rs.GET; | 24 | import javax.ws.rs.GET; | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ui.impl; | 16 | package org.onosproject.ui.impl; |
17 | 17 | ||
18 | +import org.onosproject.rest.AbstractInjectionResource; | ||
18 | import org.onosproject.ui.UiExtension; | 19 | import org.onosproject.ui.UiExtension; |
19 | import org.onosproject.ui.UiExtensionService; | 20 | import org.onosproject.ui.UiExtensionService; |
20 | import org.onosproject.ui.UiView; | 21 | import org.onosproject.ui.UiView; | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ui.impl; | 16 | package org.onosproject.ui.impl; |
17 | 17 | ||
18 | +import org.onosproject.rest.AbstractInjectionResource; | ||
18 | import org.onosproject.ui.UiExtension; | 19 | import org.onosproject.ui.UiExtension; |
19 | import org.onosproject.ui.UiExtensionService; | 20 | import org.onosproject.ui.UiExtensionService; |
20 | import org.onosproject.ui.UiView; | 21 | import org.onosproject.ui.UiView; | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.ui.impl; | 16 | package org.onosproject.ui.impl; |
17 | 17 | ||
18 | +import org.onosproject.rest.AbstractInjectionResource; | ||
18 | import org.onosproject.ui.UiExtension; | 19 | import org.onosproject.ui.UiExtension; |
19 | import org.onosproject.ui.UiExtensionService; | 20 | import org.onosproject.ui.UiExtensionService; |
20 | 21 | ... | ... |
... | @@ -75,8 +75,6 @@ | ... | @@ -75,8 +75,6 @@ |
75 | <scope>test</scope> | 75 | <scope>test</scope> |
76 | </dependency> | 76 | </dependency> |
77 | 77 | ||
78 | - | ||
79 | - | ||
80 | <dependency> | 78 | <dependency> |
81 | <groupId>com.sun.jersey</groupId> | 79 | <groupId>com.sun.jersey</groupId> |
82 | <artifactId>jersey-servlet</artifactId> | 80 | <artifactId>jersey-servlet</artifactId> |
... | @@ -118,39 +116,6 @@ | ... | @@ -118,39 +116,6 @@ |
118 | <groupId>org.apache.felix</groupId> | 116 | <groupId>org.apache.felix</groupId> |
119 | <artifactId>maven-scr-plugin</artifactId> | 117 | <artifactId>maven-scr-plugin</artifactId> |
120 | </plugin> | 118 | </plugin> |
121 | - <plugin> | ||
122 | - <groupId>org.apache.felix</groupId> | ||
123 | - <artifactId>maven-bundle-plugin</artifactId> | ||
124 | - <extensions>true</extensions> | ||
125 | - <configuration> | ||
126 | - <instructions> | ||
127 | - <_wab>src/main/webapp/</_wab> | ||
128 | - <Bundle-SymbolicName> | ||
129 | - ${project.groupId}.${project.artifactId} | ||
130 | - </Bundle-SymbolicName> | ||
131 | - <Import-Package> | ||
132 | - org.slf4j, | ||
133 | - org.osgi.framework, | ||
134 | - javax.ws.rs,javax.ws.rs.core,javax.ws.rs.ext, | ||
135 | - com.sun.jersey.api, | ||
136 | - com.sun.jersey.spi.container.servlet, | ||
137 | - com.sun.jersey.server.impl.container.servlet, | ||
138 | - com.fasterxml.jackson.databind, | ||
139 | - com.fasterxml.jackson.databind.node, | ||
140 | - com.google.common.base.*, | ||
141 | - com.google.common.collect.*, | ||
142 | - com.google.common.io.*, | ||
143 | - org.eclipse.jetty.websocket.*, | ||
144 | - org.onlab.util.*, | ||
145 | - org.onlab.osgi.*, | ||
146 | - org.onlab.packet.*, | ||
147 | - org.onlab.rest.*, | ||
148 | - org.onosproject.* | ||
149 | - </Import-Package> | ||
150 | - <Web-ContextPath>${web.context}</Web-ContextPath> | ||
151 | - </instructions> | ||
152 | - </configuration> | ||
153 | - </plugin> | ||
154 | </plugins> | 119 | </plugins> |
155 | </build> | 120 | </build> |
156 | 121 | ... | ... |
-
Please register or login to post a comment