| 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.vcloud.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import com.google.common.base.CaseFormat; |
| 24 | |
| 25 | /** |
| 26 | * The AllocationModel element defines how resources are allocated in a vDC. |
| 27 | */ |
| 28 | public enum AllocationModel { |
| 29 | /** |
| 30 | * Resources are committed to a vDC only when vApps are created in it |
| 31 | */ |
| 32 | ALLOCATION_VAPP, |
| 33 | /** |
| 34 | * Only a percentage of the resources you allocate are committed to the organization vDC. |
| 35 | */ |
| 36 | ALLOCATION_POOL, |
| 37 | /** |
| 38 | * All the resources you allocate are committed as a pool to the organization vDC. vApps in vDCs |
| 39 | * that support this allocation model can specify values for resource and limit. |
| 40 | */ |
| 41 | RESERVATION_POOL, |
| 42 | /** |
| 43 | * The VCloud API returned a model unsupported in the version 1.0 spec. |
| 44 | */ |
| 45 | UNRECOGNIZED; |
| 46 | |
| 47 | public String value() { |
| 48 | switch (this) { |
| 49 | case ALLOCATION_VAPP: |
| 50 | return "AllocationVApp"; |
| 51 | case ALLOCATION_POOL: |
| 52 | return "AllocationPool"; |
| 53 | case RESERVATION_POOL: |
| 54 | return "ReservationPool"; |
| 55 | default: |
| 56 | return "UnrecognizedModel"; |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public String toString() { |
| 62 | return value(); |
| 63 | } |
| 64 | |
| 65 | public static AllocationModel fromValue(String model) { |
| 66 | try { |
| 67 | return valueOf(CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, checkNotNull(model, "model"))); |
| 68 | } catch (IllegalArgumentException e) { |
| 69 | return UNRECOGNIZED; |
| 70 | } |
| 71 | } |
| 72 | } |