1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.jclouds.gogrid.options;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22 import static com.google.common.base.Preconditions.checkState;
23 import static org.jclouds.gogrid.reference.GoGridQueryParams.DATACENTER_KEY;
24 import static org.jclouds.gogrid.reference.GoGridQueryParams.IS_SANDBOX_KEY;
25 import static org.jclouds.gogrid.reference.GoGridQueryParams.SERVER_TYPE_KEY;
26
27 import org.jclouds.http.options.BaseHttpRequestOptions;
28
29
30
31
32 public class GetServerListOptions extends BaseHttpRequestOptions {
33
34 public final static GetServerListOptions NONE = new GetServerListOptions();
35
36 public GetServerListOptions limitServerTypeTo(String serverType) {
37 checkState(!queryParameters.containsKey(SERVER_TYPE_KEY),
38 "Can't have duplicate server type limit");
39 queryParameters.put(SERVER_TYPE_KEY, serverType);
40 return this;
41 }
42
43 public GetServerListOptions inDatacenter(String datacenterId) {
44 checkState(!queryParameters.containsKey(DATACENTER_KEY), "Can't have duplicate datacenter id");
45 queryParameters.put(DATACENTER_KEY, datacenterId);
46 return this;
47 }
48
49 public GetServerListOptions onlySandboxServers() {
50 checkState(!queryParameters.containsKey(IS_SANDBOX_KEY),
51 "Can't have duplicate sandbox type limit");
52 queryParameters.put(IS_SANDBOX_KEY, "true");
53 return this;
54 }
55
56 public GetServerListOptions excludeSandboxServers() {
57 checkState(!queryParameters.containsKey(IS_SANDBOX_KEY),
58 "Can't have duplicate sandbox type limit");
59 queryParameters.put(IS_SANDBOX_KEY, "false");
60 return this;
61 }
62
63 public static class Builder {
64 public GetServerListOptions inDatacenter(String datacenterId) {
65 GetServerListOptions getServerListOptions = new GetServerListOptions();
66 getServerListOptions.inDatacenter(checkNotNull(datacenterId));
67 return getServerListOptions;
68 }
69
70 public GetServerListOptions limitServerTypeTo(String serverType) {
71 GetServerListOptions getServerListOptions = new GetServerListOptions();
72 getServerListOptions.limitServerTypeTo(checkNotNull(serverType));
73 return getServerListOptions;
74 }
75
76 public GetServerListOptions onlySandboxServers() {
77 GetServerListOptions getServerListOptions = new GetServerListOptions();
78 getServerListOptions.onlySandboxServers();
79 return getServerListOptions;
80 }
81
82 public GetServerListOptions excludeSandboxServers() {
83 GetServerListOptions getServerListOptions = new GetServerListOptions();
84 getServerListOptions.excludeSandboxServers();
85 return getServerListOptions;
86 }
87
88 }
89
90 }