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.Set; |
22 | |
23 | import org.jclouds.ec2.options.internal.BaseEC2RequestOptions; |
24 | |
25 | /** |
26 | * Contains options supported in the Form API for the DescribeSnapshots operation. <h2> |
27 | * Usage</h2> The recommended way to instantiate a DescribeSnapshotsOptions object is to statically |
28 | * import DescribeSnapshotsOptions.Builder.* and invoke a static creation method followed by an |
29 | * instance mutator (if needed): |
30 | * <p/> |
31 | * <code> |
32 | * import static org.jclouds.ec2.options.DescribeSnapshotsOptions.Builder.* |
33 | * <p/> |
34 | * EC2Client connection = // get connection |
35 | * Set<Snapshot> snapshots = connection.getElasticBlockStoreServices().describeSnapshots(restorableBy("123125").snapshotIds(1000, 1004)); |
36 | * <code> |
37 | * |
38 | * @author Adrian Cole |
39 | * @see <a |
40 | * href="http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/index.html?ApiReference-form-DescribeSnapshots.html" |
41 | * /> |
42 | */ |
43 | public class DescribeSnapshotsOptions extends BaseEC2RequestOptions { |
44 | |
45 | /** |
46 | * Account ID of a user that can create volumes from the snapshot. |
47 | * |
48 | */ |
49 | public DescribeSnapshotsOptions restorableBy(String... accountIds) { |
50 | indexFormValuesWithPrefix("RestorableBy", accountIds); |
51 | return this; |
52 | } |
53 | |
54 | public String getRestorableBy() { |
55 | return getFirstFormOrNull("RestorableBy"); |
56 | } |
57 | |
58 | /** |
59 | * The ID of the Amazon EBS snapshot. |
60 | */ |
61 | public DescribeSnapshotsOptions snapshotIds(String... snapshotIds) { |
62 | indexFormValuesWithPrefix("SnapshotId", snapshotIds); |
63 | return this; |
64 | } |
65 | |
66 | public Set<String> getSnapshotIds() { |
67 | return getFormValuesWithKeysPrefixedBy("SnapshotId."); |
68 | } |
69 | |
70 | /** |
71 | * Returns snapshots owned by the specified owner. Multiple owners can be specified. |
72 | * <p/> |
73 | * Valid Values: self | amazon | AWS Account ID |
74 | */ |
75 | public DescribeSnapshotsOptions ownedBy(String... owners) { |
76 | indexFormValuesWithPrefix("Owner", owners); |
77 | return this; |
78 | } |
79 | |
80 | public Set<String> getOwners() { |
81 | return getFormValuesWithKeysPrefixedBy("Owner."); |
82 | } |
83 | |
84 | public static class Builder { |
85 | |
86 | /** |
87 | * @see DescribeSnapshotsOptions#restorableBy(String[] ) |
88 | */ |
89 | public static DescribeSnapshotsOptions restorableBy(String... accountIds) { |
90 | DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); |
91 | return options.restorableBy(accountIds); |
92 | } |
93 | |
94 | /** |
95 | * @see DescribeSnapshotsOptions#snapshotIds(String[] ) |
96 | */ |
97 | public static DescribeSnapshotsOptions snapshotIds(String... snapshotIds) { |
98 | DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); |
99 | return options.snapshotIds(snapshotIds); |
100 | } |
101 | |
102 | /** |
103 | * @see DescribeSnapshotsOptions#ownedBy(String[] ) |
104 | */ |
105 | public static DescribeSnapshotsOptions ownedBy(String... owners) { |
106 | DescribeSnapshotsOptions options = new DescribeSnapshotsOptions(); |
107 | return options.ownedBy(owners); |
108 | } |
109 | |
110 | } |
111 | } |