summaryrefslogtreecommitdiffstats
path: root/quantum-client/src
diff options
context:
space:
mode:
authorseshukm <seshu.kumar.m@huawei.com>2018-07-25 19:43:50 +0800
committerseshukm <seshu.kumar.m@huawei.com>2018-07-25 19:43:50 +0800
commit9e979f65650b6e261ddb550b7f209ba81ff9e58d (patch)
tree383d614069654bc574a5ca1e4466ab584935971d /quantum-client/src
parent9213aeb37885de296cc1aa4c2e05aba0a77eadd7 (diff)
code refactoring for quantum module
Issue-ID: SO-729 Change-Id: I4750ca1f77fcbd596d4b0873723ba020f5088f55 Signed-off-by: seshukm <seshu.kumar.m@huawei.com>
Diffstat (limited to 'quantum-client/src')
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java74
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java84
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java102
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java172
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java80
-rw-r--r--quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java116
6 files changed, 314 insertions, 314 deletions
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java
index fae9d53..ab64531 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/Quantum.java
@@ -26,42 +26,42 @@ import com.woorea.openstack.quantum.api.SubnetsResource;
public class Quantum extends OpenStackClient {
-
- private final NetworksResource NETWORKS;
-
- private final PortsResource PORTS;
-
- private final SubnetsResource SUBNETS;
- private final RoutersResource ROUTERS;
-
- public Quantum(String endpoint, OpenStackClientConnector connector) {
- super(endpoint, connector);
- NETWORKS = new NetworksResource(this);
- PORTS = new PortsResource(this);
- SUBNETS = new SubnetsResource(this);
- ROUTERS=new RoutersResource(this);
-
- }
-
- public Quantum(String endpoint) {
- this(endpoint, null);
- }
-
- public NetworksResource networks() {
- return NETWORKS;
- }
-
- public PortsResource ports() {
- return PORTS;
- }
-
- public SubnetsResource subnets() {
- return SUBNETS;
- }
- public RoutersResource routers()
- {
- return ROUTERS;
- }
-
+
+ private final NetworksResource NETWORKS;
+
+ private final PortsResource PORTS;
+
+ private final SubnetsResource SUBNETS;
+ private final RoutersResource ROUTERS;
+
+ public Quantum(String endpoint, OpenStackClientConnector connector) {
+ super(endpoint, connector);
+ NETWORKS = new NetworksResource(this);
+ PORTS = new PortsResource(this);
+ SUBNETS = new SubnetsResource(this);
+ ROUTERS=new RoutersResource(this);
+
+ }
+
+ public Quantum(String endpoint) {
+ this(endpoint, null);
+ }
+
+ public NetworksResource networks() {
+ return NETWORKS;
+ }
+
+ public PortsResource ports() {
+ return PORTS;
+ }
+
+ public SubnetsResource subnets() {
+ return SUBNETS;
+ }
+ public RoutersResource routers()
+ {
+ return ROUTERS;
+ }
+
}
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java
index abaf44c..e22487a 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/NetworksResource.java
@@ -26,56 +26,56 @@ import com.woorea.openstack.quantum.model.Networks;
public class NetworksResource {
- private final OpenStackClient CLIENT;
+ private final OpenStackClient CLIENT;
- public NetworksResource(OpenStackClient client) {
- CLIENT = client;
- }
+ public NetworksResource(OpenStackClient client) {
+ CLIENT = client;
+ }
- public List list() {
- return new List();
- }
+ public List list() {
+ return new List();
+ }
public Create create(Network net) {
- return new Create(net);
- }
+ return new Create(net);
+ }
public Update update(Network net) {
return new Update(net);
}
- public Delete delete(String netId){
- return new Delete(netId);
- }
+ public Delete delete(String netId){
+ return new Delete(netId);
+ }
- public Show show(String netId){
- return new Show(netId);
- }
+ public Show show(String netId){
+ return new Show(netId);
+ }
- public class List extends OpenStackRequest<Networks> {
+ public class List extends OpenStackRequest<Networks> {
- public List() {
- super(CLIENT, HttpMethod.GET, "networks", null, Networks.class);
- }
- }
+ public List() {
+ super(CLIENT, HttpMethod.GET, "networks", null, Networks.class);
+ }
+ }
- public class Query extends OpenStackRequest<Networks> {
+ public class Query extends OpenStackRequest<Networks> {
- public Query(Network network) {
- //super(network);
-// target = target.path("v2.0").path("networks");
-// target = queryParam(target);
-// return target.request(MediaType.APPLICATION_JSON).get(Networks.class);
- }
- }
+ public Query(Network network) {
+ //super(network);
+// target = target.path("v2.0").path("networks");
+// target = queryParam(target);
+// return target.request(MediaType.APPLICATION_JSON).get(Networks.class);
+ }
+ }
- public class Create extends OpenStackRequest<Network> {
+ public class Create extends OpenStackRequest<Network> {
public Create(Network net) {
- super(CLIENT, HttpMethod.POST, "networks", Entity.json(net), Network.class);
- }
- }
+ super(CLIENT, HttpMethod.POST, "networks", Entity.json(net), Network.class);
+ }
+ }
public class Update extends OpenStackRequest<Network> {
@@ -84,17 +84,17 @@ public class NetworksResource {
}
}
- public class Show extends OpenStackRequest<Network> {
+ public class Show extends OpenStackRequest<Network> {
- public Show(String id) {
- super(CLIENT, HttpMethod.GET, buildPath("networks/", id), null, Network.class);
- }
- }
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, buildPath("networks/", id), null, Network.class);
+ }
+ }
- public class Delete extends OpenStackRequest<Void> {
+ public class Delete extends OpenStackRequest<Void> {
- public Delete(String id){
- super(CLIENT, HttpMethod.DELETE, buildPath("networks/", id), null, Void.class);
- }
- }
+ public Delete(String id){
+ super(CLIENT, HttpMethod.DELETE, buildPath("networks/", id), null, Void.class);
+ }
+ }
}
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java
index ec34b53..2e1e840 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/PortsResource.java
@@ -26,76 +26,76 @@ import com.woorea.openstack.quantum.model.Ports;
public class PortsResource {
- private final OpenStackClient CLIENT;
+ private final OpenStackClient CLIENT;
- public PortsResource(OpenStackClient client) {
- CLIENT = client;
- }
+ public PortsResource(OpenStackClient client) {
+ CLIENT = client;
+ }
- public List list() {
- return new List();
- }
+ public List list() {
+ return new List();
+ }
- public Create create(Port port){
- return new Create(port);
- }
+ public Create create(Port port){
+ return new Create(port);
+ }
- public Update update(Port port){
- return new Update(port);
- }
+ public Update update(Port port){
+ return new Update(port);
+ }
- public Delete delete(String portId){
- return new Delete(portId);
- }
+ public Delete delete(String portId){
+ return new Delete(portId);
+ }
- public Show show(String portId){
- return new Show(portId);
- }
+ public Show show(String portId){
+ return new Show(portId);
+ }
- public class List extends OpenStackRequest<Ports> {
+ public class List extends OpenStackRequest<Ports> {
- public List() {
- super(CLIENT, HttpMethod.GET, "ports", null, Ports.class);
- }
- }
+ public List() {
+ super(CLIENT, HttpMethod.GET, "ports", null, Ports.class);
+ }
+ }
- public class Query extends OpenStackRequest<Ports> {
+ public class Query extends OpenStackRequest<Ports> {
- public Query(Port port) {
- //super(port);
-// target = target.path("v2.0").path("ports");
-// target = queryParam(target);
-// return target.request(MediaType.APPLICATION_JSON).get(Ports.class);
- }
+ public Query(Port port) {
+ //super(port);
+// target = target.path("v2.0").path("ports");
+// target = queryParam(target);
+// return target.request(MediaType.APPLICATION_JSON).get(Ports.class);
+ }
- }
+ }
- public class Create extends OpenStackRequest<Port> {
+ public class Create extends OpenStackRequest<Port> {
- public Create(Port port){
- super(CLIENT, HttpMethod.POST, "ports", Entity.json(port), Port.class);
- }
- }
+ public Create(Port port){
+ super(CLIENT, HttpMethod.POST, "ports", Entity.json(port), Port.class);
+ }
+ }
- public class Update extends OpenStackRequest<Port> {
+ public class Update extends OpenStackRequest<Port> {
- public Update(Port port){
- super(CLIENT, HttpMethod.PUT, buildPath("ports/", port.getId()), Entity.json(port), Port.class);
- }
- }
+ public Update(Port port){
+ super(CLIENT, HttpMethod.PUT, buildPath("ports/", port.getId()), Entity.json(port), Port.class);
+ }
+ }
- public class Show extends OpenStackRequest<Port> {
+ public class Show extends OpenStackRequest<Port> {
- public Show(String id) {
- super(CLIENT, HttpMethod.GET, buildPath("ports/", id), null, Port.class);
- }
- }
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, buildPath("ports/", id), null, Port.class);
+ }
+ }
- public class Delete extends OpenStackRequest<Void> {
+ public class Delete extends OpenStackRequest<Void> {
- public Delete(String id){
+ public Delete(String id){
super(CLIENT, HttpMethod.DELETE, buildPath("ports/", id), null, Void.class);
- }
- }
+ }
+ }
}
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java
index f0f8e20..e158e5f 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/RoutersResource.java
@@ -28,91 +28,91 @@ import com.woorea.openstack.quantum.model.Routers;
public class RoutersResource {
- private final OpenStackClient CLIENT;
-
- public RoutersResource(OpenStackClient client) {
- CLIENT = client;
- }
-
- public List list() {
- return new List();
- }
-
- public Create create(RouterForCreate router){
- return new Create(router);
- }
-
- public Delete delete(String netId){
- return new Delete(netId);
- }
-
- public Show show(String netId){
- return new Show(netId);
- }
-
- public class List extends OpenStackRequest<Routers> {
-
- public List() {
- super(CLIENT, HttpMethod.GET, "routers", null, Routers.class);
- }
- }
-
- public class Query extends OpenStackRequest<Routers> {
-
- public Query(Router router) {
- //super(network);
-// target = target.path("v2.0").path("networks");
-// target = queryParam(target);
-// return target.request(MediaType.APPLICATION_JSON).get(Networks.class);
- }
- }
- public class Create extends OpenStackRequest<Router> {
-
- public Create(RouterForCreate router){
- super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class);
- }
- }
-
-
-
- public class Show extends OpenStackRequest<Router> {
-
- public Show(String id) {
- super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class);
- }
- }
-
- public class Delete extends OpenStackRequest<Void> {
-
- public Delete(String id){
- super(CLIENT, HttpMethod.DELETE, buildPath("routers/", id), null, Void.class);
- }
- }
- public Attach addInterface(RouterForAddInterface interfaceToAdd){
- return new Attach(interfaceToAdd);
- }
- public class Attach extends OpenStackRequest<RouterInterface> {
-
- public Attach(RouterForAddInterface interfaceToAdd){
- super(CLIENT, HttpMethod.PUT, buildPath("routers/",interfaceToAdd.getRouterId(),"/add_router_interface"), Entity.json(interfaceToAdd),RouterInterface.class);
- }
-
- }
- public Detach deleteInterface(RouterForAddInterface interfaceRouter) {
- return new Detach(interfaceRouter);
- }
-
- public class Detach extends OpenStackRequest<RouterInterface> {
-
- public Detach(RouterForAddInterface interfaceToAdd) {
- super(CLIENT, HttpMethod.PUT, buildPath("routers/",
- interfaceToAdd.getRouterId(), "/remove_router_interface"),
- Entity.json(interfaceToAdd), RouterInterface.class);
- }
-
- }
-
-
-
+ private final OpenStackClient CLIENT;
+
+ public RoutersResource(OpenStackClient client) {
+ CLIENT = client;
+ }
+
+ public List list() {
+ return new List();
+ }
+
+ public Create create(RouterForCreate router){
+ return new Create(router);
+ }
+
+ public Delete delete(String netId){
+ return new Delete(netId);
+ }
+
+ public Show show(String netId){
+ return new Show(netId);
+ }
+
+ public class List extends OpenStackRequest<Routers> {
+
+ public List() {
+ super(CLIENT, HttpMethod.GET, "routers", null, Routers.class);
+ }
+ }
+
+ public class Query extends OpenStackRequest<Routers> {
+
+ public Query(Router router) {
+ //super(network);
+// target = target.path("v2.0").path("networks");
+// target = queryParam(target);
+// return target.request(MediaType.APPLICATION_JSON).get(Networks.class);
+ }
+ }
+ public class Create extends OpenStackRequest<Router> {
+
+ public Create(RouterForCreate router){
+ super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class);
+ }
+ }
+
+
+
+ public class Show extends OpenStackRequest<Router> {
+
+ public Show(String id) {
+ super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class);
+ }
+ }
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ public Delete(String id){
+ super(CLIENT, HttpMethod.DELETE, buildPath("routers/", id), null, Void.class);
+ }
+ }
+ public Attach addInterface(RouterForAddInterface interfaceToAdd){
+ return new Attach(interfaceToAdd);
+ }
+ public class Attach extends OpenStackRequest<RouterInterface> {
+
+ public Attach(RouterForAddInterface interfaceToAdd){
+ super(CLIENT, HttpMethod.PUT, buildPath("routers/",interfaceToAdd.getRouterId(),"/add_router_interface"), Entity.json(interfaceToAdd),RouterInterface.class);
+ }
+
+ }
+ public Detach deleteInterface(RouterForAddInterface interfaceRouter) {
+ return new Detach(interfaceRouter);
+ }
+
+ public class Detach extends OpenStackRequest<RouterInterface> {
+
+ public Detach(RouterForAddInterface interfaceToAdd) {
+ super(CLIENT, HttpMethod.PUT, buildPath("routers/",
+ interfaceToAdd.getRouterId(), "/remove_router_interface"),
+ Entity.json(interfaceToAdd), RouterInterface.class);
+ }
+
+ }
+
+
+
}
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java
index 56f1593..81f3750 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/SubnetsResource.java
@@ -26,56 +26,56 @@ import com.woorea.openstack.quantum.model.Subnets;
public class SubnetsResource {
- private final OpenStackClient CLIENT;
+ private final OpenStackClient CLIENT;
- public SubnetsResource(OpenStackClient client) {
- CLIENT = client;
- }
+ public SubnetsResource(OpenStackClient client) {
+ CLIENT = client;
+ }
- public List list() {
- return new List();
- }
+ public List list() {
+ return new List();
+ }
public Create create(Subnet net) {
- return new Create(net);
- }
+ return new Create(net);
+ }
public Update update(Subnet net) {
return new Update(net);
}
- public Delete delete(String netId){
- return new Delete(netId);
- }
+ public Delete delete(String netId){
+ return new Delete(netId);
+ }
- public Show show(String netId){
- return new Show(netId);
- }
+ public Show show(String netId){
+ return new Show(netId);
+ }
- public class List extends OpenStackRequest<Subnets> {
+ public class List extends OpenStackRequest<Subnets> {
- public List() {
- super(CLIENT, HttpMethod.GET, "subnets", null, Subnets.class);
- }
- }
+ public List() {
+ super(CLIENT, HttpMethod.GET, "subnets", null, Subnets.class);
+ }
+ }
- public class Query extends OpenStackRequest<Subnets> {
+ public class Query extends OpenStackRequest<Subnets> {
- public Query(Subnet subnet) {
- //super(subnet);
-// target = target.path("v2.0").path("subnets");
-// target = queryParam(target);
-// return target.request(MediaType.APPLICATION_JSON).get(Subnets.class);
- }
- }
+ public Query(Subnet subnet) {
+ //super(subnet);
+// target = target.path("v2.0").path("subnets");
+// target = queryParam(target);
+// return target.request(MediaType.APPLICATION_JSON).get(Subnets.class);
+ }
+ }
- public class Create extends OpenStackRequest<Subnet> {
+ public class Create extends OpenStackRequest<Subnet> {
public Create(Subnet subnet) {
- super(CLIENT, HttpMethod.POST, "subnets", Entity.json(subnet), Subnet.class);
- }
- }
+ super(CLIENT, HttpMethod.POST, "subnets", Entity.json(subnet), Subnet.class);
+ }
+ }
public class Update extends OpenStackRequest<Subnet> {
@@ -84,17 +84,17 @@ public class SubnetsResource {
}
}
- public class Show extends OpenStackRequest<Subnet> {
+ public class Show extends OpenStackRequest<Subnet> {
- public Show(String id) {
+ public Show(String id) {
super(CLIENT, HttpMethod.GET, buildPath("subnets/", id), null, Subnet.class);
- }
- }
+ }
+ }
- public class Delete extends OpenStackRequest<Void> {
+ public class Delete extends OpenStackRequest<Void> {
- public Delete(String id){
+ public Delete(String id){
super(CLIENT, HttpMethod.DELETE, buildPath("subnets/", id), null, Void.class);
- }
- }
+ }
+ }
}
diff --git a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java
index 2511b0c..1ba1bb6 100644
--- a/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java
+++ b/quantum-client/src/main/java/com/woorea/openstack/quantum/api/query/AbsOpenStackCmd.java
@@ -26,71 +26,71 @@ import com.woorea.openstack.base.client.OpenStackRequest;
public class AbsOpenStackCmd<T> extends OpenStackRequest<T> {
- private T query;
+ private T query;
- protected AbsOpenStackCmd(T query)
- {
- this.setQuery(query);
- }
+ protected AbsOpenStackCmd(T query)
+ {
+ this.setQuery(query);
+ }
- /**
- * @param query the query to set
- */
- public void setQuery(T query) {
- this.query = query;
- }
+ /**
+ * @param query the query to set
+ */
+ public void setQuery(T query) {
+ this.query = query;
+ }
- /**
- * @return the query
- */
- public T getQuery() {
- return query;
- }
+ /**
+ * @return the query
+ */
+ public T getQuery() {
+ return query;
+ }
- private String getFieldValue(Field field, T target)
- {
- try {
- field.setAccessible(true);
- Object obj = field.get(target);
- if (obj == null)
- return null;
- return obj.toString();
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
+ private String getFieldValue(Field field, T target)
+ {
+ try {
+ field.setAccessible(true);
+ Object obj = field.get(target);
+ if (obj == null)
+ return null;
+ return obj.toString();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
- private Map<String, String> getObjectParamMap(T target)
- {
- Map<String, String> resultMap = new HashMap<>();
- if (target == null)
- return resultMap;
+ private Map<String, String> getObjectParamMap(T target)
+ {
+ Map<String, String> resultMap = new HashMap<>();
+ if (target == null)
+ return resultMap;
- Field[] paramMap = target.getClass().getDeclaredFields();
- for (Field field : paramMap) {
- String resultName = field.getName();
- String value = getFieldValue(field, target);
- if (value != null) {
- JsonProperty prop = field.getAnnotation(JsonProperty.class);
- if (prop != null) {
- resultMap.put(prop.value(), getFieldValue(field, target));
- } else {
- resultMap.put(resultName, getFieldValue(field, target));
- }
- }
- }
+ Field[] paramMap = target.getClass().getDeclaredFields();
+ for (Field field : paramMap) {
+ String resultName = field.getName();
+ String value = getFieldValue(field, target);
+ if (value != null) {
+ JsonProperty prop = field.getAnnotation(JsonProperty.class);
+ if (prop != null) {
+ resultMap.put(prop.value(), getFieldValue(field, target));
+ } else {
+ resultMap.put(resultName, getFieldValue(field, target));
+ }
+ }
+ }
- return resultMap;
- }
+ return resultMap;
+ }
- /*
- public WebTarget queryParam(WebTarget target) {
- Map<String, String> map = getObjectParamMap(this.query);
- for (String fieldName : map.keySet()) {
- target = target.queryParam(fieldName, map.get(fieldName));
- }
- return target;
- }
- */
+ /*
+ public WebTarget queryParam(WebTarget target) {
+ Map<String, String> map = getObjectParamMap(this.query);
+ for (String fieldName : map.keySet()) {
+ target = target.queryParam(fieldName, map.get(fieldName));
+ }
+ return target;
+ }
+ */
}