| 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/BucketLocationConstraint.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 BucketLocationConstraintMapper |
| 31 | { |
| 32 | |
| 33 | static const int EU_HASH = HashingUtils::HashString("EU"); |
| 34 | static const int eu_west_1_HASH = HashingUtils::HashString("eu-west-1"); |
| 35 | static const int us_west_1_HASH = HashingUtils::HashString("us-west-1"); |
| 36 | static const int us_west_2_HASH = HashingUtils::HashString("us-west-2"); |
| 37 | static const int ap_south_1_HASH = HashingUtils::HashString("ap-south-1"); |
| 38 | static const int ap_southeast_1_HASH = HashingUtils::HashString("ap-southeast-1"); |
| 39 | static const int ap_southeast_2_HASH = HashingUtils::HashString("ap-southeast-2"); |
| 40 | static const int ap_northeast_1_HASH = HashingUtils::HashString("ap-northeast-1"); |
| 41 | static const int sa_east_1_HASH = HashingUtils::HashString("sa-east-1"); |
| 42 | static const int cn_north_1_HASH = HashingUtils::HashString("cn-north-1"); |
| 43 | static const int eu_central_1_HASH = HashingUtils::HashString("eu-central-1"); |
| 44 | static const int eu_west_3_HASH = HashingUtils::HashString("eu-west-3"); |
| 45 | static const int eu_west_2_HASH = HashingUtils::HashString("eu-west-2"); |
| 46 | static const int ap_northeast_2_HASH = HashingUtils::HashString("ap-northeast-2"); |
| 47 | static const int ca_central_1_HASH = HashingUtils::HashString("ca-central-1"); |
| 48 | static const int us_gov_west_1_HASH = HashingUtils::HashString("us-gov-west-1"); |
| 49 | static const int us_east_1_HASH = HashingUtils::HashString("us-east-1"); |
| 50 | static const int us_east_2_HASH = HashingUtils::HashString("us-east-2"); |
| 51 | static const int cn_northwest_1_HASH = HashingUtils::HashString("cn-northwest-1"); |
| 52 | |
| 53 | |
| 54 | BucketLocationConstraint GetBucketLocationConstraintForName(const Aws::String& name) |
| 55 | { |
| 56 | int hashCode = HashingUtils::HashString(name.c_str()); |
| 57 | if (hashCode == EU_HASH) |
| 58 | { |
| 59 | return BucketLocationConstraint::EU; |
| 60 | } |
| 61 | else if (hashCode == eu_west_1_HASH) |
| 62 | { |
| 63 | return BucketLocationConstraint::eu_west_1; |
| 64 | } |
| 65 | else if (hashCode == us_west_1_HASH) |
| 66 | { |
| 67 | return BucketLocationConstraint::us_west_1; |
| 68 | } |
| 69 | else if (hashCode == us_west_2_HASH) |
| 70 | { |
| 71 | return BucketLocationConstraint::us_west_2; |
| 72 | } |
| 73 | else if (hashCode == ap_south_1_HASH) |
| 74 | { |
| 75 | return BucketLocationConstraint::ap_south_1; |
| 76 | } |
| 77 | else if (hashCode == ap_southeast_1_HASH) |
| 78 | { |
| 79 | return BucketLocationConstraint::ap_southeast_1; |
| 80 | } |
| 81 | else if (hashCode == ap_southeast_2_HASH) |
| 82 | { |
| 83 | return BucketLocationConstraint::ap_southeast_2; |
| 84 | } |
| 85 | else if (hashCode == ap_northeast_1_HASH) |
| 86 | { |
| 87 | return BucketLocationConstraint::ap_northeast_1; |
| 88 | } |
| 89 | else if (hashCode == sa_east_1_HASH) |
| 90 | { |
| 91 | return BucketLocationConstraint::sa_east_1; |
| 92 | } |
| 93 | else if (hashCode == cn_north_1_HASH) |
| 94 | { |
| 95 | return BucketLocationConstraint::cn_north_1; |
| 96 | } |
| 97 | else if (hashCode == eu_central_1_HASH) |
| 98 | { |
| 99 | return BucketLocationConstraint::eu_central_1; |
| 100 | } |
| 101 | else if (hashCode == eu_west_3_HASH) |
| 102 | { |
| 103 | return BucketLocationConstraint::eu_west_3; |
| 104 | } |
| 105 | else if (hashCode == eu_west_2_HASH) |
| 106 | { |
| 107 | return BucketLocationConstraint::eu_west_2; |
| 108 | } |
| 109 | else if (hashCode == ap_northeast_2_HASH) |
| 110 | { |
| 111 | return BucketLocationConstraint::ap_northeast_2; |
| 112 | } |
| 113 | else if (hashCode == ca_central_1_HASH) |
| 114 | { |
| 115 | return BucketLocationConstraint::ca_central_1; |
| 116 | } |
| 117 | else if (hashCode == us_gov_west_1_HASH) |
| 118 | { |
| 119 | return BucketLocationConstraint::us_gov_west_1; |
| 120 | } |
| 121 | else if (hashCode == us_east_1_HASH) |
| 122 | { |
| 123 | return BucketLocationConstraint::us_east_1; |
| 124 | } |
| 125 | else if (hashCode == us_east_2_HASH) |
| 126 | { |
| 127 | return BucketLocationConstraint::us_east_2; |
| 128 | } |
| 129 | else if (hashCode == cn_northwest_1_HASH) |
| 130 | { |
| 131 | return BucketLocationConstraint::cn_northwest_1; |
| 132 | } |
| 133 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 134 | if(overflowContainer) |
| 135 | { |
| 136 | overflowContainer->StoreOverflow(hashCode, name); |
| 137 | return static_cast<BucketLocationConstraint>(hashCode); |
| 138 | } |
| 139 | |
| 140 | return BucketLocationConstraint::NOT_SET; |
| 141 | } |
| 142 | |
| 143 | Aws::String GetNameForBucketLocationConstraint(BucketLocationConstraint enumValue) |
| 144 | { |
| 145 | switch(enumValue) |
| 146 | { |
| 147 | case BucketLocationConstraint::EU: |
| 148 | return "EU"; |
| 149 | case BucketLocationConstraint::eu_west_1: |
| 150 | return "eu-west-1"; |
| 151 | case BucketLocationConstraint::us_west_1: |
| 152 | return "us-west-1"; |
| 153 | case BucketLocationConstraint::us_west_2: |
| 154 | return "us-west-2"; |
| 155 | case BucketLocationConstraint::ap_south_1: |
| 156 | return "ap-south-1"; |
| 157 | case BucketLocationConstraint::ap_southeast_1: |
| 158 | return "ap-southeast-1"; |
| 159 | case BucketLocationConstraint::ap_southeast_2: |
| 160 | return "ap-southeast-2"; |
| 161 | case BucketLocationConstraint::ap_northeast_1: |
| 162 | return "ap-northeast-1"; |
| 163 | case BucketLocationConstraint::sa_east_1: |
| 164 | return "sa-east-1"; |
| 165 | case BucketLocationConstraint::cn_north_1: |
| 166 | return "cn-north-1"; |
| 167 | case BucketLocationConstraint::eu_central_1: |
| 168 | return "eu-central-1"; |
| 169 | case BucketLocationConstraint::eu_west_3: |
| 170 | return "eu-west-3"; |
| 171 | case BucketLocationConstraint::eu_west_2: |
| 172 | return "eu-west-2"; |
| 173 | case BucketLocationConstraint::ap_northeast_2: |
| 174 | return "ap-northeast-2"; |
| 175 | case BucketLocationConstraint::ca_central_1: |
| 176 | return "ca-central-1"; |
| 177 | case BucketLocationConstraint::us_gov_west_1: |
| 178 | return "us-gov-west-1"; |
| 179 | case BucketLocationConstraint::us_east_1: |
| 180 | return "us-east-1"; |
| 181 | case BucketLocationConstraint::us_east_2: |
| 182 | return "us-east-2"; |
| 183 | case BucketLocationConstraint::cn_northwest_1: |
| 184 | return "cn-northwest-1"; |
| 185 | default: |
| 186 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); |
| 187 | if(overflowContainer) |
| 188 | { |
| 189 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); |
| 190 | } |
| 191 | |
| 192 | return {}; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | } // namespace BucketLocationConstraintMapper |
| 197 | } // namespace Model |
| 198 | } // namespace S3 |
| 199 | } // namespace Aws |
| 200 |