Skip to content
Permalink
Browse files
Additional support for heat features. Autovalue refactorings. Rax pro…
…viders.
  • Loading branch information
zack-shoylev committed Jun 18, 2015
1 parent 95df556 commit 9eea11aa9bda55f0b778e0c8628138d754bad20f
Showing 34 changed files with 1,503 additions and 222 deletions.
@@ -103,7 +103,6 @@
<dependency>
<groupId>com.google.auto.value</groupId>
<artifactId>auto-value</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -23,15 +23,18 @@
import org.jclouds.location.functions.RegionToEndpoint;
import org.jclouds.openstack.heat.v1.features.ResourceApi;
import org.jclouds.openstack.heat.v1.features.StackApi;
import org.jclouds.openstack.heat.v1.features.TemplateApi;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.rest.annotations.EndpointParam;

import com.google.common.annotations.Beta;
import com.google.inject.Provides;

/**
* Provides access to the OpenStack Orchestration (Heat) API.
*
*/
@Beta
public interface HeatApi extends Closeable {

@Provides
@@ -44,6 +47,12 @@ public interface HeatApi extends Closeable {
@Delegate
ResourceApi getResourceApi(@EndpointParam(parser = RegionToEndpoint.class) String region);

/**
* Provides access to Template validation.
*/
@Delegate
TemplateApi getTemplateApi(@EndpointParam(parser = RegionToEndpoint.class) String region);

/**
* Provides access to Stack features.
*/
@@ -16,19 +16,19 @@
*/
package org.jclouds.openstack.heat.v1.domain;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import org.jclouds.openstack.v2_0.domain.Link;

import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;

/**
* Representation of an OpenStack Heat Stack.
@@ -69,12 +69,12 @@ public abstract class Stack {
/**
* @return the parameters of this Stack.
*/
@Nullable public abstract Map<String, String> getParameters();
public abstract Map<String, String> getParameters();

/**
* @return the capabilities of this Stack.
*/
@Nullable public abstract Set<String> getCapabilities();
public abstract Set<String> getCapabilities();

/**
* @return the outputs of this Stack.
@@ -84,7 +84,7 @@ public abstract class Stack {
/**
* @return the notification topics of this Stack.
*/
@Nullable public abstract List<String> getNotificationTopics();
public abstract List<String> getNotificationTopics();

/**
* @return the status of this Stack.
@@ -135,10 +135,10 @@ private static Stack create(String id, String name, String description, String o
description,
owner,
project,
parameters != null ? ImmutableMap.copyOf(parameters) : null,
capabilities != null ? ImmutableSet.copyOf(capabilities) : null,
outputs != null ? ImmutableList.copyOf(outputs) : null,
notificationTopics != null ? ImmutableList.copyOf(notificationTopics) : null,
parameters != null ? ImmutableMap.copyOf(parameters) : ImmutableMap.<String, String>of(),
capabilities != null ? ImmutableSet.copyOf(capabilities) : ImmutableSet.<String>of(),
outputs != null ? ImmutableList.copyOf(outputs) : ImmutableList.<String>of(),
notificationTopics != null ? ImmutableList.copyOf(notificationTopics) : ImmutableList.<String>of(),
status,
statusReason,
created,
@@ -148,4 +148,3 @@ private static Stack create(String id, String name, String description, String o
ImmutableSet.copyOf(links));
}
}

@@ -16,14 +16,15 @@
*/
package org.jclouds.openstack.heat.v1.domain;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;
import java.util.Date;
import java.util.Set;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import org.jclouds.openstack.v2_0.domain.Link;

import java.util.Date;
import java.util.Set;
import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableSet;

/**
* Representation of an OpenStack Heat Stack Resources.
@@ -59,7 +60,7 @@ public abstract class StackResource {
/**
* @return the field required_by
*/
@Nullable public abstract Set<String> getRequiredBy();
public abstract Set<String> getRequiredBy();

/**
* @return the resource type
@@ -85,7 +86,7 @@ private static StackResource create(String name, String logicalResourceId, Strin
physicalResourceId,
status,
statusReason,
requiredBy != null ? ImmutableSet.copyOf(requiredBy) : null,
requiredBy != null ? ImmutableSet.copyOf(requiredBy) : ImmutableSet.<String>of(),
resourceType,
updated,
ImmutableSet.copyOf(links));
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jclouds.openstack.heat.v1.domain;

import java.util.Map;

import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;

import com.google.auto.value.AutoValue;
import com.google.common.collect.ImmutableMap;

/**
* Representation of an OpenStack Heat Stack Template.
*/
@AutoValue
public abstract class Template {

/**
* @return the description of this Stack Template.
*/
@Nullable public abstract String getDescription();

/**
* @return the parameters of this Stack, such as compute_flavor or compute_image.
*/
public abstract Map<String, Object> getParameters();

/**
* @return the resources of this Stack, such as server_instance.
*/
public abstract Map<String, Object> getResources();

@SerializedNames({"description", "parameters", "resources"})
private static Template create(String description, Map<String, Object> parameters, Map<String, Object> resources) {
return new AutoValue_Template(
description,
parameters != null ? ImmutableMap.copyOf(parameters) : ImmutableMap.<String, Object>of(),
resources != null ? ImmutableMap.copyOf(resources) : ImmutableMap.<String, Object>of());
}
}

@@ -16,13 +16,27 @@
*/
package org.jclouds.openstack.heat.v1.features;

import java.util.List;
import java.util.Map;

import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;

import org.jclouds.Fallbacks.EmptyListOnNotFoundOr404;
import org.jclouds.Fallbacks.EmptyMapOnNotFoundOr404;
import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.openstack.heat.v1.domain.Stack;
import org.jclouds.openstack.heat.v1.domain.StackResource;
import org.jclouds.openstack.heat.v1.domain.Template;
import org.jclouds.openstack.heat.v1.options.CreateStack;
import org.jclouds.openstack.heat.v1.options.ListStackOptions;
import org.jclouds.openstack.heat.v1.options.UpdateStack;
@@ -33,18 +47,6 @@
import org.jclouds.rest.annotations.SelectJson;
import org.jclouds.rest.binders.BindToJsonPayload;

import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.MediaType;
import java.util.List;
import java.util.Map;


/**
* Provides access to the OpenStack Orchestration (Heat) Stack API features.
@@ -120,4 +122,9 @@ public interface StackApi {
@Fallback(EmptyMapOnNotFoundOr404.class)
Map<String, Object> getStackResourceMetadata(@PathParam("stack_name") String stackName, @PathParam("stack_id") String stackId, @PathParam("resource_name") String name);

@Named("stack:get_template")
@GET
@Path("/{stack_name}/{stack_id}/template")
@Fallback(NullOnNotFoundOr404.class)
Template getTemplate(@PathParam("stack_name") String stackName, @PathParam("stack_id") String stackId);
}
@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jclouds.openstack.heat.v1.features;

import javax.inject.Named;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jclouds.Fallbacks.NullOnNotFoundOr404;
import org.jclouds.openstack.heat.v1.domain.Template;
import org.jclouds.openstack.keystone.v2_0.filters.AuthenticateRequest;
import org.jclouds.rest.annotations.Fallback;
import org.jclouds.rest.annotations.Payload;
import org.jclouds.rest.annotations.PayloadParam;
import org.jclouds.rest.annotations.RequestFilters;

/**
* Provides access to Resource features.
*
*/
@RequestFilters(AuthenticateRequest.class)
public interface TemplateApi {

/**
* Normal response codes: 200
Error response codes: badRequest (400), unauthorized (401), notFound (404), internalServerError (500)
*/
@Named("validation:validate_template")
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/validate")
@Payload("%7B\"template_url\":\"{url}\"%7D")
Template validate(@PayloadParam("url") String template_url);

@Named("validation:get_template")
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Path("/stacks/{stack_name}/{stack_id}/template")
@Fallback(NullOnNotFoundOr404.class)
Template get(@PathParam("stack_name") String name, @PathParam("stack_id") String id);
}

0 comments on commit 9eea11a

Please sign in to comment.