View Javadoc

1   /**
2    * Licensed to jclouds, Inc. (jclouds) under one or more
3    * contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  jclouds licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.jclouds.gogrid.services;
20  
21  import static org.jclouds.gogrid.reference.GoGridHeaders.VERSION;
22  import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_DESCRIPTION_KEY;
23  import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_FRIENDLY_NAME_KEY;
24  import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
25  import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
26  
27  import java.util.Set;
28  
29  import javax.ws.rs.GET;
30  import javax.ws.rs.Path;
31  import javax.ws.rs.QueryParam;
32  
33  import org.jclouds.gogrid.GoGridAsyncClient;
34  import org.jclouds.gogrid.binders.BindIdsToQueryParams;
35  import org.jclouds.gogrid.binders.BindNamesToQueryParams;
36  import org.jclouds.gogrid.domain.Option;
37  import org.jclouds.gogrid.domain.ServerImage;
38  import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
39  import org.jclouds.gogrid.functions.ParseImageFromJsonResponse;
40  import org.jclouds.gogrid.functions.ParseImageListFromJsonResponse;
41  import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
42  import org.jclouds.gogrid.options.GetImageListOptions;
43  import org.jclouds.rest.annotations.BinderParam;
44  import org.jclouds.rest.annotations.QueryParams;
45  import org.jclouds.rest.annotations.RequestFilters;
46  import org.jclouds.rest.annotations.ResponseParser;
47  
48  import com.google.common.util.concurrent.ListenableFuture;
49  
50  /**
51   * @author Oleksiy Yarmula
52   */
53  @RequestFilters(SharedKeyLiteAuthentication.class)
54  @QueryParams(keys = VERSION, values = GoGridAsyncClient.VERSION)
55  public interface GridImageAsyncClient {
56  
57     /**
58      * @see GridImageClient#getImageList
59      */
60     @GET
61     @ResponseParser(ParseImageListFromJsonResponse.class)
62     @Path("/grid/image/list")
63     ListenableFuture<Set<ServerImage>> getImageList(GetImageListOptions... options);
64  
65     /**
66      * @see GridImageClient#getImagesById
67      */
68     @GET
69     @ResponseParser(ParseImageListFromJsonResponse.class)
70     @Path("/grid/image/get")
71     ListenableFuture<Set<ServerImage>> getImagesById(
72              @BinderParam(BindIdsToQueryParams.class) Long... ids);
73  
74     /**
75      * @see GridImageClient#getImagesByName
76      */
77     @GET
78     @ResponseParser(ParseImageListFromJsonResponse.class)
79     @Path("/grid/image/get")
80     ListenableFuture<Set<ServerImage>> getImagesByName(
81              @BinderParam(BindNamesToQueryParams.class) String... names);
82  
83     /**
84      * @see GridImageClient#editImageDescription
85      */
86     @GET
87     @ResponseParser(ParseImageFromJsonResponse.class)
88     @Path("/grid/image/edit")
89     ListenableFuture<ServerImage> editImageDescription(@QueryParam(IMAGE_KEY) String idOrName,
90              @QueryParam(IMAGE_DESCRIPTION_KEY) String newDescription);
91  
92     /**
93      * @see GridImageClient#editImageFriendlyName
94      */
95     @GET
96     @ResponseParser(ParseImageFromJsonResponse.class)
97     @Path("/grid/image/edit")
98     ListenableFuture<ServerImage> editImageFriendlyName(@QueryParam(IMAGE_KEY) String idOrName,
99              @QueryParam(IMAGE_FRIENDLY_NAME_KEY) String newFriendlyName);
100 
101    /**
102     * @see GridImageClient#getDatacenters
103     */
104    @GET
105    @ResponseParser(ParseOptionsFromJsonResponse.class)
106    @Path("/common/lookup/list")
107    @QueryParams(keys = LOOKUP_LIST_KEY, values = "datacenter")
108    ListenableFuture<Set<Option>> getDatacenters();
109 }