| 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/TransitionStorageClass.h> |
| 17 | #include <aws/core/utils/HashingUtils.h> |
| 18 | #include <aws/core/Globals.h> |
| 19 | #include <aws/core/utils/EnumParseOverflowContainer.h> |
| 20 | |
| 21 | using namespace Aws::Utils; |
| 22 | |
| 23 | |
| 24 | namespace Aws |
| 25 | { |
| 26 | namespace S3 |
| 27 | { |
| 28 | namespace Model |
| 29 | { |
| 30 | namespace TransitionStorageClassMapper |
| 31 | { |
| 32 | |
| 33 | static const int GLACIER_HASH = HashingUtils::HashString("GLACIER"); |
| 34 | static const int STANDARD_IA_HASH = HashingUtils::HashString("STANDARD_IA"); |
| 35 | static const int ONEZONE_IA_HASH = HashingUtils::HashString("ONEZONE_IA"); |
| 36 | static const int INTELLIGENT_TIERING_HASH = HashingUtils::HashString("INTELLIGENT_TIERING"); |
| 37 | static const int DEEP_ARCHIVE_HASH = HashingUtils::HashString("DEEP_ARCHIVE"); |
| 38 | |
| 39 | |
| 40 | TransitionStorageClass GetTransitionStorageClassForName(const Aws::String& name) |
| 41 | { |
| 42 | int hashCode = HashingUtils::HashString(name.c_str()); |
| 43 | if (hashCode == GLACIER_HASH) |
| 44 | { |
| 45 | return TransitionStorageClass::GLACIER; |
| 46 | } |
| 47 | else if (hashCode == STANDARD_IA_HASH) |
| 48 | { |
| 49 | return TransitionStorageClass::STANDARD_IA; |
| 50 | } |
| 51 | else if (hashCode == ONEZONE_IA_HASH) |
| 52 | { |
| 53 | return TransitionStorageClass::ONEZONE_IA; |
| 54 | } |
| 55 | else if (hashCode == INTELLIGENT_TIERING_HASH) |
| 56 | { |
| 57 | return TransitionStorageClass::INTELLIGENT_TIERING; |
| 58 | } |
| 59 | else if (hashCode == DEEP_ARCHIVE_HASH) |
| 60 | { |
| 61 | return TransitionStorageClass::DEEP_ARCHIVE; |
| 62 | } |
| 63 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 64 | if(overflowContainer) |
| 65 | { |
| 66 | overflowContainer->StoreOverflow(hashCode, name); |
| 67 | return static_cast<TransitionStorageClass>(hashCode); |
| 68 | } |
| 69 | |
| 70 | return TransitionStorageClass::NOT_SET; |
| 71 | } |
| 72 | |
| 73 | Aws::String GetNameForTransitionStorageClass(TransitionStorageClass enumValue) |
| 74 | { |
| 75 | switch(enumValue) |
| 76 | { |
| 77 | case TransitionStorageClass::GLACIER: |
| 78 | return "GLACIER"; |
| 79 | case TransitionStorageClass::STANDARD_IA: |
| 80 | return "STANDARD_IA"; |
| 81 | case TransitionStorageClass::ONEZONE_IA: |
| 82 | return "ONEZONE_IA"; |
| 83 | case TransitionStorageClass::INTELLIGENT_TIERING: |
| 84 | return "INTELLIGENT_TIERING"; |
| 85 | case TransitionStorageClass::DEEP_ARCHIVE: |
| 86 | return "DEEP_ARCHIVE"; |
| 87 | default: |
| 88 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 89 | if(overflowContainer) |
| 90 | { |
| 91 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); |
| 92 | } |
| 93 | |
| 94 | return {}; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | } // namespace TransitionStorageClassMapper |
| 99 | } // namespace Model |
| 100 | } // namespace S3 |
| 101 | } // namespace Aws |
| 102 |