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.aws.ec2.options;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 import java.util.Date;
24
25 import org.jclouds.date.DateService;
26 import org.jclouds.date.internal.SimpleDateFormatDateService;
27 import org.jclouds.ec2.domain.InstanceType;
28 import org.jclouds.ec2.options.internal.BaseEC2RequestOptions;
29
30 /**
31 * Contains options supported in the Form API for the DescribeSpotPriceHistory operation. <h2>
32 * Usage</h2> The recommended way to instantiate a DescribeSpotPriceHistoryOptions object is to
33 * statically import DescribeSpotPriceHistoryOptions.Builder.* and invoke a static creation method
34 * followed by an instance mutator (if needed):
35 * <p/>
36 * <code>
37 * import static org.jclouds.aws.ec2.options.DescribeSpotPriceHistoryOptions.Builder.*
38 * <p/>
39 * AWSEC2Client client = // get connection
40 * history = client.getSpotInstanceServices().describeSpotPriceHistoryInRegion(from(yesterday).instanceType("m1.small"));
41 * <code>
42 *
43 * @author Adrian Cole
44 * @see <a href=
45 * "http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeSpotPriceHistory.html"
46 * />
47 */
48 public class DescribeSpotPriceHistoryOptions extends BaseEC2RequestOptions {
49 public static final DescribeSpotPriceHistoryOptions NONE = new DescribeSpotPriceHistoryOptions();
50 private static final DateService service = new SimpleDateFormatDateService();
51
52 /**
53 * Start date and time of the Spot Instance price history data.
54 */
55 public DescribeSpotPriceHistoryOptions from(Date start) {
56 formParameters.put("StartTime", service.iso8601DateFormat(checkNotNull(start, "start")));
57 return this;
58 }
59
60 /**
61 * End date and time of the Spot Instance price history data.
62 */
63 public DescribeSpotPriceHistoryOptions to(Date end) {
64 formParameters.put("EndTime", service.iso8601DateFormat(checkNotNull(end, "end")));
65 return this;
66 }
67
68 /**
69 * Specifies the instance type to return.
70 */
71 public DescribeSpotPriceHistoryOptions instanceType(String type) {
72 formParameters.put("InstanceType.1", checkNotNull(type, "type"));
73 return this;
74 }
75
76 /**
77 * The description of the AMI.
78 */
79 public DescribeSpotPriceHistoryOptions productDescription(String description) {
80 formParameters.put("ProductDescription", checkNotNull(description, "description"));
81 return this;
82 }
83
84 public static class Builder {
85 /**
86 * @see DescribeSpotPriceHistoryOptions#from
87 */
88 public static DescribeSpotPriceHistoryOptions from(Date start) {
89 DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
90 return options.from(start);
91 }
92
93 /**
94 * @see DescribeSpotPriceHistoryOptions#to
95 */
96 public static DescribeSpotPriceHistoryOptions to(Date end) {
97 DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
98 return options.to(end);
99 }
100
101 /**
102 * @see DescribeSpotPriceHistoryOptions#instanceType(InstanceType)
103 */
104 public static DescribeSpotPriceHistoryOptions instanceType(String instanceType) {
105 DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
106 return options.instanceType(instanceType);
107 }
108
109 /**
110 * @see DescribeSpotPriceHistoryOptions#productDescription(String)
111 */
112 public static DescribeSpotPriceHistoryOptions productDescription(String description) {
113 DescribeSpotPriceHistoryOptions options = new DescribeSpotPriceHistoryOptions();
114 return options.productDescription(description);
115 }
116
117 }
118 }