From 2e984294ac28c6f2ede290c38164c5d536ccaf4a Mon Sep 17 00:00:00 2001 From: ChrisC Date: Tue, 31 Jan 2017 13:57:24 +0100 Subject: Initial OpenECOMP MSO OpenStack SDK lib commit Change-Id: Ieaacb2b2c0dcc469669880e73f0cda9fa59a6c5a Signed-off-by: ChrisC --- .../main/java/com/woorea/openstack/heat/Heat.java | 31 +++++++++ .../woorea/openstack/heat/ResourcesResource.java | 31 +++++++++ .../com/woorea/openstack/heat/StackResource.java | 76 ++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 heat-client/src/main/java/com/woorea/openstack/heat/Heat.java create mode 100644 heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java create mode 100644 heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java (limited to 'heat-client/src') diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java b/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java new file mode 100644 index 0000000..96e9cd7 --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/Heat.java @@ -0,0 +1,31 @@ +package com.woorea.openstack.heat; + +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackClientConnector; + +/** + * Reference: http://api.openstack.org/api-ref-orchestration.html + */ +public class Heat extends OpenStackClient { + + private final StackResource stacks; + private final ResourcesResource resources; + + public Heat(String endpoint, OpenStackClientConnector connector) { + super(endpoint, connector); + stacks = new StackResource(this); + resources = new ResourcesResource(this); + } + + public Heat(String endpoint) { + this(endpoint, null); + } + + public StackResource getStacks() { + return stacks; + } + + public ResourcesResource getResources() { + return resources; + } +} diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java b/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java new file mode 100644 index 0000000..c3635bc --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java @@ -0,0 +1,31 @@ +package com.woorea.openstack.heat; + +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.heat.model.Resources; + + +/** + * v1/​{tenant_id}​/stacks/​{stack_name}​/resources + */ +public class ResourcesResource { + private final OpenStackClient client; + + public ResourcesResource(OpenStackClient client) { + this.client = client; + } + + public ListResources listResources(String name) { + return new ListResources(name); + } + + /** + * v1/​{tenant_id}​/stacks/​{stack_name}​/resources + */ + public class ListResources extends OpenStackRequest { + public ListResources(String name) { + super(client, HttpMethod.GET, "/stacks/" + name + "/resources", null, Resources.class); + } + } +} diff --git a/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java b/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java new file mode 100644 index 0000000..055a5c4 --- /dev/null +++ b/heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java @@ -0,0 +1,76 @@ +package com.woorea.openstack.heat; + +/* + * Modifications copyright (c) 2017 AT&T Intellectual Property + */ + +import com.woorea.openstack.base.client.Entity; +import com.woorea.openstack.base.client.HttpMethod; +import com.woorea.openstack.base.client.OpenStackClient; +import com.woorea.openstack.base.client.OpenStackRequest; +import com.woorea.openstack.heat.model.CreateStackParam; +import com.woorea.openstack.heat.model.UpdateStackParam; +import com.woorea.openstack.heat.model.Stack; +import com.woorea.openstack.heat.model.Stacks; + +public class StackResource { + + private final OpenStackClient client; + + public StackResource(OpenStackClient client) { + this.client = client; + } + + public CreateStack create(CreateStackParam param) { + return new CreateStack(param); + } + + public UpdateStack update(String name, UpdateStackParam param) { + return new UpdateStack(name, param); + } + + public List list() { + return new List(); + } + + public GetStack byName(String name) { + return new GetStack(name); + } + + public DeleteStack deleteByName(String name) { + return new DeleteStack(name); + } + + public class CreateStack extends OpenStackRequest { + public CreateStack(CreateStackParam params) { + super(client, HttpMethod.POST, "/stacks", Entity.json(params), Stack.class); + } + } + + public class UpdateStack extends OpenStackRequest { + public UpdateStack(String name, UpdateStackParam params) { + super(client, HttpMethod.PUT, "/stacks/" + name, Entity.json(params), Void.class); + } + } + + public class DeleteStack extends OpenStackRequest { + public DeleteStack(String name) { + super(client, HttpMethod.DELETE, "/stacks/" + name, null, Void.class); + } + } + + + public class GetStack extends OpenStackRequest { + public GetStack(String name) { + super(client, HttpMethod.GET, "/stacks/" + name, null, Stack.class); + } + } + + public class List extends OpenStackRequest { + public List() { + super(client, HttpMethod.GET, "/stacks", null, Stacks.class); + } + } + + +} -- cgit 1.2.3-korg