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.compute.domain;
20
21 import java.util.NoSuchElementException;
22
23 import org.jclouds.compute.domain.internal.TemplateBuilderImpl;
24 import org.jclouds.compute.options.TemplateOptions;
25
26 import com.google.common.base.Predicate;
27 import com.google.inject.ImplementedBy;
28
29 /**
30 * Creates a customized template based on requirements.
31 *
32 * @author Adrian Cole
33 */
34 @ImplementedBy(TemplateBuilderImpl.class)
35 public interface TemplateBuilder {
36
37 /**
38 * prime this builder with parameters known to work on the current compute provider.
39 */
40 TemplateBuilder any();
41
42 /**
43 * Configure this template to require the minimum hardware of the parameter.
44 */
45 TemplateBuilder fromHardware(Hardware hardware);
46
47 /**
48 * Configure this template to fuzzy-match on the image parameter
49 */
50 TemplateBuilder fromImage(Image image);
51
52 /**
53 * Configure this template to match the resources of the template parameter.
54 */
55 TemplateBuilder fromTemplate(Template image);
56
57 /**
58 * configure this template to the smallest hardware, based on cores, ram, then disk
59 */
60 TemplateBuilder smallest();
61
62 /**
63 * configure this template to the fastest hardware, based on cpu
64 */
65 TemplateBuilder fastest();
66
67 /**
68 * configure this template to the largest hardware, based on cores, ram, then disk
69 */
70 TemplateBuilder biggest();
71
72 /**
73 * Configure this template to use a specific operating system image.
74 */
75 TemplateBuilder osFamily(OsFamily os);
76
77 /**
78 * Configure this template to start in a specific location
79 *
80 * @throws NoSuchElementException
81 * if no location matches the id specified
82 */
83 TemplateBuilder locationId(String locationId);
84
85 /**
86 * Configure this template to require a specific imageId.
87 * <p/>
88 * Note that image Ids are often scoped to {@code location}
89 */
90 TemplateBuilder imageId(String imageId);
91
92 /**
93 * Configure this template to require a specific hardwareId.
94 */
95 TemplateBuilder hardwareId(String hardwareId);
96
97 /**
98 * Configure this template to have an operating system name that matches the regular expression
99 */
100 TemplateBuilder osNameMatches(String osNameRegex);
101
102 /**
103 * Configure this template to have an operating system description that matches the regular
104 * expression
105 */
106 TemplateBuilder osDescriptionMatches(String osDescriptionRegex);
107
108 /**
109 * Configure this template to have an os version that matches the regular expression
110 */
111 TemplateBuilder osVersionMatches(String osVersionRegex);
112
113 /**
114 * Configure this template to require a specific architecture. ex. virtualizationType or
115 *
116 */
117 TemplateBuilder osArchMatches(String architecture);
118
119 /**
120 * Configure this template to require a 64 bit operating system.
121 */
122 TemplateBuilder os64Bit(boolean is64bit);
123
124 /**
125 * Configure this template to have an image name that matches the regular expression
126 */
127 TemplateBuilder imageNameMatches(String imageNameRegex);
128
129 /**
130 * Configure this template to have an image version that matches the regular expression
131 */
132 TemplateBuilder imageVersionMatches(String imageVersionRegex);
133
134 /**
135 * Configure this template to have an image description that matches the regular expression
136 */
137 TemplateBuilder imageDescriptionMatches(String imageDescriptionRegex);
138
139 /**
140 * Configure this template to have an image description that matches the supplied condition
141 */
142 TemplateBuilder imageMatches(Predicate<Image> condition);
143
144 /**
145 * Configure this template to require the minimum cores below
146 */
147 TemplateBuilder minCores(double minCores);
148
149 /**
150 * Configure this template to require the minimum ram in megabytes below
151 */
152 TemplateBuilder minRam(int megabytes);
153
154 /**
155 * Generate an immutable template from the current builder.
156 */
157 Template build();
158
159 /**
160 * options such as inbound ports and run scripts.
161 */
162 TemplateBuilder options(TemplateOptions options);
163
164 }