1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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.ID_KEY;
23 import static org.jclouds.gogrid.reference.GoGridQueryParams.IMAGE_KEY;
24 import static org.jclouds.gogrid.reference.GoGridQueryParams.IP_KEY;
25 import static org.jclouds.gogrid.reference.GoGridQueryParams.LOOKUP_LIST_KEY;
26 import static org.jclouds.gogrid.reference.GoGridQueryParams.NAME_KEY;
27 import static org.jclouds.gogrid.reference.GoGridQueryParams.POWER_KEY;
28 import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_ID_OR_NAME_KEY;
29 import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_RAM_KEY;
30
31 import java.util.Map;
32 import java.util.Set;
33
34 import javax.ws.rs.GET;
35 import javax.ws.rs.Path;
36 import javax.ws.rs.QueryParam;
37
38 import org.jclouds.domain.Credentials;
39 import org.jclouds.gogrid.GoGridAsyncClient;
40 import org.jclouds.gogrid.binders.BindIdsToQueryParams;
41 import org.jclouds.gogrid.binders.BindNamesToQueryParams;
42 import org.jclouds.gogrid.domain.Option;
43 import org.jclouds.gogrid.domain.PowerCommand;
44 import org.jclouds.gogrid.domain.Server;
45 import org.jclouds.gogrid.filters.SharedKeyLiteAuthentication;
46 import org.jclouds.gogrid.functions.ParseCredentialsFromJsonResponse;
47 import org.jclouds.gogrid.functions.ParseOptionsFromJsonResponse;
48 import org.jclouds.gogrid.functions.ParseServerFromJsonResponse;
49 import org.jclouds.gogrid.functions.ParseServerListFromJsonResponse;
50 import org.jclouds.gogrid.functions.ParseServerNameToCredentialsMapFromJsonResponse;
51 import org.jclouds.gogrid.options.AddServerOptions;
52 import org.jclouds.gogrid.options.GetServerListOptions;
53 import org.jclouds.rest.annotations.BinderParam;
54 import org.jclouds.rest.annotations.ExceptionParser;
55 import org.jclouds.rest.annotations.QueryParams;
56 import org.jclouds.rest.annotations.RequestFilters;
57 import org.jclouds.rest.annotations.ResponseParser;
58 import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
59 import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
60
61 import com.google.common.util.concurrent.ListenableFuture;
62
63
64
65
66
67
68
69
70
71
72 @RequestFilters(SharedKeyLiteAuthentication.class)
73 @QueryParams(keys = VERSION, values = GoGridAsyncClient.VERSION)
74 public interface GridServerAsyncClient {
75
76
77
78
79 @GET
80 @ResponseParser(ParseServerListFromJsonResponse.class)
81 @Path("/grid/server/list")
82 ListenableFuture<Set<Server>> getServerList(GetServerListOptions... getServerListOptions);
83
84
85
86
87 @GET
88 @ResponseParser(ParseServerListFromJsonResponse.class)
89 @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
90 @Path("/grid/server/get")
91 ListenableFuture<Set<Server>> getServersByName(
92 @BinderParam(BindNamesToQueryParams.class) String... names);
93
94
95
96
97 @GET
98 @ResponseParser(ParseServerListFromJsonResponse.class)
99 @ExceptionParser(ReturnEmptySetOnNotFoundOr404.class)
100 @Path("/grid/server/get")
101 ListenableFuture<Set<Server>> getServersById(
102 @BinderParam(BindIdsToQueryParams.class) long... ids);
103
104
105
106
107 @GET
108 @ResponseParser(ParseServerNameToCredentialsMapFromJsonResponse.class)
109 @Path("/support/password/list")
110 ListenableFuture<Map<String, Credentials>> getServerCredentialsList();
111
112
113
114
115 @GET
116 @ResponseParser(ParseCredentialsFromJsonResponse.class)
117 @Path("/support/grid/password/get")
118 ListenableFuture<Credentials> getServerCredentials(@QueryParam("id") long id);
119
120
121
122
123
124 @GET
125 @ResponseParser(ParseServerFromJsonResponse.class)
126 @Path("/grid/server/add")
127 ListenableFuture<Server> addServer(@QueryParam(NAME_KEY) String name,
128 @QueryParam(IMAGE_KEY) String image, @QueryParam(SERVER_RAM_KEY) String ram,
129 @QueryParam(IP_KEY) String ip, AddServerOptions... addServerOptions);
130
131
132
133
134 @GET
135 @ResponseParser(ParseServerFromJsonResponse.class)
136 @Path("/grid/server/power")
137 ListenableFuture<Server> power(
138 @QueryParam(SERVER_ID_OR_NAME_KEY) String idOrName,
139 @QueryParam(POWER_KEY) PowerCommand power);
140
141
142
143
144 @GET
145 @ResponseParser(ParseServerFromJsonResponse.class)
146 @Path("/grid/server/delete")
147 @ExceptionParser(ReturnNullOnNotFoundOr404.class)
148 ListenableFuture<Server> deleteById(@QueryParam(ID_KEY) long id);
149
150
151
152
153 @GET
154 @ResponseParser(ParseServerFromJsonResponse.class)
155 @Path("/grid/server/delete")
156 @ExceptionParser(ReturnNullOnNotFoundOr404.class)
157 ListenableFuture<Server> deleteByName(@QueryParam(NAME_KEY) String name);
158
159
160
161
162 @GET
163 @ResponseParser(ParseOptionsFromJsonResponse.class)
164 @Path("/common/lookup/list")
165 @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.ram")
166 ListenableFuture<Set<Option>> getRamSizes();
167
168
169
170
171 @GET
172 @ResponseParser(ParseOptionsFromJsonResponse.class)
173 @Path("/common/lookup/list")
174 @QueryParams(keys = LOOKUP_LIST_KEY, values = "server.datacenter")
175 ListenableFuture<Set<Option>> getDatacenters();
176 }