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.ec2.domain; |
20 | |
21 | import org.jclouds.ec2.EC2AsyncClient; |
22 | |
23 | /** |
24 | * |
25 | * An attribute of an AMI. |
26 | * |
27 | * @author Adrian Cole |
28 | * @see EC2AsyncClient#modifyImageAttribute |
29 | * @see EC2AsyncClient#resetImageAttribute |
30 | * @see EC2AsyncClient#describeImageAttribute |
31 | * |
32 | */ |
33 | public enum ImageAttribute { |
34 | |
35 | /** |
36 | * the product code associated with the AMI. |
37 | */ |
38 | PRODUCT_CODES, |
39 | |
40 | /** |
41 | * the ID of the RAM disk associated with the AMI. |
42 | */ |
43 | RAMDISK, |
44 | |
45 | /** |
46 | * the ID of the kernel associated with the AMI. |
47 | */ |
48 | KERNEL, |
49 | /** |
50 | * the launch permissions of the AMI. |
51 | */ |
52 | LAUNCH_PERMISSION, |
53 | /** |
54 | * the operating system platform. |
55 | */ |
56 | PLATFORM, |
57 | /** |
58 | * the mapping that defines native device names to use when exposing virtual devices. |
59 | */ |
60 | BLOCK_DEVICE_MAPPING, UNRECOGNIZED; |
61 | public String value() { |
62 | switch (this) { |
63 | case PRODUCT_CODES: |
64 | return "productCodes"; |
65 | case RAMDISK: |
66 | return "ramdisk"; |
67 | case KERNEL: |
68 | return "kernel"; |
69 | case LAUNCH_PERMISSION: |
70 | return "launchPermission"; |
71 | case PLATFORM: |
72 | return "platform"; |
73 | case BLOCK_DEVICE_MAPPING: |
74 | return "blockDeviceMapping"; |
75 | default: |
76 | throw new IllegalArgumentException("unmapped attribute: " + super.name()); |
77 | } |
78 | } |
79 | |
80 | @Override |
81 | public String toString() { |
82 | return value(); |
83 | } |
84 | |
85 | public static ImageAttribute fromValue(String attribute) { |
86 | if ("productCodes".equals(attribute)) |
87 | return PRODUCT_CODES; |
88 | else if ("ramdisk".equals(attribute)) |
89 | return RAMDISK; |
90 | else if ("kernel".equals(attribute)) |
91 | return KERNEL; |
92 | else if ("launchPermission".equals(attribute)) |
93 | return LAUNCH_PERMISSION; |
94 | else if ("platform".equals(attribute)) |
95 | return PLATFORM; |
96 | else if ("blockDeviceMapping".equals(attribute)) |
97 | return BLOCK_DEVICE_MAPPING; |
98 | else |
99 | return UNRECOGNIZED; |
100 | } |
101 | |
102 | } |