summaryrefslogtreecommitdiffstats
path: root/swift-client/src
diff options
context:
space:
mode:
authorChrisC <cc697w@intl.att.com>2017-01-31 13:57:24 +0100
committerChrisC <cc697w@intl.att.com>2017-01-31 14:55:11 +0100
commit2e984294ac28c6f2ede290c38164c5d536ccaf4a (patch)
tree5eba5a929b7a961c98749fa69e03cfea58e1a724 /swift-client/src
parent86c0f28c8ed469486b64d6422dc53e3a7bcc8adb (diff)
Initial OpenECOMP MSO OpenStack SDK lib commit
Change-Id: Ieaacb2b2c0dcc469669880e73f0cda9fa59a6c5a Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'swift-client/src')
-rw-r--r--swift-client/src/main/java/com/woorea/openstack/swift/Swift.java33
-rw-r--r--swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java22
-rw-r--r--swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java143
-rw-r--r--swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java74
4 files changed, 272 insertions, 0 deletions
diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java b/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java
new file mode 100644
index 0000000..0629853
--- /dev/null
+++ b/swift-client/src/main/java/com/woorea/openstack/swift/Swift.java
@@ -0,0 +1,33 @@
+package com.woorea.openstack.swift;
+
+
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackClientConnector;
+import com.woorea.openstack.swift.api.AccountResource;
+import com.woorea.openstack.swift.api.ContainersResource;
+
+public class Swift extends OpenStackClient {
+
+ private final AccountResource ACCOUNT;
+
+ private final ContainersResource CONTAINERS;
+
+ public Swift(String endpoint, OpenStackClientConnector connector) {
+ super(endpoint, connector);
+ CONTAINERS = new ContainersResource(this);
+ ACCOUNT = new AccountResource(this);
+ }
+
+ public Swift(String endpoint) {
+ this(endpoint, null);
+ }
+
+ public ContainersResource containers() {
+ return CONTAINERS;
+ }
+
+ public AccountResource account() {
+ return ACCOUNT;
+ }
+
+}
diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java
new file mode 100644
index 0000000..f98fbf9
--- /dev/null
+++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/AccountResource.java
@@ -0,0 +1,22 @@
+package com.woorea.openstack.swift.api;
+
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackRequest;
+
+public class AccountResource {
+
+ private final OpenStackClient CLIENT;
+
+ public AccountResource(OpenStackClient client) {
+ CLIENT = client;
+ }
+
+ public class ShowAccount extends OpenStackRequest<Void> {
+
+ public ShowAccount() {
+// return target.request(MediaType.APPLICATION_JSON).head();
+ }
+
+ }
+
+}
diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java
new file mode 100644
index 0000000..c55babe
--- /dev/null
+++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainerResource.java
@@ -0,0 +1,143 @@
+package com.woorea.openstack.swift.api;
+
+import java.util.Map;
+
+
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.base.client.OpenStackResponse;
+import com.woorea.openstack.swift.model.ObjectDownload;
+import com.woorea.openstack.swift.model.ObjectForUpload;
+
+public class ContainerResource {
+
+ private final OpenStackClient CLIENT;
+
+ private String container;
+
+ public ContainerResource(OpenStackClient client, String container) {
+ CLIENT = client;
+ this.container = container;
+ }
+
+ public List list() {
+ return new List(container, null);
+ }
+
+ public CreateDirectory createDirectory(String path) {
+ return new CreateDirectory(container, path);
+ }
+
+ public Show show(String path) {
+ return new Show(container, path);
+ }
+
+ public Upload upload(ObjectForUpload objectForUpload) {
+ return new Upload(objectForUpload);
+ }
+
+ public Download download(String path) {
+ return new Download(container, path);
+ }
+
+ public Delete delete(String path) {
+ return new Delete(container, path);
+ }
+
+ public class List extends OpenStackRequest<java.util.List<Object>> {
+
+ private String containerName;
+
+ private Map<String, String> filters;
+
+ public List(String containerName, Map<String, String> filters) {
+ this.containerName = containerName;
+ this.filters = filters;
+ //returnType(new TypeToken<List<Object>>(){});
+// target = target.path(containerName);
+// for(String filter : new String[]{"prefix","delimiter","path","marker"}) {
+// if(filters.get(filter) != null) {
+// target = target.queryParam(filter, filters.get(filter));
+// }
+// }
+// return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Object>>(){});
+ }
+
+ }
+
+ public class CreateDirectory extends OpenStackRequest<Void> {
+
+ private String container;
+
+ private String path;
+
+ public CreateDirectory(String container, String path) {
+ this.container = container;
+ this.path = path;
+// endpoint.path(container).path(path).request().put(Entity.entity(new byte[1],"application/directory"));
+ }
+
+ }
+
+ public class Show extends OpenStackRequest<Object> {
+
+ private String containerName;
+
+ private String objectName;
+
+ public Show(String containerName, String objectName) {
+ this.containerName = containerName;
+ this.objectName = objectName;
+// return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).head();
+ }
+
+ }
+
+ public class Upload extends OpenStackRequest<OpenStackResponse> {
+
+ private ObjectForUpload objectForUpload;
+
+ public Upload(ObjectForUpload objectForUpload) {
+ this.objectForUpload = objectForUpload;
+// Invocation.Builder invocationBuilder = target.path(objectForUpload.getContainer()).path(objectForUpload.getName()).request(MediaType.APPLICATION_JSON);
+// for(String key : objectForUpload.getProperties().keySet()) {
+// invocationBuilder.header("x-object-meta-" + key, objectForUpload.getProperties().get(key));
+// }
+// return invocationBuilder.put(Entity.entity(objectForUpload.getInputStream(), MediaType.APPLICATION_OCTET_STREAM), Response.class);
+ }
+
+ }
+
+ public class Download extends OpenStackRequest<ObjectDownload> {
+
+ private String containerName;
+
+ private String objectName;
+
+ public Download(String containerName, String objectName) {
+ this.containerName = containerName;
+ this.objectName = objectName;
+// Response response = target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).get();
+// ObjectDownload objectDownload = new ObjectDownload();
+// objectDownload.setInputStream((InputStream) response.getEntity());
+// return objectDownload;
+ }
+
+ }
+
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ private String containerName;
+
+ private String objectName;
+
+ public Delete(String containerName, String objectName) {
+ this.containerName = containerName;
+ this.objectName = objectName;
+ //return target.path(containerName).path(objectName).request(MediaType.APPLICATION_JSON).delete();
+ }
+
+ }
+
+}
diff --git a/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java
new file mode 100644
index 0000000..aedcc3f
--- /dev/null
+++ b/swift-client/src/main/java/com/woorea/openstack/swift/api/ContainersResource.java
@@ -0,0 +1,74 @@
+package com.woorea.openstack.swift.api;
+
+
+import com.woorea.openstack.base.client.OpenStackClient;
+import com.woorea.openstack.base.client.OpenStackRequest;
+import com.woorea.openstack.swift.model.Container;
+
+public class ContainersResource {
+
+ private final OpenStackClient CLIENT;
+
+ public ContainersResource(OpenStackClient client) {
+ CLIENT = client;
+ }
+
+ public List list() {
+ return new List();
+ }
+
+ public Create create(String name) {
+ return new Create(name);
+ }
+
+ public Show show(String name) {
+ return new Show(name);
+ }
+
+ public Delete delete(String name) {
+ return new Delete(name);
+ }
+
+ public ContainerResource container(String name) {
+ return new ContainerResource(CLIENT, name);
+ }
+
+ public class List extends OpenStackRequest<java.util.List<Container>> {
+
+ public List() {
+ //return target.request(MediaType.APPLICATION_JSON).get(new GenericType<List<Container>>(){});
+ }
+
+ }
+
+
+ public class Create extends OpenStackRequest<Container> {
+
+ public Create(String containerName) {
+ //return target.path(containerName).request().method("PUT",Entity.text("*"));
+ }
+
+ }
+
+ public class Show extends OpenStackRequest<Container> {
+
+ private String containerName;
+
+ public Show(String containerName) {
+// return target.path(containerName).request(MediaType.APPLICATION_JSON).head();
+ }
+
+ }
+
+ public class Delete extends OpenStackRequest<Void> {
+
+ private String containerName;
+
+ public Delete(String containerName) {
+ this.containerName = containerName;
+ //return target.path(containerName).request(MediaType.APPLICATION_JSON).delete();
+ }
+
+ }
+
+}