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.trmk.vcloud_0_8;
20  
21  import java.net.URI;
22  import java.util.Map;
23  import java.util.NoSuchElementException;
24  import java.util.Set;
25  import java.util.concurrent.TimeUnit;
26  
27  import org.jclouds.javax.annotation.Nullable;
28  
29  import org.jclouds.concurrent.Timeout;
30  import org.jclouds.trmk.vcloud_0_8.domain.Catalog;
31  import org.jclouds.trmk.vcloud_0_8.domain.CatalogItem;
32  import org.jclouds.trmk.vcloud_0_8.domain.CustomizationParameters;
33  import org.jclouds.trmk.vcloud_0_8.domain.InternetService;
34  import org.jclouds.trmk.vcloud_0_8.domain.KeyPair;
35  import org.jclouds.trmk.vcloud_0_8.domain.Network;
36  import org.jclouds.trmk.vcloud_0_8.domain.Node;
37  import org.jclouds.trmk.vcloud_0_8.domain.Org;
38  import org.jclouds.trmk.vcloud_0_8.domain.Protocol;
39  import org.jclouds.trmk.vcloud_0_8.domain.PublicIpAddress;
40  import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
41  import org.jclouds.trmk.vcloud_0_8.domain.Task;
42  import org.jclouds.trmk.vcloud_0_8.domain.TasksList;
43  import org.jclouds.trmk.vcloud_0_8.domain.VApp;
44  import org.jclouds.trmk.vcloud_0_8.domain.VAppConfiguration;
45  import org.jclouds.trmk.vcloud_0_8.domain.VAppTemplate;
46  import org.jclouds.trmk.vcloud_0_8.domain.VDC;
47  import org.jclouds.trmk.vcloud_0_8.options.AddInternetServiceOptions;
48  import org.jclouds.trmk.vcloud_0_8.options.AddNodeOptions;
49  import org.jclouds.trmk.vcloud_0_8.options.CloneVAppOptions;
50  import org.jclouds.trmk.vcloud_0_8.options.InstantiateVAppTemplateOptions;
51  
52  /**
53   * Provides access to VCloud resources via their REST API.
54   * <p/>
55   * 
56   * @see <a href=
57   *      "https://community.vcloudexpress.terremark.com/en-us/discussion_forums/f/60.aspx"
58   *      />
59   * @author Adrian Cole
60   */
61  @Timeout(duration = 300, timeUnit = TimeUnit.SECONDS)
62  public interface TerremarkVCloudClient {
63     Catalog getCatalog(URI catalogId);
64  
65     /**
66      * returns the catalog in the organization associated with the specified
67      * name. Note that both parameters can be null to choose default.
68      * 
69      * @param orgName
70      *           organization name, or null for the default
71      * @param catalogName
72      *           catalog name, or null for the default
73      * @throws NoSuchElementException
74      *            if you specified an org or catalog name that isn't present
75      */
76     Catalog findCatalogInOrgNamed(@Nullable String orgName, @Nullable String catalogName);
77  
78     CatalogItem getCatalogItem(URI catalogItem);
79  
80     /**
81      * returns the catalog item in the catalog associated with the specified
82      * name. Note that the org and catalog parameters can be null to choose
83      * default.
84      * 
85      * @param orgName
86      *           organization name, or null for the default
87      * @param catalogName
88      *           catalog name, or null for the default
89      * @param itemName
90      *           item you wish to lookup
91      * 
92      * @throws NoSuchElementException
93      *            if you specified an org, catalog, or catalog item name that
94      *            isn't present
95      */
96     CatalogItem findCatalogItemInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName, String itemName);
97  
98     Network findNetworkInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String networkName);
99  
100    Network getNetwork(URI network);
101 
102    /**
103     * returns the VDC in the organization associated with the specified name.
104     * Note that both parameters can be null to choose default.
105     * 
106     * @param orgName
107     *           organization name, or null for the default
108     * @param vdcName
109     *           catalog name, or null for the default
110     * @throws NoSuchElementException
111     *            if you specified an org or vdc name that isn't present
112     */
113    VDC findVDCInOrgNamed(String orgName, String vdcName);
114 
115    TasksList getTasksList(URI tasksListId);
116 
117    TasksList findTasksListInOrgNamed(String orgName, String tasksListName);
118 
119    /**
120     * Whenever the result of a request cannot be returned immediately, the
121     * server creates a Task object and includes it in the response, as a member
122     * of the Tasks container in the response body. Each Task has an href value,
123     * which is a URL that the client can use to retrieve the Task element alone,
124     * without the rest of the response in which it was contained. All
125     * information about the task is included in the Task element when it is
126     * returned in the response's Tasks container, so a client does not need to
127     * make an additional request to the Task URL unless it wants to follow the
128     * progress of a task that was incomplete.
129     */
130    Task getTask(URI taskId);
131 
132    void cancelTask(URI taskId);
133 
134    /**
135     * 
136     * @return a listing of all orgs that the current user has access to.
137     */
138    Map<String, ReferenceType> listOrgs();
139 
140    VApp instantiateVAppTemplateInVDC(URI vDC, URI template, String appName, InstantiateVAppTemplateOptions... options);
141 
142    Task cloneVAppInVDC(URI vDC, URI toClone, String newName, CloneVAppOptions... options);
143 
144    VAppTemplate getVAppTemplate(URI vAppTemplate);
145 
146    /**
147     * returns the vapp template corresponding to a catalog item in the catalog
148     * associated with the specified name. Note that the org and catalog
149     * parameters can be null to choose default.
150     * 
151     * @param orgName
152     *           organization name, or null for the default
153     * @param catalogName
154     *           catalog name, or null for the default
155     * @param itemName
156     *           item you wish to lookup
157     * 
158     * @throws NoSuchElementException
159     *            if you specified an org, catalog, or catalog item name that
160     *            isn't present
161     */
162    VAppTemplate findVAppTemplateInOrgCatalogNamed(@Nullable String orgName, @Nullable String catalogName,
163          String itemName);
164 
165    VApp findVAppInOrgVDCNamed(@Nullable String orgName, @Nullable String catalogName, String vAppName);
166 
167    VApp getVApp(URI vApp);
168 
169    Task deployVApp(URI vAppId);
170 
171    /**
172     * 
173     */
174    Task undeployVApp(URI vAppId);
175 
176    /**
177     * This call powers on the vApp, as specified in the vApp's ovf:Startup
178     * element.
179     */
180    Task powerOnVApp(URI vAppId);
181 
182    /**
183     * This call powers off the vApp, as specified in the vApp's ovf:Startup
184     * element.
185     */
186    Task powerOffVApp(URI vAppId);
187 
188    /**
189     * This call shuts down the vApp.
190     */
191    void shutdownVApp(URI vAppId);
192 
193    /**
194     * This call resets the vApp.
195     */
196    Task resetVApp(URI vAppId);
197 
198    /**
199     * This call suspends the vApp.
200     */
201    Task suspendVApp(URI vAppId);
202 
203    Task deleteVApp(URI vAppId);
204 
205    /**
206     * {@inheritDoc}
207     */
208    VDC getVDC(URI catalogItem);
209 
210    Org getOrg(URI orgId);
211 
212    Org findOrgNamed(String orgName);
213 
214    CustomizationParameters getCustomizationOptions(URI customizationOptions);
215 
216    /**
217     * This call returns a list of public IP addresses.
218     */
219    Set<PublicIpAddress> getPublicIpsAssociatedWithVDC(URI vDCId);
220 
221    void deletePublicIp(URI ipId);
222 
223    /**
224     * This call adds an internet service to a known, existing public IP. This
225     * call is identical to Add Internet Service except you specify the public IP
226     * in the request.
227     * 
228     */
229    InternetService addInternetServiceToExistingIp(URI existingIpId, String serviceName, Protocol protocol, int port,
230          AddInternetServiceOptions... options);
231 
232    void deleteInternetService(URI internetServiceId);
233 
234    InternetService getInternetService(URI internetServiceId);
235 
236    Set<InternetService> getAllInternetServicesInVDC(URI vDCId);
237 
238    /**
239     * This call returns information about the internet service on a public IP.
240     */
241    Set<InternetService> getInternetServicesOnPublicIp(URI ipId);
242 
243    Set<InternetService> getPublicIp(URI ipId);
244 
245    /**
246     * This call adds a node to an existing internet service.
247     * <p/>
248     * Every vDC is assigned a network of 60 IP addresses that can be used as
249     * nodes. Each node can associated with multiple internet service. You can
250     * get a list of the available IP addresses by calling Get IP Addresses for a
251     * Network.
252     * 
253     * @param internetServiceId
254     * @param ipAddress
255     * @param name
256     * @param port
257     * @param options
258     * @return
259     */
260    Node addNode(URI internetServiceId, String ipAddress, String name, int port, AddNodeOptions... options);
261 
262    Node getNode(URI nodeId);
263 
264    Node configureNode(URI nodeId, String name, boolean enabled, @Nullable String description);
265 
266    void deleteNode(URI nodeId);
267 
268    Set<Node> getNodes(URI internetServiceId);
269 
270    /**
271     * This call configures the settings of an existing vApp by passing the new
272     * configuration. The existing vApp must be in a powered off state (status =
273     * 2).
274     * <p/>
275     * You can change the following items for a vApp.
276     * <ol>
277     * <li>vApp name Number of virtual CPUs</li>
278     * <li>Amount of virtual memory</li>
279     * <li>Add a virtual disk</li>
280     * <li>Delete a virtual disk</li>
281     * </ol>
282     * You can make more than one change in a single request. For example, you
283     * can increase the number of virtual CPUs and the amount of virtual memory
284     * in the same request.
285     * 
286     * @param VApp
287     *           vApp to change in power state off
288     * @param configuration
289     *           (s) to change
290     * @return task of configuration change
291     */
292    Task configureVApp(VApp vApp, VAppConfiguration configuration);
293 
294    /**
295     */
296    Set<KeyPair> listKeyPairsInOrg(URI org);
297 
298    /**
299     * @throws IllegalStateException
300     *            if a key of the same name already exists
301     */
302    KeyPair generateKeyPairInOrg(URI org, String name, boolean makeDefault);
303 
304    /**
305     */
306    KeyPair findKeyPairInOrg(URI org, String keyPairName);
307 
308    KeyPair getKeyPair(URI keyPair);
309 
310    // TODO
311    // KeyPair configureKeyPair(int keyPairId, KeyPairConfiguration
312    // keyPairConfiguration);
313 
314    void deleteKeyPair(URI keyPair);
315 
316 }