1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/backup/model/ReportDeliveryChannel.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 Backup
17 {
18 namespace Model
19 {
20 
ReportDeliveryChannel()21 ReportDeliveryChannel::ReportDeliveryChannel() :
22     m_s3BucketNameHasBeenSet(false),
23     m_s3KeyPrefixHasBeenSet(false),
24     m_formatsHasBeenSet(false)
25 {
26 }
27 
ReportDeliveryChannel(JsonView jsonValue)28 ReportDeliveryChannel::ReportDeliveryChannel(JsonView jsonValue) :
29     m_s3BucketNameHasBeenSet(false),
30     m_s3KeyPrefixHasBeenSet(false),
31     m_formatsHasBeenSet(false)
32 {
33   *this = jsonValue;
34 }
35 
operator =(JsonView jsonValue)36 ReportDeliveryChannel& ReportDeliveryChannel::operator =(JsonView jsonValue)
37 {
38   if(jsonValue.ValueExists("S3BucketName"))
39   {
40     m_s3BucketName = jsonValue.GetString("S3BucketName");
41 
42     m_s3BucketNameHasBeenSet = true;
43   }
44 
45   if(jsonValue.ValueExists("S3KeyPrefix"))
46   {
47     m_s3KeyPrefix = jsonValue.GetString("S3KeyPrefix");
48 
49     m_s3KeyPrefixHasBeenSet = true;
50   }
51 
52   if(jsonValue.ValueExists("Formats"))
53   {
54     Array<JsonView> formatsJsonList = jsonValue.GetArray("Formats");
55     for(unsigned formatsIndex = 0; formatsIndex < formatsJsonList.GetLength(); ++formatsIndex)
56     {
57       m_formats.push_back(formatsJsonList[formatsIndex].AsString());
58     }
59     m_formatsHasBeenSet = true;
60   }
61 
62   return *this;
63 }
64 
Jsonize() const65 JsonValue ReportDeliveryChannel::Jsonize() const
66 {
67   JsonValue payload;
68 
69   if(m_s3BucketNameHasBeenSet)
70   {
71    payload.WithString("S3BucketName", m_s3BucketName);
72 
73   }
74 
75   if(m_s3KeyPrefixHasBeenSet)
76   {
77    payload.WithString("S3KeyPrefix", m_s3KeyPrefix);
78 
79   }
80 
81   if(m_formatsHasBeenSet)
82   {
83    Array<JsonValue> formatsJsonList(m_formats.size());
84    for(unsigned formatsIndex = 0; formatsIndex < formatsJsonList.GetLength(); ++formatsIndex)
85    {
86      formatsJsonList[formatsIndex].AsString(m_formats[formatsIndex]);
87    }
88    payload.WithArray("Formats", std::move(formatsJsonList));
89 
90   }
91 
92   return payload;
93 }
94 
95 } // namespace Model
96 } // namespace Backup
97 } // namespace Aws
98