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.ec2.options; |
20 | |
21 | import java.util.Arrays; |
22 | import java.util.Set; |
23 | |
24 | import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; |
25 | |
26 | /** |
27 | * Contains options supported in the Form API for the DescribeRegions operation. <h2> |
28 | * Usage</h2> The recommended way to instantiate a DescribeRegionsOptions object is to statically |
29 | * import DescribeRegionsOptions.Builder.* and invoke a static creation method followed by an |
30 | * instance mutator (if needed): |
31 | * <p/> |
32 | * <code> |
33 | * import static org.jclouds.ec2.options.DescribeRegionsOptions.Builder.* |
34 | * <p/> |
35 | * EC2Client connection = // get connection |
36 | * Future<Set<ImageMetadata>> images = connection.getRegionsAndRegionsServices().describeRegions(regions("us-east-1a", "us-east-1b")); |
37 | * <code> |
38 | * |
39 | * @author Adrian Cole |
40 | * @see <a |
41 | * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeRegions.html" |
42 | * /> |
43 | */ |
44 | public class DescribeRegionsOptions extends BaseEC2RequestOptions { |
45 | |
46 | /** |
47 | * Name of a Region. |
48 | */ |
49 | public DescribeRegionsOptions regions(String... regions) { |
50 | String[] regionStrings = Arrays.copyOf(regions, regions.length, String[].class); |
51 | indexFormValuesWithPrefix("RegionName", regionStrings); |
52 | return this; |
53 | } |
54 | |
55 | public Set<String> getZones() { |
56 | return getFormValuesWithKeysPrefixedBy("RegionName."); |
57 | } |
58 | |
59 | public static class Builder { |
60 | |
61 | /** |
62 | * @see DescribeRegionsOptions#regions(String[] ) |
63 | */ |
64 | public static DescribeRegionsOptions regions(String... regions) { |
65 | DescribeRegionsOptions options = new DescribeRegionsOptions(); |
66 | return options.regions(regions); |
67 | } |
68 | |
69 | } |
70 | } |