1/*
2* Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3*
4* Licensed under the Apache License, Version 2.0 (the "License").
5* You may not use this file except in compliance with the License.
6* A copy of the License is located at
7*
8* http://aws.amazon.com/apache2.0
9*
10* or in the "license" file accompanying this file. This file is distributed
11* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12* express or implied. See the License for the specific language governing
13* permissions and limitations under the License.
14*/
15
16#include <aws/s3/model/StorageClass.h>
17#include <aws/core/utils/HashingUtils.h>
18#include <aws/core/Globals.h>
19#include <aws/core/utils/EnumParseOverflowContainer.h>
20
21using namespace Aws::Utils;
22
23
24namespace Aws
25{
26 namespace S3
27 {
28 namespace Model
29 {
30 namespace StorageClassMapper
31 {
32
33 static const int STANDARD_HASH = HashingUtils::HashString("STANDARD");
34 static const int REDUCED_REDUNDANCY_HASH = HashingUtils::HashString("REDUCED_REDUNDANCY");
35 static const int STANDARD_IA_HASH = HashingUtils::HashString("STANDARD_IA");
36 static const int ONEZONE_IA_HASH = HashingUtils::HashString("ONEZONE_IA");
37 static const int INTELLIGENT_TIERING_HASH = HashingUtils::HashString("INTELLIGENT_TIERING");
38 static const int GLACIER_HASH = HashingUtils::HashString("GLACIER");
39 static const int DEEP_ARCHIVE_HASH = HashingUtils::HashString("DEEP_ARCHIVE");
40
41
42 StorageClass GetStorageClassForName(const Aws::String& name)
43 {
44 int hashCode = HashingUtils::HashString(name.c_str());
45 if (hashCode == STANDARD_HASH)
46 {
47 return StorageClass::STANDARD;
48 }
49 else if (hashCode == REDUCED_REDUNDANCY_HASH)
50 {
51 return StorageClass::REDUCED_REDUNDANCY;
52 }
53 else if (hashCode == STANDARD_IA_HASH)
54 {
55 return StorageClass::STANDARD_IA;
56 }
57 else if (hashCode == ONEZONE_IA_HASH)
58 {
59 return StorageClass::ONEZONE_IA;
60 }
61 else if (hashCode == INTELLIGENT_TIERING_HASH)
62 {
63 return StorageClass::INTELLIGENT_TIERING;
64 }
65 else if (hashCode == GLACIER_HASH)
66 {
67 return StorageClass::GLACIER;
68 }
69 else if (hashCode == DEEP_ARCHIVE_HASH)
70 {
71 return StorageClass::DEEP_ARCHIVE;
72 }
73 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
74 if(overflowContainer)
75 {
76 overflowContainer->StoreOverflow(hashCode, name);
77 return static_cast<StorageClass>(hashCode);
78 }
79
80 return StorageClass::NOT_SET;
81 }
82
83 Aws::String GetNameForStorageClass(StorageClass enumValue)
84 {
85 switch(enumValue)
86 {
87 case StorageClass::STANDARD:
88 return "STANDARD";
89 case StorageClass::REDUCED_REDUNDANCY:
90 return "REDUCED_REDUNDANCY";
91 case StorageClass::STANDARD_IA:
92 return "STANDARD_IA";
93 case StorageClass::ONEZONE_IA:
94 return "ONEZONE_IA";
95 case StorageClass::INTELLIGENT_TIERING:
96 return "INTELLIGENT_TIERING";
97 case StorageClass::GLACIER:
98 return "GLACIER";
99 case StorageClass::DEEP_ARCHIVE:
100 return "DEEP_ARCHIVE";
101 default:
102 EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
103 if(overflowContainer)
104 {
105 return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
106 }
107
108 return {};
109 }
110 }
111
112 } // namespace StorageClassMapper
113 } // namespace Model
114 } // namespace S3
115} // namespace Aws
116