| 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/Event.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 EventMapper | 
| 31 | { | 
| 32 | |
| 33 | static const int s3_ReducedRedundancyLostObject_HASH = HashingUtils::HashString( "s3:ReducedRedundancyLostObject"); | 
| 34 | static const int s3_ObjectCreated_HASH = HashingUtils::HashString( "s3:ObjectCreated:*"); | 
| 35 | static const int s3_ObjectCreated_Put_HASH = HashingUtils::HashString( "s3:ObjectCreated:Put"); | 
| 36 | static const int s3_ObjectCreated_Post_HASH = HashingUtils::HashString( "s3:ObjectCreated:Post"); | 
| 37 | static const int s3_ObjectCreated_Copy_HASH = HashingUtils::HashString( "s3:ObjectCreated:Copy"); | 
| 38 | static const int s3_ObjectCreated_CompleteMultipartUpload_HASH = HashingUtils::HashString( "s3:ObjectCreated:CompleteMultipartUpload"); | 
| 39 | static const int s3_ObjectRemoved_HASH = HashingUtils::HashString( "s3:ObjectRemoved:*"); | 
| 40 | static const int s3_ObjectRemoved_Delete_HASH = HashingUtils::HashString( "s3:ObjectRemoved:Delete"); | 
| 41 | static const int s3_ObjectRemoved_DeleteMarkerCreated_HASH = HashingUtils::HashString( "s3:ObjectRemoved:DeleteMarkerCreated"); | 
| 42 | static const int s3_ObjectRestore_HASH = HashingUtils::HashString( "s3:ObjectRestore:*"); | 
| 43 | static const int s3_ObjectRestore_Post_HASH = HashingUtils::HashString( "s3:ObjectRestore:Post"); | 
| 44 | static const int s3_ObjectRestore_Completed_HASH = HashingUtils::HashString( "s3:ObjectRestore:Completed"); | 
| 45 | static const int s3_Replication_HASH = HashingUtils::HashString( "s3:Replication:*"); | 
| 46 | static const int s3_Replication_OperationFailedReplication_HASH = HashingUtils::HashString( "s3:Replication:OperationFailedReplication"); | 
| 47 | static const int s3_Replication_OperationNotTracked_HASH = HashingUtils::HashString( "s3:Replication:OperationNotTracked"); | 
| 48 | static const int s3_Replication_OperationMissedThreshold_HASH = HashingUtils::HashString( "s3:Replication:OperationMissedThreshold"); | 
| 49 | static const int s3_Replication_OperationReplicatedAfterThreshold_HASH = HashingUtils::HashString( "s3:Replication:OperationReplicatedAfterThreshold"); | 
| 50 | |
| 51 | |
| 52 | Event GetEventForName(const Aws::String& name) | 
| 53 | { | 
| 54 | int hashCode = HashingUtils::HashString(name.c_str()); | 
| 55 | if (hashCode == s3_ReducedRedundancyLostObject_HASH) | 
| 56 | { | 
| 57 | return Event::s3_ReducedRedundancyLostObject; | 
| 58 | } | 
| 59 | else if (hashCode == s3_ObjectCreated_HASH) | 
| 60 | { | 
| 61 | return Event::s3_ObjectCreated; | 
| 62 | } | 
| 63 | else if (hashCode == s3_ObjectCreated_Put_HASH) | 
| 64 | { | 
| 65 | return Event::s3_ObjectCreated_Put; | 
| 66 | } | 
| 67 | else if (hashCode == s3_ObjectCreated_Post_HASH) | 
| 68 | { | 
| 69 | return Event::s3_ObjectCreated_Post; | 
| 70 | } | 
| 71 | else if (hashCode == s3_ObjectCreated_Copy_HASH) | 
| 72 | { | 
| 73 | return Event::s3_ObjectCreated_Copy; | 
| 74 | } | 
| 75 | else if (hashCode == s3_ObjectCreated_CompleteMultipartUpload_HASH) | 
| 76 | { | 
| 77 | return Event::s3_ObjectCreated_CompleteMultipartUpload; | 
| 78 | } | 
| 79 | else if (hashCode == s3_ObjectRemoved_HASH) | 
| 80 | { | 
| 81 | return Event::s3_ObjectRemoved; | 
| 82 | } | 
| 83 | else if (hashCode == s3_ObjectRemoved_Delete_HASH) | 
| 84 | { | 
| 85 | return Event::s3_ObjectRemoved_Delete; | 
| 86 | } | 
| 87 | else if (hashCode == s3_ObjectRemoved_DeleteMarkerCreated_HASH) | 
| 88 | { | 
| 89 | return Event::s3_ObjectRemoved_DeleteMarkerCreated; | 
| 90 | } | 
| 91 | else if (hashCode == s3_ObjectRestore_HASH) | 
| 92 | { | 
| 93 | return Event::s3_ObjectRestore; | 
| 94 | } | 
| 95 | else if (hashCode == s3_ObjectRestore_Post_HASH) | 
| 96 | { | 
| 97 | return Event::s3_ObjectRestore_Post; | 
| 98 | } | 
| 99 | else if (hashCode == s3_ObjectRestore_Completed_HASH) | 
| 100 | { | 
| 101 | return Event::s3_ObjectRestore_Completed; | 
| 102 | } | 
| 103 | else if (hashCode == s3_Replication_HASH) | 
| 104 | { | 
| 105 | return Event::s3_Replication; | 
| 106 | } | 
| 107 | else if (hashCode == s3_Replication_OperationFailedReplication_HASH) | 
| 108 | { | 
| 109 | return Event::s3_Replication_OperationFailedReplication; | 
| 110 | } | 
| 111 | else if (hashCode == s3_Replication_OperationNotTracked_HASH) | 
| 112 | { | 
| 113 | return Event::s3_Replication_OperationNotTracked; | 
| 114 | } | 
| 115 | else if (hashCode == s3_Replication_OperationMissedThreshold_HASH) | 
| 116 | { | 
| 117 | return Event::s3_Replication_OperationMissedThreshold; | 
| 118 | } | 
| 119 | else if (hashCode == s3_Replication_OperationReplicatedAfterThreshold_HASH) | 
| 120 | { | 
| 121 | return Event::s3_Replication_OperationReplicatedAfterThreshold; | 
| 122 | } | 
| 123 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); | 
| 124 | if(overflowContainer) | 
| 125 | { | 
| 126 | overflowContainer->StoreOverflow(hashCode, name); | 
| 127 | return static_cast<Event>(hashCode); | 
| 128 | } | 
| 129 | |
| 130 | return Event::NOT_SET; | 
| 131 | } | 
| 132 | |
| 133 | Aws::String GetNameForEvent(Event enumValue) | 
| 134 | { | 
| 135 | switch(enumValue) | 
| 136 | { | 
| 137 | case Event::s3_ReducedRedundancyLostObject: | 
| 138 | return "s3:ReducedRedundancyLostObject"; | 
| 139 | case Event::s3_ObjectCreated: | 
| 140 | return "s3:ObjectCreated:*"; | 
| 141 | case Event::s3_ObjectCreated_Put: | 
| 142 | return "s3:ObjectCreated:Put"; | 
| 143 | case Event::s3_ObjectCreated_Post: | 
| 144 | return "s3:ObjectCreated:Post"; | 
| 145 | case Event::s3_ObjectCreated_Copy: | 
| 146 | return "s3:ObjectCreated:Copy"; | 
| 147 | case Event::s3_ObjectCreated_CompleteMultipartUpload: | 
| 148 | return "s3:ObjectCreated:CompleteMultipartUpload"; | 
| 149 | case Event::s3_ObjectRemoved: | 
| 150 | return "s3:ObjectRemoved:*"; | 
| 151 | case Event::s3_ObjectRemoved_Delete: | 
| 152 | return "s3:ObjectRemoved:Delete"; | 
| 153 | case Event::s3_ObjectRemoved_DeleteMarkerCreated: | 
| 154 | return "s3:ObjectRemoved:DeleteMarkerCreated"; | 
| 155 | case Event::s3_ObjectRestore: | 
| 156 | return "s3:ObjectRestore:*"; | 
| 157 | case Event::s3_ObjectRestore_Post: | 
| 158 | return "s3:ObjectRestore:Post"; | 
| 159 | case Event::s3_ObjectRestore_Completed: | 
| 160 | return "s3:ObjectRestore:Completed"; | 
| 161 | case Event::s3_Replication: | 
| 162 | return "s3:Replication:*"; | 
| 163 | case Event::s3_Replication_OperationFailedReplication: | 
| 164 | return "s3:Replication:OperationFailedReplication"; | 
| 165 | case Event::s3_Replication_OperationNotTracked: | 
| 166 | return "s3:Replication:OperationNotTracked"; | 
| 167 | case Event::s3_Replication_OperationMissedThreshold: | 
| 168 | return "s3:Replication:OperationMissedThreshold"; | 
| 169 | case Event::s3_Replication_OperationReplicatedAfterThreshold: | 
| 170 | return "s3:Replication:OperationReplicatedAfterThreshold"; | 
| 171 | default: | 
| 172 | EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer(); | 
| 173 | if(overflowContainer) | 
| 174 | { | 
| 175 | return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue)); | 
| 176 | } | 
| 177 | |
| 178 | return {}; | 
| 179 | } | 
| 180 | } | 
| 181 | |
| 182 | } // namespace EventMapper | 
| 183 | } // namespace Model | 
| 184 | } // namespace S3 | 
| 185 | } // namespace Aws | 
| 186 | 
