| 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.rimuhosting.miro.data; |
| 20 | |
| 21 | import com.google.gson.annotations.SerializedName; |
| 22 | import org.jclouds.rimuhosting.miro.domain.Image; |
| 23 | |
| 24 | /** |
| 25 | * Some options we need to create a new server/VPS. |
| 26 | * |
| 27 | * @author Ivan Meredith |
| 28 | */ |
| 29 | public class CreateOptions implements PostData{ |
| 30 | public CreateOptions(){} |
| 31 | |
| 32 | public CreateOptions(String name, String password, Image image){ |
| 33 | this.name = name; |
| 34 | this.password = password; |
| 35 | if(image != null){ |
| 36 | this.imageId = image.getId(); |
| 37 | } |
| 38 | } |
| 39 | public CreateOptions(String name, String password, String imageId){ |
| 40 | this.name = name; |
| 41 | this.password = password; |
| 42 | this.imageId = imageId; |
| 43 | } |
| 44 | /** |
| 45 | * The control panel to install on the VPS. Currently only webmin is installable manually. |
| 46 | * Currently null/empty string works. For none. Or webmin. |
| 47 | * TODO: Control panels need a rest @GET interface. Or enum |
| 48 | */ |
| 49 | @SerializedName("control_panel") |
| 50 | private String controlPanel; |
| 51 | /** |
| 52 | * Must be a valid Image id. |
| 53 | */ |
| 54 | @SerializedName("distro") |
| 55 | private String imageId; |
| 56 | /** |
| 57 | * Must be FQDN. |
| 58 | */ |
| 59 | @SerializedName("domain_name") |
| 60 | private String name; |
| 61 | /** |
| 62 | * The password to use when setting up the server. If not provided we will set a random one. |
| 63 | */ |
| 64 | private String password; |
| 65 | |
| 66 | public String getControlPanel() { |
| 67 | return controlPanel; |
| 68 | } |
| 69 | |
| 70 | public void setControlPanel(String controlPanel) { |
| 71 | this.controlPanel = controlPanel; |
| 72 | } |
| 73 | |
| 74 | public String getImageId() { |
| 75 | return imageId; |
| 76 | } |
| 77 | |
| 78 | public void setImageId(String imageId) { |
| 79 | this.imageId = imageId; |
| 80 | } |
| 81 | |
| 82 | public String getName() { |
| 83 | return name; |
| 84 | } |
| 85 | |
| 86 | public void setName(String name) { |
| 87 | this.name = name; |
| 88 | } |
| 89 | |
| 90 | public String getPassword() { |
| 91 | return password; |
| 92 | } |
| 93 | |
| 94 | public void setPassword(String password) { |
| 95 | this.password = password; |
| 96 | } |
| 97 | |
| 98 | @Override |
| 99 | public void validate() { |
| 100 | assert(imageId != null && imageId.length() != 0); |
| 101 | //TODO validation of FQDN |
| 102 | } |
| 103 | } |