203 lines
5.4 KiB
C++
203 lines
5.4 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/ecs/model/ContainerOverride.h>
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|
|
|
#include <utility>
|
|
|
|
using namespace Aws::Utils::Json;
|
|
using namespace Aws::Utils;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace ECS
|
|
{
|
|
namespace Model
|
|
{
|
|
|
|
ContainerOverride::ContainerOverride() :
|
|
m_nameHasBeenSet(false),
|
|
m_commandHasBeenSet(false),
|
|
m_environmentHasBeenSet(false),
|
|
m_environmentFilesHasBeenSet(false),
|
|
m_cpu(0),
|
|
m_cpuHasBeenSet(false),
|
|
m_memory(0),
|
|
m_memoryHasBeenSet(false),
|
|
m_memoryReservation(0),
|
|
m_memoryReservationHasBeenSet(false),
|
|
m_resourceRequirementsHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
ContainerOverride::ContainerOverride(JsonView jsonValue) :
|
|
m_nameHasBeenSet(false),
|
|
m_commandHasBeenSet(false),
|
|
m_environmentHasBeenSet(false),
|
|
m_environmentFilesHasBeenSet(false),
|
|
m_cpu(0),
|
|
m_cpuHasBeenSet(false),
|
|
m_memory(0),
|
|
m_memoryHasBeenSet(false),
|
|
m_memoryReservation(0),
|
|
m_memoryReservationHasBeenSet(false),
|
|
m_resourceRequirementsHasBeenSet(false)
|
|
{
|
|
*this = jsonValue;
|
|
}
|
|
|
|
ContainerOverride& ContainerOverride::operator =(JsonView jsonValue)
|
|
{
|
|
if(jsonValue.ValueExists("name"))
|
|
{
|
|
m_name = jsonValue.GetString("name");
|
|
|
|
m_nameHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("command"))
|
|
{
|
|
Array<JsonView> commandJsonList = jsonValue.GetArray("command");
|
|
for(unsigned commandIndex = 0; commandIndex < commandJsonList.GetLength(); ++commandIndex)
|
|
{
|
|
m_command.push_back(commandJsonList[commandIndex].AsString());
|
|
}
|
|
m_commandHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("environment"))
|
|
{
|
|
Array<JsonView> environmentJsonList = jsonValue.GetArray("environment");
|
|
for(unsigned environmentIndex = 0; environmentIndex < environmentJsonList.GetLength(); ++environmentIndex)
|
|
{
|
|
m_environment.push_back(environmentJsonList[environmentIndex].AsObject());
|
|
}
|
|
m_environmentHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("environmentFiles"))
|
|
{
|
|
Array<JsonView> environmentFilesJsonList = jsonValue.GetArray("environmentFiles");
|
|
for(unsigned environmentFilesIndex = 0; environmentFilesIndex < environmentFilesJsonList.GetLength(); ++environmentFilesIndex)
|
|
{
|
|
m_environmentFiles.push_back(environmentFilesJsonList[environmentFilesIndex].AsObject());
|
|
}
|
|
m_environmentFilesHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("cpu"))
|
|
{
|
|
m_cpu = jsonValue.GetInteger("cpu");
|
|
|
|
m_cpuHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("memory"))
|
|
{
|
|
m_memory = jsonValue.GetInteger("memory");
|
|
|
|
m_memoryHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("memoryReservation"))
|
|
{
|
|
m_memoryReservation = jsonValue.GetInteger("memoryReservation");
|
|
|
|
m_memoryReservationHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("resourceRequirements"))
|
|
{
|
|
Array<JsonView> resourceRequirementsJsonList = jsonValue.GetArray("resourceRequirements");
|
|
for(unsigned resourceRequirementsIndex = 0; resourceRequirementsIndex < resourceRequirementsJsonList.GetLength(); ++resourceRequirementsIndex)
|
|
{
|
|
m_resourceRequirements.push_back(resourceRequirementsJsonList[resourceRequirementsIndex].AsObject());
|
|
}
|
|
m_resourceRequirementsHasBeenSet = true;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
JsonValue ContainerOverride::Jsonize() const
|
|
{
|
|
JsonValue payload;
|
|
|
|
if(m_nameHasBeenSet)
|
|
{
|
|
payload.WithString("name", m_name);
|
|
|
|
}
|
|
|
|
if(m_commandHasBeenSet)
|
|
{
|
|
Array<JsonValue> commandJsonList(m_command.size());
|
|
for(unsigned commandIndex = 0; commandIndex < commandJsonList.GetLength(); ++commandIndex)
|
|
{
|
|
commandJsonList[commandIndex].AsString(m_command[commandIndex]);
|
|
}
|
|
payload.WithArray("command", std::move(commandJsonList));
|
|
|
|
}
|
|
|
|
if(m_environmentHasBeenSet)
|
|
{
|
|
Array<JsonValue> environmentJsonList(m_environment.size());
|
|
for(unsigned environmentIndex = 0; environmentIndex < environmentJsonList.GetLength(); ++environmentIndex)
|
|
{
|
|
environmentJsonList[environmentIndex].AsObject(m_environment[environmentIndex].Jsonize());
|
|
}
|
|
payload.WithArray("environment", std::move(environmentJsonList));
|
|
|
|
}
|
|
|
|
if(m_environmentFilesHasBeenSet)
|
|
{
|
|
Array<JsonValue> environmentFilesJsonList(m_environmentFiles.size());
|
|
for(unsigned environmentFilesIndex = 0; environmentFilesIndex < environmentFilesJsonList.GetLength(); ++environmentFilesIndex)
|
|
{
|
|
environmentFilesJsonList[environmentFilesIndex].AsObject(m_environmentFiles[environmentFilesIndex].Jsonize());
|
|
}
|
|
payload.WithArray("environmentFiles", std::move(environmentFilesJsonList));
|
|
|
|
}
|
|
|
|
if(m_cpuHasBeenSet)
|
|
{
|
|
payload.WithInteger("cpu", m_cpu);
|
|
|
|
}
|
|
|
|
if(m_memoryHasBeenSet)
|
|
{
|
|
payload.WithInteger("memory", m_memory);
|
|
|
|
}
|
|
|
|
if(m_memoryReservationHasBeenSet)
|
|
{
|
|
payload.WithInteger("memoryReservation", m_memoryReservation);
|
|
|
|
}
|
|
|
|
if(m_resourceRequirementsHasBeenSet)
|
|
{
|
|
Array<JsonValue> resourceRequirementsJsonList(m_resourceRequirements.size());
|
|
for(unsigned resourceRequirementsIndex = 0; resourceRequirementsIndex < resourceRequirementsJsonList.GetLength(); ++resourceRequirementsIndex)
|
|
{
|
|
resourceRequirementsJsonList[resourceRequirementsIndex].AsObject(m_resourceRequirements[resourceRequirementsIndex].Jsonize());
|
|
}
|
|
payload.WithArray("resourceRequirements", std::move(resourceRequirementsJsonList));
|
|
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace ECS
|
|
} // namespace Aws
|