1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 6 #include <aws/glue/model/BackfillError.h> 7 #include <aws/core/utils/json/JsonSerializer.h> 8 9 #include <utility> 10 11 using namespace Aws::Utils::Json; 12 using namespace Aws::Utils; 13 14 namespace Aws 15 { 16 namespace Glue 17 { 18 namespace Model 19 { 20 BackfillError()21BackfillError::BackfillError() : 22 m_code(BackfillErrorCode::NOT_SET), 23 m_codeHasBeenSet(false), 24 m_partitionsHasBeenSet(false) 25 { 26 } 27 BackfillError(JsonView jsonValue)28BackfillError::BackfillError(JsonView jsonValue) : 29 m_code(BackfillErrorCode::NOT_SET), 30 m_codeHasBeenSet(false), 31 m_partitionsHasBeenSet(false) 32 { 33 *this = jsonValue; 34 } 35 operator =(JsonView jsonValue)36BackfillError& BackfillError::operator =(JsonView jsonValue) 37 { 38 if(jsonValue.ValueExists("Code")) 39 { 40 m_code = BackfillErrorCodeMapper::GetBackfillErrorCodeForName(jsonValue.GetString("Code")); 41 42 m_codeHasBeenSet = true; 43 } 44 45 if(jsonValue.ValueExists("Partitions")) 46 { 47 Array<JsonView> partitionsJsonList = jsonValue.GetArray("Partitions"); 48 for(unsigned partitionsIndex = 0; partitionsIndex < partitionsJsonList.GetLength(); ++partitionsIndex) 49 { 50 m_partitions.push_back(partitionsJsonList[partitionsIndex].AsObject()); 51 } 52 m_partitionsHasBeenSet = true; 53 } 54 55 return *this; 56 } 57 Jsonize() const58JsonValue BackfillError::Jsonize() const 59 { 60 JsonValue payload; 61 62 if(m_codeHasBeenSet) 63 { 64 payload.WithString("Code", BackfillErrorCodeMapper::GetNameForBackfillErrorCode(m_code)); 65 } 66 67 if(m_partitionsHasBeenSet) 68 { 69 Array<JsonValue> partitionsJsonList(m_partitions.size()); 70 for(unsigned partitionsIndex = 0; partitionsIndex < partitionsJsonList.GetLength(); ++partitionsIndex) 71 { 72 partitionsJsonList[partitionsIndex].AsObject(m_partitions[partitionsIndex].Jsonize()); 73 } 74 payload.WithArray("Partitions", std::move(partitionsJsonList)); 75 76 } 77 78 return payload; 79 } 80 81 } // namespace Model 82 } // namespace Glue 83 } // namespace Aws 84