From 3f9a0c3183480d150089c0d5a6e507c877f7d121 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steve (ss835w)" Date: Thu, 2 May 2019 09:42:55 -0400 Subject: Enhance Openstack Client Update Openstack Client to support additional fields Updat all formatting issues Issue-ID: SO-1844 Change-Id: I1369e0c18cc25274db8df7e12855a020b8da38da Signed-off-by: Smokowski, Steve (ss835w) --- .../java/com/woorea/openstack/quantum/Quantum.java | 26 ++--- .../openstack/quantum/api/NetworksResource.java | 8 +- .../openstack/quantum/api/PortsResource.java | 17 ++-- .../openstack/quantum/api/RoutersResource.java | 108 +++++++++++---------- .../openstack/quantum/api/SubnetsResource.java | 9 +- .../quantum/api/query/AbsOpenStackCmd.java | 10 +- 6 files changed, 87 insertions(+), 91 deletions(-) (limited to 'quantum-client/src/main/java/com/woorea/openstack') 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 ab64531..c4f5e9f 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); - + 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() - { + + 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 8b5ee25..6530237 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 @@ -44,11 +44,11 @@ public class NetworksResource { return new Update(net); } - public Delete delete(String netId){ + public Delete delete(String netId) { return new Delete(netId); } - public Show show(String netId){ + public Show show(String netId) { return new Show(netId); } @@ -62,7 +62,7 @@ public class NetworksResource { public class Query extends OpenStackRequest { public Query(Network network) { - + } } @@ -90,7 +90,7 @@ public class NetworksResource { public class Delete extends OpenStackRequest { - public Delete(String id){ + 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 a82c111..7ac0c8c 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 @@ -36,19 +36,19 @@ public class PortsResource { return new List(); } - public Create create(Port port){ + public Create create(Port port) { return new Create(port); } - public Update update(Port port){ + public Update update(Port port) { return new Update(port); } - public Delete delete(String portId){ + public Delete delete(String portId) { return new Delete(portId); } - public Show show(String portId){ + public Show show(String portId) { return new Show(portId); } @@ -61,22 +61,21 @@ public class PortsResource { public class Query extends OpenStackRequest { - public Query(Port port) { - } + public Query(Port port) {} } public class Create extends OpenStackRequest { - public Create(Port port){ + public Create(Port port) { super(CLIENT, HttpMethod.POST, "ports", Entity.json(port), Port.class); } } public class Update extends OpenStackRequest { - public Update(Port port){ + public Update(Port port) { super(CLIENT, HttpMethod.PUT, buildPath("ports/", port.getId()), Entity.json(port), Port.class); } } @@ -90,7 +89,7 @@ public class PortsResource { public class Delete extends OpenStackRequest { - 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 774e44a..ed2f22d 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,87 +28,89 @@ import com.woorea.openstack.quantum.model.Routers; public class RoutersResource { - private final OpenStackClient CLIENT; + private final OpenStackClient CLIENT; - public RoutersResource(OpenStackClient client) { - CLIENT = client; - } + public RoutersResource(OpenStackClient client) { + CLIENT = client; + } - public List list() { - return new List(); - } + public List list() { + return new List(); + } - public Create create(RouterForCreate router){ - return new Create(router); - } + public Create create(RouterForCreate router) { + return new Create(router); + } - 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 { + public class List extends OpenStackRequest { - public List() { - super(CLIENT, HttpMethod.GET, "routers", null, Routers.class); - } + public List() { + super(CLIENT, HttpMethod.GET, "routers", null, Routers.class); } + } - public class Query extends OpenStackRequest { + public class Query extends OpenStackRequest { - public Query(Router router) { - } - } - public class Create extends OpenStackRequest { + public Query(Router router) {} + } + public class Create extends OpenStackRequest { - public Create(RouterForCreate router){ - super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class); - } + public Create(RouterForCreate router) { + super(CLIENT, HttpMethod.POST, "routers", Entity.json(router), Router.class); } + } - - public class Show extends OpenStackRequest { - public Show(String id) { - super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class); - } + public class Show extends OpenStackRequest { + + public Show(String id) { + super(CLIENT, HttpMethod.GET, buildPath("routers/", id), null, Router.class); } + } - public class Delete extends OpenStackRequest { + public class Delete extends OpenStackRequest { - public Delete(String id){ - super(CLIENT, HttpMethod.DELETE, buildPath("routers/", id), null, Void.class); - } + 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 { + } - 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 Attach addInterface(RouterForAddInterface interfaceToAdd) { + return new Attach(interfaceToAdd); + } + + public class Attach extends OpenStackRequest { + + public Attach(RouterForAddInterface interfaceToAdd) { + super(CLIENT, HttpMethod.PUT, buildPath("routers/", interfaceToAdd.getRouterId(), "/add_router_interface"), + Entity.json(interfaceToAdd), RouterInterface.class); } - public class Detach extends OpenStackRequest { + } + + public Detach deleteInterface(RouterForAddInterface interfaceRouter) { + return new Detach(interfaceRouter); + } + + public class Detach extends OpenStackRequest { public Detach(RouterForAddInterface interfaceToAdd) { - super(CLIENT, HttpMethod.PUT, buildPath("routers/", - interfaceToAdd.getRouterId(), "/remove_router_interface"), + 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 bee3743..91553b3 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 @@ -44,11 +44,11 @@ public class SubnetsResource { return new Update(net); } - public Delete delete(String netId){ + public Delete delete(String netId) { return new Delete(netId); } - public Show show(String netId){ + public Show show(String netId) { return new Show(netId); } @@ -61,8 +61,7 @@ public class SubnetsResource { public class Query extends OpenStackRequest { - public Query(Subnet subnet) { - } + public Query(Subnet subnet) {} } @@ -89,7 +88,7 @@ public class SubnetsResource { public class Delete extends OpenStackRequest { - 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 8914ab0..2b5c977 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 @@ -19,7 +19,6 @@ package com.woorea.openstack.quantum.api.query; import java.lang.reflect.Field; import java.util.HashMap; import java.util.Map; - import com.fasterxml.jackson.annotation.JsonProperty; import com.woorea.openstack.base.client.OpenStackRequest; @@ -27,8 +26,7 @@ public class AbsOpenStackCmd extends OpenStackRequest { private T query; - protected AbsOpenStackCmd(T query) - { + protected AbsOpenStackCmd(T query) { this.setQuery(query); } @@ -46,8 +44,7 @@ public class AbsOpenStackCmd extends OpenStackRequest { return query; } - private String getFieldValue(Field field, T target) - { + private String getFieldValue(Field field, T target) { try { field.setAccessible(true); Object obj = field.get(target); @@ -59,8 +56,7 @@ public class AbsOpenStackCmd extends OpenStackRequest { } } - private Map getObjectParamMap(T target) - { + private Map getObjectParamMap(T target) { Map resultMap = new HashMap<>(); if (target == null) return resultMap; -- cgit 1.2.3-korg