172 lines
3.6 KiB
C++
172 lines
3.6 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/mobile/model/ProjectDetails.h>
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|
|
|
#include <utility>
|
|
|
|
using namespace Aws::Utils::Json;
|
|
using namespace Aws::Utils;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace Mobile
|
|
{
|
|
namespace Model
|
|
{
|
|
|
|
ProjectDetails::ProjectDetails() :
|
|
m_nameHasBeenSet(false),
|
|
m_projectIdHasBeenSet(false),
|
|
m_regionHasBeenSet(false),
|
|
m_state(ProjectState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_createdDateHasBeenSet(false),
|
|
m_lastUpdatedDateHasBeenSet(false),
|
|
m_consoleUrlHasBeenSet(false),
|
|
m_resourcesHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
ProjectDetails::ProjectDetails(JsonView jsonValue) :
|
|
m_nameHasBeenSet(false),
|
|
m_projectIdHasBeenSet(false),
|
|
m_regionHasBeenSet(false),
|
|
m_state(ProjectState::NOT_SET),
|
|
m_stateHasBeenSet(false),
|
|
m_createdDateHasBeenSet(false),
|
|
m_lastUpdatedDateHasBeenSet(false),
|
|
m_consoleUrlHasBeenSet(false),
|
|
m_resourcesHasBeenSet(false)
|
|
{
|
|
*this = jsonValue;
|
|
}
|
|
|
|
ProjectDetails& ProjectDetails::operator =(JsonView jsonValue)
|
|
{
|
|
if(jsonValue.ValueExists("name"))
|
|
{
|
|
m_name = jsonValue.GetString("name");
|
|
|
|
m_nameHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("projectId"))
|
|
{
|
|
m_projectId = jsonValue.GetString("projectId");
|
|
|
|
m_projectIdHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("region"))
|
|
{
|
|
m_region = jsonValue.GetString("region");
|
|
|
|
m_regionHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("state"))
|
|
{
|
|
m_state = ProjectStateMapper::GetProjectStateForName(jsonValue.GetString("state"));
|
|
|
|
m_stateHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("createdDate"))
|
|
{
|
|
m_createdDate = jsonValue.GetDouble("createdDate");
|
|
|
|
m_createdDateHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("lastUpdatedDate"))
|
|
{
|
|
m_lastUpdatedDate = jsonValue.GetDouble("lastUpdatedDate");
|
|
|
|
m_lastUpdatedDateHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("consoleUrl"))
|
|
{
|
|
m_consoleUrl = jsonValue.GetString("consoleUrl");
|
|
|
|
m_consoleUrlHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("resources"))
|
|
{
|
|
Array<JsonView> resourcesJsonList = jsonValue.GetArray("resources");
|
|
for(unsigned resourcesIndex = 0; resourcesIndex < resourcesJsonList.GetLength(); ++resourcesIndex)
|
|
{
|
|
m_resources.push_back(resourcesJsonList[resourcesIndex].AsObject());
|
|
}
|
|
m_resourcesHasBeenSet = true;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
JsonValue ProjectDetails::Jsonize() const
|
|
{
|
|
JsonValue payload;
|
|
|
|
if(m_nameHasBeenSet)
|
|
{
|
|
payload.WithString("name", m_name);
|
|
|
|
}
|
|
|
|
if(m_projectIdHasBeenSet)
|
|
{
|
|
payload.WithString("projectId", m_projectId);
|
|
|
|
}
|
|
|
|
if(m_regionHasBeenSet)
|
|
{
|
|
payload.WithString("region", m_region);
|
|
|
|
}
|
|
|
|
if(m_stateHasBeenSet)
|
|
{
|
|
payload.WithString("state", ProjectStateMapper::GetNameForProjectState(m_state));
|
|
}
|
|
|
|
if(m_createdDateHasBeenSet)
|
|
{
|
|
payload.WithDouble("createdDate", m_createdDate.SecondsWithMSPrecision());
|
|
}
|
|
|
|
if(m_lastUpdatedDateHasBeenSet)
|
|
{
|
|
payload.WithDouble("lastUpdatedDate", m_lastUpdatedDate.SecondsWithMSPrecision());
|
|
}
|
|
|
|
if(m_consoleUrlHasBeenSet)
|
|
{
|
|
payload.WithString("consoleUrl", m_consoleUrl);
|
|
|
|
}
|
|
|
|
if(m_resourcesHasBeenSet)
|
|
{
|
|
Array<JsonValue> resourcesJsonList(m_resources.size());
|
|
for(unsigned resourcesIndex = 0; resourcesIndex < resourcesJsonList.GetLength(); ++resourcesIndex)
|
|
{
|
|
resourcesJsonList[resourcesIndex].AsObject(m_resources[resourcesIndex].Jsonize());
|
|
}
|
|
payload.WithArray("resources", std::move(resourcesJsonList));
|
|
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace Mobile
|
|
} // namespace Aws
|