-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from chilicat/heat
Add Heat Functionality
- Loading branch information
Showing
15 changed files
with
682 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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>com.woorea</groupId> | ||
<artifactId>openstack-java-sdk</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>heat-client</artifactId> | ||
<name>OpenStack Heat Client</name> | ||
<description>OpenStack Heat Client</description> | ||
<dependencies> | ||
<dependency> | ||
<groupId>com.woorea</groupId> | ||
<artifactId>openstack-client</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.woorea</groupId> | ||
<artifactId>heat-model</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
31 changes: 31 additions & 0 deletions
31
heat-client/src/main/java/com/woorea/openstack/heat/Heat.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
heat-client/src/main/java/com/woorea/openstack/heat/ResourcesResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Resources> { | ||
public ListResources(String name) { | ||
super(client, HttpMethod.GET, "/stacks/" + name + "/resources", null, Resources.class); | ||
} | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
heat-client/src/main/java/com/woorea/openstack/heat/StackResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.woorea.openstack.heat; | ||
|
||
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.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 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<Stack> { | ||
public CreateStack(CreateStackParam params) { | ||
super(client, HttpMethod.POST, "/stacks", Entity.json(params), Stack.class); | ||
} | ||
} | ||
|
||
public class DeleteStack extends OpenStackRequest<Void> { | ||
public DeleteStack(String name) { | ||
super(client, HttpMethod.DELETE, "/stacks/" + name, null, Void.class); | ||
} | ||
} | ||
|
||
|
||
public class GetStack extends OpenStackRequest<Stack> { | ||
public GetStack(String name) { | ||
super(client, HttpMethod.GET, "/stacks/" + name, null, Stack.class); | ||
} | ||
} | ||
|
||
public class List extends OpenStackRequest<Stacks> { | ||
public List() { | ||
super(client, HttpMethod.GET, "/stacks", null, Stacks.class); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<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>com.woorea</groupId> | ||
<artifactId>openstack-java-sdk</artifactId> | ||
<version>3.2.2-SNAPSHOT</version> | ||
</parent> | ||
<artifactId>heat-model</artifactId> | ||
<name>OpenStack Heat Model</name> | ||
<description>OpenStack Heat Model</description> | ||
</project> |
100 changes: 100 additions & 0 deletions
100
heat-model/src/main/java/com/woorea/openstack/heat/model/CreateStackParam.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package com.woorea.openstack.heat.model; | ||
|
||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
import java.util.Map; | ||
|
||
public class CreateStackParam { | ||
@JsonProperty("stack_name") | ||
private String stackName; | ||
|
||
@JsonProperty("template_url") | ||
private String templateUrl; | ||
|
||
@JsonProperty | ||
private String template; | ||
|
||
@JsonProperty("parameters") | ||
private Map<String, String> parameters; | ||
|
||
@JsonProperty("timeout_mins") | ||
private int timeoutMinutes; | ||
|
||
@JsonProperty("environment") | ||
private String environment; | ||
|
||
public String getStackName() { | ||
return stackName; | ||
} | ||
|
||
public void setStackName(String stackName) { | ||
this.stackName = stackName; | ||
} | ||
|
||
public String getTemplateUrl() { | ||
return templateUrl; | ||
} | ||
|
||
/** | ||
* The URL of the template to instantiate. This value is ignored if the template is supplied inline. | ||
* | ||
* @param templateUrl a template url. | ||
*/ | ||
public void setTemplateUrl(String templateUrl) { | ||
this.templateUrl = templateUrl; | ||
} | ||
|
||
public Map<String, String> getParameters() { | ||
return parameters; | ||
} | ||
|
||
public String getTemplate() { | ||
return template; | ||
} | ||
|
||
/** | ||
* A JSON template to instantiate. This value takes precedence over the template URL if both are supplied. | ||
* | ||
* @param template a template json. | ||
*/ | ||
public void setTemplate(String template) { | ||
this.template = template; | ||
} | ||
|
||
public void setParameters(Map<String, String> parameters) { | ||
this.parameters = parameters; | ||
} | ||
|
||
public int getTimeoutMinutes() { | ||
return timeoutMinutes; | ||
} | ||
|
||
public void setTimeoutMinutes(int timeoutMinutes) { | ||
this.timeoutMinutes = timeoutMinutes; | ||
} | ||
|
||
public String getEnvironment() { | ||
return environment; | ||
} | ||
|
||
/** | ||
* A JSON environment for the stack. | ||
* | ||
* @param environment a environment. | ||
*/ | ||
public void setEnvironment(String environment) { | ||
this.environment = environment; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "CreateStackParam{" + | ||
"stackName='" + stackName + '\'' + | ||
", templateUrl='" + templateUrl + '\'' + | ||
", template='" + template + '\'' + | ||
", parameters=" + parameters + | ||
", timeoutMinutes=" + timeoutMinutes + | ||
", environment='" + environment + '\'' + | ||
'}'; | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
heat-model/src/main/java/com/woorea/openstack/heat/model/Explanation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.woorea.openstack.heat.model; | ||
|
||
import org.codehaus.jackson.annotate.JsonProperty; | ||
import org.codehaus.jackson.map.annotate.JsonRootName; | ||
|
||
@JsonRootName("error") | ||
public class Explanation { | ||
@JsonProperty("explanation") | ||
private String explanation; | ||
|
||
@JsonProperty("code") | ||
private int code; | ||
|
||
@JsonRootName("error") | ||
public static class Error { | ||
@JsonProperty("message") | ||
private String message; | ||
|
||
@JsonProperty("traceback") | ||
private String traceback; | ||
|
||
@JsonProperty("type") | ||
private String type; | ||
|
||
@JsonProperty("title") | ||
private String title; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
heat-model/src/main/java/com/woorea/openstack/heat/model/Link.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.woorea.openstack.heat.model; | ||
|
||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
public class Link { | ||
@JsonProperty("href") | ||
private String href; | ||
|
||
@JsonProperty("rel") | ||
private String rel; | ||
|
||
public String getHref() { | ||
return href; | ||
} | ||
|
||
public void setHref(String href) { | ||
this.href = href; | ||
} | ||
|
||
public String getRel() { | ||
return rel; | ||
} | ||
|
||
public void setRel(String rel) { | ||
this.rel = rel; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "Link{" + | ||
"href='" + href + '\'' + | ||
", rel='" + rel + '\'' + | ||
'}'; | ||
} | ||
} |
Oops, something went wrong.