1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/datasync/model/DescribeTaskExecutionResult.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8 #include <aws/core/AmazonWebServiceResult.h>
9 #include <aws/core/utils/StringUtils.h>
10 #include <aws/core/utils/UnreferencedParam.h>
11 
12 #include <utility>
13 
14 using namespace Aws::DataSync::Model;
15 using namespace Aws::Utils::Json;
16 using namespace Aws::Utils;
17 using namespace Aws;
18 
DescribeTaskExecutionResult()19 DescribeTaskExecutionResult::DescribeTaskExecutionResult() :
20     m_status(TaskExecutionStatus::NOT_SET),
21     m_estimatedFilesToTransfer(0),
22     m_estimatedBytesToTransfer(0),
23     m_filesTransferred(0),
24     m_bytesWritten(0),
25     m_bytesTransferred(0)
26 {
27 }
28 
DescribeTaskExecutionResult(const Aws::AmazonWebServiceResult<JsonValue> & result)29 DescribeTaskExecutionResult::DescribeTaskExecutionResult(const Aws::AmazonWebServiceResult<JsonValue>& result) :
30     m_status(TaskExecutionStatus::NOT_SET),
31     m_estimatedFilesToTransfer(0),
32     m_estimatedBytesToTransfer(0),
33     m_filesTransferred(0),
34     m_bytesWritten(0),
35     m_bytesTransferred(0)
36 {
37   *this = result;
38 }
39 
operator =(const Aws::AmazonWebServiceResult<JsonValue> & result)40 DescribeTaskExecutionResult& DescribeTaskExecutionResult::operator =(const Aws::AmazonWebServiceResult<JsonValue>& result)
41 {
42   JsonView jsonValue = result.GetPayload().View();
43   if(jsonValue.ValueExists("TaskExecutionArn"))
44   {
45     m_taskExecutionArn = jsonValue.GetString("TaskExecutionArn");
46 
47   }
48 
49   if(jsonValue.ValueExists("Status"))
50   {
51     m_status = TaskExecutionStatusMapper::GetTaskExecutionStatusForName(jsonValue.GetString("Status"));
52 
53   }
54 
55   if(jsonValue.ValueExists("Options"))
56   {
57     m_options = jsonValue.GetObject("Options");
58 
59   }
60 
61   if(jsonValue.ValueExists("Excludes"))
62   {
63     Array<JsonView> excludesJsonList = jsonValue.GetArray("Excludes");
64     for(unsigned excludesIndex = 0; excludesIndex < excludesJsonList.GetLength(); ++excludesIndex)
65     {
66       m_excludes.push_back(excludesJsonList[excludesIndex].AsObject());
67     }
68   }
69 
70   if(jsonValue.ValueExists("Includes"))
71   {
72     Array<JsonView> includesJsonList = jsonValue.GetArray("Includes");
73     for(unsigned includesIndex = 0; includesIndex < includesJsonList.GetLength(); ++includesIndex)
74     {
75       m_includes.push_back(includesJsonList[includesIndex].AsObject());
76     }
77   }
78 
79   if(jsonValue.ValueExists("StartTime"))
80   {
81     m_startTime = jsonValue.GetDouble("StartTime");
82 
83   }
84 
85   if(jsonValue.ValueExists("EstimatedFilesToTransfer"))
86   {
87     m_estimatedFilesToTransfer = jsonValue.GetInt64("EstimatedFilesToTransfer");
88 
89   }
90 
91   if(jsonValue.ValueExists("EstimatedBytesToTransfer"))
92   {
93     m_estimatedBytesToTransfer = jsonValue.GetInt64("EstimatedBytesToTransfer");
94 
95   }
96 
97   if(jsonValue.ValueExists("FilesTransferred"))
98   {
99     m_filesTransferred = jsonValue.GetInt64("FilesTransferred");
100 
101   }
102 
103   if(jsonValue.ValueExists("BytesWritten"))
104   {
105     m_bytesWritten = jsonValue.GetInt64("BytesWritten");
106 
107   }
108 
109   if(jsonValue.ValueExists("BytesTransferred"))
110   {
111     m_bytesTransferred = jsonValue.GetInt64("BytesTransferred");
112 
113   }
114 
115   if(jsonValue.ValueExists("Result"))
116   {
117     m_result = jsonValue.GetObject("Result");
118 
119   }
120 
121 
122 
123   return *this;
124 }
125