1 | /** |
2 | * |
3 | * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> |
4 | * |
5 | * ==================================================================== |
6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
7 | * you may not use this file except in compliance with the License. |
8 | * 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, software |
13 | * distributed under the License is distributed on an "AS IS" BASIS, |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
15 | * See the License for the specific language governing permissions and |
16 | * limitations under the License. |
17 | * ==================================================================== |
18 | */ |
19 | package org.jclouds.cloudservers.options; |
20 | |
21 | import java.util.Date; |
22 | |
23 | import org.jclouds.openstack.options.BaseListOptions; |
24 | |
25 | /** |
26 | * Options used to control the amount of detail in the request. |
27 | * |
28 | * @see BaseListOptions |
29 | * @see <a href="http://docs.rackspacecloud.com/servers/api/cs-devguide-latest.pdf" /> |
30 | * @author Adrian Cole |
31 | */ |
32 | public class ListOptions extends BaseListOptions { |
33 | |
34 | public static final ListOptions NONE = new ListOptions(); |
35 | |
36 | /** |
37 | * unless used, only the name and id will be returned per row. |
38 | * |
39 | * @return |
40 | */ |
41 | public ListOptions withDetails() { |
42 | this.pathSuffix = "/detail"; |
43 | return this; |
44 | } |
45 | |
46 | /** |
47 | * {@inheritDoc} |
48 | */ |
49 | @Override |
50 | public ListOptions changesSince(Date ifModifiedSince) { |
51 | super.changesSince(ifModifiedSince); |
52 | return this; |
53 | } |
54 | |
55 | /** |
56 | * {@inheritDoc} |
57 | */ |
58 | @Override |
59 | public ListOptions maxResults(int limit) { |
60 | super.maxResults(limit); |
61 | return this; |
62 | |
63 | } |
64 | |
65 | /** |
66 | * {@inheritDoc} |
67 | */ |
68 | @Override |
69 | public ListOptions startAt(long offset) { |
70 | super.startAt(offset); |
71 | return this; |
72 | } |
73 | |
74 | public static class Builder { |
75 | |
76 | /** |
77 | * @see ListOptions#withDetails() |
78 | */ |
79 | public static ListOptions withDetails() { |
80 | ListOptions options = new ListOptions(); |
81 | return options.withDetails(); |
82 | } |
83 | |
84 | /** |
85 | * @see BaseListOptions#startAt(long) |
86 | */ |
87 | public static ListOptions startAt(long prefix) { |
88 | ListOptions options = new ListOptions(); |
89 | return options.startAt(prefix); |
90 | } |
91 | |
92 | /** |
93 | * @see BaseListOptions#maxResults(long) |
94 | */ |
95 | public static ListOptions maxResults(int maxKeys) { |
96 | ListOptions options = new ListOptions(); |
97 | return options.maxResults(maxKeys); |
98 | } |
99 | |
100 | /** |
101 | * @see BaseListOptions#changesSince(Date) |
102 | */ |
103 | public static ListOptions changesSince(Date since) { |
104 | ListOptions options = new ListOptions(); |
105 | return options.changesSince(since); |
106 | } |
107 | |
108 | } |
109 | } |