| /** |
| * Licensed to jclouds, Inc. (jclouds) under one or more |
| * contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. jclouds 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.hostedchef; |
| |
| import java.util.Set; |
| |
| 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.Constants; |
| import org.jclouds.Fallbacks.FalseOnNotFoundOr404; |
| import org.jclouds.Fallbacks.NullOnNotFoundOr404; |
| import org.jclouds.chef.ChefApi; |
| import org.jclouds.chef.ChefAsyncApi; |
| import org.jclouds.chef.filters.SignedHeaderAuth; |
| import org.jclouds.chef.functions.ParseKeySetFromJson; |
| import org.jclouds.hostedchef.binders.BindGroupNameToJsonPayload; |
| import org.jclouds.hostedchef.binders.BindGroupToUpdateRequestJsonPayload; |
| import org.jclouds.hostedchef.binders.GroupName; |
| import org.jclouds.hostedchef.domain.Group; |
| import org.jclouds.hostedchef.domain.User; |
| import org.jclouds.rest.annotations.BinderParam; |
| import org.jclouds.rest.annotations.Fallback; |
| import org.jclouds.rest.annotations.Headers; |
| import org.jclouds.rest.annotations.ParamParser; |
| import org.jclouds.rest.annotations.RequestFilters; |
| import org.jclouds.rest.annotations.ResponseParser; |
| |
| import com.google.common.util.concurrent.ListenableFuture; |
| |
| /** |
| * Provides asynchronous access to the Hosted Chef via their REST API. |
| * |
| * @see HostedChefApi |
| * @author Ignasi Barrera |
| * @deprecated please use |
| * {@code org.jclouds.ContextBuilder#buildApi(HostedChefApi.class)} |
| * as {@link HostedChefAsyncApi} interface will be removed in |
| * jclouds 1.7. |
| */ |
| @Deprecated |
| @RequestFilters(SignedHeaderAuth.class) |
| @Consumes(MediaType.APPLICATION_JSON) |
| @Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}") |
| public interface HostedChefAsyncApi extends ChefAsyncApi { |
| |
| /** |
| * @see ChefApi#nodeExists(String) |
| */ |
| @Override |
| // Use get instead of HEAD |
| @Named("node:exists") |
| @GET |
| @Path("/nodes/{nodename}") |
| @Fallback(FalseOnNotFoundOr404.class) |
| ListenableFuture<Boolean> nodeExists(@PathParam("nodename") String nodename); |
| |
| /** |
| * @see HostedChefApi#getUser(String) |
| */ |
| @Named("user:get") |
| @GET |
| @Path("/users/{name}") |
| @Fallback(NullOnNotFoundOr404.class) |
| ListenableFuture<User> getUser(@PathParam("name") String name); |
| |
| /** |
| * @see HostedChefApi#listGroups() |
| */ |
| @Named("group:list") |
| @GET |
| @Path("/groups") |
| @ResponseParser(ParseKeySetFromJson.class) |
| ListenableFuture<Set<String>> listGroups(); |
| |
| /** |
| * @see HostedChefApi#getGroup(String) |
| */ |
| @Named("group:get") |
| @GET |
| @Path("/groups/{name}") |
| @Fallback(NullOnNotFoundOr404.class) |
| ListenableFuture<Group> getGroup(@PathParam("name") String name); |
| |
| /** |
| * @see HostedChefApi#createGroup(String) |
| */ |
| @Named("group:create") |
| @POST |
| @Path("/groups") |
| ListenableFuture<Void> createGroup(@BinderParam(BindGroupNameToJsonPayload.class) String name); |
| |
| /** |
| * @see HostedChefApi#updateGroup(Group) |
| */ |
| @Named("group:update") |
| @PUT |
| @Path("/groups/{name}") |
| ListenableFuture<Void> updateGroup( |
| @PathParam("name") @ParamParser(GroupName.class) @BinderParam(BindGroupToUpdateRequestJsonPayload.class) Group group); |
| |
| /** |
| * @see HostedChefApi#getGroup(String) |
| */ |
| @Named("group:delete") |
| @DELETE |
| @Path("/groups/{name}") |
| ListenableFuture<Void> deleteGroup(@PathParam("name") String name); |
| |
| } |