Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable/grizzly #58

Open
wants to merge 3 commits into
base: stable/grizzly
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.classpath
.project
.settings/
*.json
target/
bin/logs/

Expand All @@ -17,4 +18,4 @@ openstack-ui/src/main/webapp/WEB-INF/lib/
openstack-ui/.gwt/
openstack-ui/deploy.sh
test-output/
bin
bin
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

@JsonRootName("image")
public class Image implements Serializable {

private String id;

private String uri;
Expand Down
24 changes: 24 additions & 0 deletions heat-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openstack</groupId>
<artifactId>openstack-java-sdk</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>heat-client</artifactId>
<name>OpenStack Heat Client</name>
<description>OpenStack Heat Client</description>
<dependencies>
<dependency>
<groupId>org.openstack</groupId>
<artifactId>openstack-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.openstack</groupId>
<artifactId>heat-model</artifactId>
<version>2.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openstack.heat.client;

import javax.ws.rs.client.WebTarget;

import org.openstack.OpenStack;
import org.openstack.common.client.AbstractOpenStackClient;

public class HeatClient extends AbstractOpenStackClient{

public HeatClient(String endpointURL, String token) {
super(endpointURL, token);
}

public <R> R execute(HeatCommand<R> command) {
WebTarget endpoint = OpenStack.CLIENT.target(endpointURL);
if(token != null) {
endpoint.register(tokenFilter);
}
return command.execute(endpoint);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.openstack.heat.client;

import javax.ws.rs.client.WebTarget;

public interface HeatCommand<R>{

R execute(WebTarget endpoint);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.openstack.heat.client;

public interface HeatResourcesPath {
String stackPath = "stacks";
String resourcePath = "resources";
String eventPath = "events";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package org.openstack.heat.client.api;

import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

import org.openstack.heat.client.HeatCommand;
import org.openstack.heat.client.HeatResourcesPath;
import org.openstack.heat.model.Event;
import org.openstack.heat.model.Events;

public class EventsCore {

private static class ListStackEvents implements HeatCommand<Events>{
private String stackID;
private String stackName;

public ListStackEvents(String stackID, String stackName) {
super();
this.stackID = stackID;
this.stackName = stackName;
}

@Override
public Events execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(stackName).path(stackID).path(HeatResourcesPath.eventPath)
.request(MediaType.APPLICATION_JSON).get(Events.class);
}

}

private static class ListResourceEvents implements HeatCommand<Events>{
private String stackID;
private String stackName;
private String resourceName;

public ListResourceEvents(String stackID, String stackName,
String resourceName) {
super();
this.stackID = stackID;
this.stackName = stackName;
this.resourceName = resourceName;
}

@Override
public Events execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(stackName).path(stackID).
path(HeatResourcesPath.resourcePath).path(resourceName).path(HeatResourcesPath.eventPath)
.request(MediaType.APPLICATION_JSON).get(Events.class);
}

}

private static class ShowEvent implements HeatCommand<Event>{
private String stackID;
private String stackName;
private String resourceName;
private String eventID;

public ShowEvent(String stackID, String stackName,
String resourceName, String eventID) {
super();
this.stackID = stackID;
this.stackName = stackName;
this.resourceName = resourceName;
this.eventID = eventID;
}

@Override
public Event execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(stackName).path(stackID).
path(HeatResourcesPath.resourcePath).path(resourceName).
path(HeatResourcesPath.eventPath).path(eventID)
.request(MediaType.APPLICATION_JSON).get(Event.class);
}
}

public static HeatCommand<Events> listStackEvents(String stackID, String stackName){
return new ListStackEvents(stackID, stackName);
}

public static HeatCommand<Events> listResourceEvents(String stackID, String stackName, String resourceName){
return new ListResourceEvents(stackID, stackName ,resourceName);
}

public static HeatCommand<Event> showEvent(String stackID, String stackName, String resourceName, String eventID){
return new ShowEvent(stackID, stackName ,resourceName, eventID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package org.openstack.heat.client.api;

import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;

import org.openstack.heat.client.HeatCommand;
import org.openstack.heat.model.Resource;
import org.openstack.heat.model.Resources;

public class ResourcesCore {
private static final String stackPath = "stacks";
private static final String resourcePath = "resources";

private static class ListResources implements HeatCommand<Resources>{
private String stackID;

public ListResources(String stackID){
this.stackID = stackID;
}
@Override
public Resources execute(WebTarget endpoint) {
return endpoint.path(stackPath).path(stackID).path(resourcePath)
.request(MediaType.APPLICATION_JSON).get(Resources.class);
}
}

private static class ShowResource implements HeatCommand<Resource>{
private String stackID;
private String stackName;
private String resourceName;

public ShowResource(String stackID ,String stackName, String resourceName){
this.stackID = stackID;
this.stackName = stackName;
this.resourceName = resourceName;
}
@Override
public Resource execute(WebTarget endpoint) {
return endpoint.path(stackPath).path(stackName).path(stackID).path(resourcePath).path(resourceName)
.request(MediaType.APPLICATION_JSON).get(Resource.class);
}
}

public static HeatCommand<Resources> listResources(String stackID){
return new ListResources(stackID);
}

public static HeatCommand<Resource> showResource(String stackID , String stackName, String resourceName){
return new ShowResource(stackID, stackName, resourceName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package org.openstack.heat.client.api;

import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import org.openstack.heat.client.HeatCommand;
import org.openstack.heat.client.HeatResourcesPath;
import org.openstack.heat.model.Stack;
import org.openstack.heat.model.StackForCreate;
import org.openstack.heat.model.Stacks;

public class StacksCore {

private static class ListStacks implements HeatCommand<Stacks>{

@Override
public Stacks execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).request(MediaType.APPLICATION_JSON).get(Stacks.class);
}

}

private static class ShowStack implements HeatCommand<Stack>{
private String id;

public ShowStack(String id){
this.id = id;
}

@Override
public Stack execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(id).request(MediaType.APPLICATION_JSON).get(Stack.class);
}
}

private static class CreateStack implements HeatCommand<Response>{
private StackForCreate stackForCreate;

public CreateStack(StackForCreate stackForCreate) {
super();
this.stackForCreate = stackForCreate;
}

@Override
public Response execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).request(MediaType.TEXT_PLAIN)
.post(Entity.json(stackForCreate));
}

}

private static class UpdateStack implements HeatCommand<Response>{
private String stackName;
private String stackID;
private StackForCreate stackForCreate;

public UpdateStack(String stackName, String stackID,
StackForCreate stackForCreate) {
super();
this.stackName = stackName;
this.stackID = stackID;
this.stackForCreate = stackForCreate;
}



@Override
public Response execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(stackName).path(stackID)
.request(MediaType.TEXT_PLAIN).put(Entity.json(stackForCreate));
}

}

private static class DeleteStack implements HeatCommand<Response>{
private String id;

public DeleteStack(String id) {
super();
this.id = id;
}

@Override
public Response execute(WebTarget endpoint) {
return endpoint.path(HeatResourcesPath.stackPath).path(id).request(MediaType.TEXT_PLAIN).delete();
}

}

public static HeatCommand<Stacks> listStacks(){
return new ListStacks();
}

public static HeatCommand<Stack> showStack(String id){
return new ShowStack(id);
}

public static HeatCommand<Response> createStack(StackForCreate stackForCreate){
return new CreateStack(stackForCreate);
}

public static HeatCommand<Response> updateStack(String stackName, String stackID,
StackForCreate stackForCreate){
return new UpdateStack(stackName,stackID,stackForCreate);
}

public static HeatCommand<Response> deleteStack(String id){
return new DeleteStack(id);
}
}
12 changes: 12 additions & 0 deletions heat-model/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openstack</groupId>
<artifactId>openstack-java-sdk</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>heat-model</artifactId>
<name>OpenStack Heat Model</name>
<description>OpenStack Heat Model</description>
</project>
Loading