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.trmk.vcloud_0_8.domain;
20
21 import static com.google.common.base.Preconditions.checkNotNull;
22
23 /**
24 * Objects such as vAppTemplate, vApp, and Vm have a status attribute whose
25 * value indicates the state of the object. Status for an object, such as a
26 * vAppTemplate or vApp, whose Children (Vm objects) each have a status of their
27 * own, is computed from the status of the Children.
28 *
29 * <h2>NOTE</h2>
30 * <p/>
31 * The deployment status of an object is indicated by the value of its deployed
32 * attribute.
33 *
34 * @since vcloud api 0.8
35 *
36 * @author Adrian Cole
37 */
38 public enum Status {
39
40 /**
41 * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is unresolved.
42 *
43 * @since vcloud api 0.8
44 */
45 UNRESOLVED,
46 /**
47 * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is resolved.
48 *
49 * @since vcloud api 0.8
50 */
51 RESOLVED,
52
53 /**
54 * The {@link VApp} or {@link Vm} is suspended.
55 *
56 * @since vcloud api 0.8
57 */
58 SUSPENDED,
59 /**
60 * The {@link VApp} or {@link Vm} is powered on
61 *
62 * @since vcloud api 0.8
63 */
64 ON,
65 /**
66 * The {@link VAppTemplate}, {@link VApp}, or {@link Vm} is off.
67 *
68 * @since vcloud api 0.8
69 */
70 OFF, UNRECOGNIZED, DEPLOYED;
71 public String value() {
72 switch (this) {
73 case UNRESOLVED:
74 return "0";
75 case RESOLVED:
76 return "1";
77 case OFF:
78 return "2";
79 case SUSPENDED:
80 return "3";
81 case ON:
82 return "4";
83 default:
84 return "7";
85 }
86 }
87
88 public static Status fromValue(String status) {
89 try {
90 return fromValue(Integer.parseInt(checkNotNull(status, "status")));
91 } catch (IllegalArgumentException e) {
92 return UNRECOGNIZED;
93 }
94 }
95
96 public static Status fromValue(int v) {
97 switch (v) {
98 case 0:
99 return UNRESOLVED;
100 case 1:
101 return RESOLVED;
102 case 2:
103 return OFF;
104 case 3:
105 return SUSPENDED;
106 case 4:
107 return ON;
108 case 7:
109 return UNRECOGNIZED;
110 default:
111 return UNRECOGNIZED;
112 }
113 }
114
115 }