| 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 ServerStatusOptions extends BaseHttpRequestOptions { |
| 25 | |
| 26 | public enum StatusTypes { |
| 27 | STATE, CPU, MEMORY, DISK, BANDWIDTH, UPTIME; |
| 28 | } |
| 29 | |
| 30 | public static class Builder { |
| 31 | /** |
| 32 | * @see org.jclouds.glesys.options.ServerStatusOptions#statusType |
| 33 | */ |
| 34 | public static ServerStatusOptions state() { |
| 35 | ServerStatusOptions options = new ServerStatusOptions(); |
| 36 | return options.statusType(StatusTypes.STATE); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @see org.jclouds.glesys.options.ServerStatusOptions#statusType |
| 41 | */ |
| 42 | public static ServerStatusOptions cpu() { |
| 43 | ServerStatusOptions options = new ServerStatusOptions(); |
| 44 | return options.statusType(StatusTypes.CPU); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @see org.jclouds.glesys.options.ServerStatusOptions#statusType |
| 49 | */ |
| 50 | public static ServerStatusOptions memory() { |
| 51 | ServerStatusOptions options = new ServerStatusOptions(); |
| 52 | return options.statusType(StatusTypes.MEMORY); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * @see org.jclouds.glesys.options.ServerStatusOptions#statusType |
| 57 | */ |
| 58 | public static ServerStatusOptions disk() { |
| 59 | ServerStatusOptions options = new ServerStatusOptions(); |
| 60 | return options.statusType(StatusTypes.DISK); |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * @see org.jclouds.glesys.options.ServerStatusOptions#statusType |
| 65 | */ |
| 66 | public static ServerStatusOptions bandwidth() { |
| 67 | ServerStatusOptions options = new ServerStatusOptions(); |
| 68 | return options.statusType(StatusTypes.BANDWIDTH); |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /** |
| 73 | * Select the given type of information form the server |
| 74 | */ |
| 75 | public ServerStatusOptions statusType(StatusTypes type) { |
| 76 | formParameters.put("statustype", type.name().toLowerCase()); |
| 77 | return this; |
| 78 | } |
| 79 | } |