1 | /* |
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
3 | * contributor license agreements. See the NOTICE file distributed with |
4 | * this work for additional information regarding copyright ownership. |
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
6 | * (the "License"); you may not use this file except in compliance with |
7 | * the License. You may obtain a copy of the License at |
8 | * |
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
10 | * |
11 | * Unless required by applicable law or agreed to in writing, software |
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing permissions and |
15 | * limitations under the License. |
16 | */ |
17 | package org.jclouds.glesys.options; |
18 | |
19 | import org.jclouds.http.options.BaseHttpRequestOptions; |
20 | |
21 | /** |
22 | * @author Adam Lowe |
23 | */ |
24 | public class DomainOptions extends BaseHttpRequestOptions { |
25 | public static class Builder { |
26 | /** |
27 | * @see DomainOptions#primaryNameServer |
28 | */ |
29 | public static DomainOptions primaryNameServer(String primaryNameServer) { |
30 | DomainOptions options = new DomainOptions(); |
31 | return options.primaryNameServer(primaryNameServer); |
32 | } |
33 | |
34 | /** |
35 | * @see DomainOptions#responsiblePerson |
36 | */ |
37 | public static DomainOptions responsiblePerson(String responsiblePerson) { |
38 | DomainOptions options = new DomainOptions(); |
39 | return options.responsiblePerson(responsiblePerson); |
40 | } |
41 | |
42 | /** |
43 | * @see DomainOptions#ttl |
44 | */ |
45 | public static DomainOptions ttl(int ttl) { |
46 | DomainOptions options = new DomainOptions(); |
47 | return options.ttl(ttl); |
48 | } |
49 | |
50 | /** |
51 | * @see DomainOptions#refresh |
52 | */ |
53 | public static DomainOptions refresh(int refresh) { |
54 | DomainOptions options = new DomainOptions(); |
55 | return options.refresh(refresh); |
56 | } |
57 | |
58 | /** |
59 | * @see DomainOptions#retry |
60 | */ |
61 | public static DomainOptions retry(int retry) { |
62 | DomainOptions options = new DomainOptions(); |
63 | return options.retry(retry); |
64 | } |
65 | |
66 | /** |
67 | * @see DomainOptions#expire |
68 | */ |
69 | public static DomainOptions expire(int expire) { |
70 | DomainOptions options = new DomainOptions(); |
71 | return options.expire(expire); |
72 | } |
73 | |
74 | /** |
75 | * @see DomainOptions#minimum |
76 | */ |
77 | public static DomainOptions minimum(int minimum) { |
78 | DomainOptions options = new DomainOptions(); |
79 | return options.minimum(minimum); |
80 | } |
81 | } |
82 | |
83 | /** |
84 | * Configure the primary DNS server for this domain. |
85 | */ |
86 | public DomainOptions primaryNameServer(String primaryNameServer) { |
87 | formParameters.put("primarynameserver", primaryNameServer); |
88 | return this; |
89 | } |
90 | |
91 | /** |
92 | * Configure the E-mail address of the person responsible for this domain (usually attached to MX records). |
93 | */ |
94 | public DomainOptions responsiblePerson(String responsiblePerson) { |
95 | responsiblePerson = responsiblePerson.replaceAll("@", "."); |
96 | if (!responsiblePerson.endsWith(".")) { |
97 | responsiblePerson = responsiblePerson + "."; |
98 | } |
99 | formParameters.put("responsibleperson", responsiblePerson); |
100 | return this; |
101 | } |
102 | |
103 | /** |
104 | * TTL (time to live). The number of seconds a domain name is cached locally before expiration and return to authoritative nameservers for updates |
105 | */ |
106 | public DomainOptions ttl(int ttl) { |
107 | formParameters.put("ttl", Integer.toString(ttl)); |
108 | return this; |
109 | } |
110 | |
111 | /** |
112 | * Configure the number of seconds between update requests from secondary and slave name servers |
113 | */ |
114 | public DomainOptions refresh(int refresh) { |
115 | formParameters.put("refresh", Integer.toString(refresh)); |
116 | return this; |
117 | } |
118 | |
119 | /** |
120 | * Configure the number of seconds the secondary/slave will wait before retrying when the last attempt failed |
121 | */ |
122 | public DomainOptions retry(int retry) { |
123 | formParameters.put("retry", Integer.toString(retry)); |
124 | return this; |
125 | } |
126 | |
127 | /** |
128 | * Configure the number of seconds a master or slave will wait before considering the data stale if it cannot reach the primary name server |
129 | */ |
130 | public DomainOptions expire(int expire) { |
131 | formParameters.put("expire", Integer.toString(expire)); |
132 | return this; |
133 | } |
134 | |
135 | /** |
136 | * Configure the minimum/default TTL if the domain does not specify ttl |
137 | * |
138 | * @see #ttl |
139 | */ |
140 | public DomainOptions minimum(int minimum) { |
141 | formParameters.put("minimum", Integer.toString(minimum)); |
142 | return this; |
143 | } |
144 | } |