203 lines
4.9 KiB
C++
203 lines
4.9 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/lightsail/model/InstancePortInfo.h>
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|
|
|
#include <utility>
|
|
|
|
using namespace Aws::Utils::Json;
|
|
using namespace Aws::Utils;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace Lightsail
|
|
{
|
|
namespace Model
|
|
{
|
|
|
|
InstancePortInfo::InstancePortInfo() :
|
|
m_fromPort(0),
|
|
m_fromPortHasBeenSet(false),
|
|
m_toPort(0),
|
|
m_toPortHasBeenSet(false),
|
|
m_protocol(NetworkProtocol::NOT_SET),
|
|
m_protocolHasBeenSet(false),
|
|
m_accessFromHasBeenSet(false),
|
|
m_accessType(PortAccessType::NOT_SET),
|
|
m_accessTypeHasBeenSet(false),
|
|
m_commonNameHasBeenSet(false),
|
|
m_accessDirection(AccessDirection::NOT_SET),
|
|
m_accessDirectionHasBeenSet(false),
|
|
m_cidrsHasBeenSet(false),
|
|
m_cidrListAliasesHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
InstancePortInfo::InstancePortInfo(JsonView jsonValue) :
|
|
m_fromPort(0),
|
|
m_fromPortHasBeenSet(false),
|
|
m_toPort(0),
|
|
m_toPortHasBeenSet(false),
|
|
m_protocol(NetworkProtocol::NOT_SET),
|
|
m_protocolHasBeenSet(false),
|
|
m_accessFromHasBeenSet(false),
|
|
m_accessType(PortAccessType::NOT_SET),
|
|
m_accessTypeHasBeenSet(false),
|
|
m_commonNameHasBeenSet(false),
|
|
m_accessDirection(AccessDirection::NOT_SET),
|
|
m_accessDirectionHasBeenSet(false),
|
|
m_cidrsHasBeenSet(false),
|
|
m_cidrListAliasesHasBeenSet(false)
|
|
{
|
|
*this = jsonValue;
|
|
}
|
|
|
|
InstancePortInfo& InstancePortInfo::operator =(JsonView jsonValue)
|
|
{
|
|
if(jsonValue.ValueExists("fromPort"))
|
|
{
|
|
m_fromPort = jsonValue.GetInteger("fromPort");
|
|
|
|
m_fromPortHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("toPort"))
|
|
{
|
|
m_toPort = jsonValue.GetInteger("toPort");
|
|
|
|
m_toPortHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("protocol"))
|
|
{
|
|
m_protocol = NetworkProtocolMapper::GetNetworkProtocolForName(jsonValue.GetString("protocol"));
|
|
|
|
m_protocolHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("accessFrom"))
|
|
{
|
|
m_accessFrom = jsonValue.GetString("accessFrom");
|
|
|
|
m_accessFromHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("accessType"))
|
|
{
|
|
m_accessType = PortAccessTypeMapper::GetPortAccessTypeForName(jsonValue.GetString("accessType"));
|
|
|
|
m_accessTypeHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("commonName"))
|
|
{
|
|
m_commonName = jsonValue.GetString("commonName");
|
|
|
|
m_commonNameHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("accessDirection"))
|
|
{
|
|
m_accessDirection = AccessDirectionMapper::GetAccessDirectionForName(jsonValue.GetString("accessDirection"));
|
|
|
|
m_accessDirectionHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("cidrs"))
|
|
{
|
|
Array<JsonView> cidrsJsonList = jsonValue.GetArray("cidrs");
|
|
for(unsigned cidrsIndex = 0; cidrsIndex < cidrsJsonList.GetLength(); ++cidrsIndex)
|
|
{
|
|
m_cidrs.push_back(cidrsJsonList[cidrsIndex].AsString());
|
|
}
|
|
m_cidrsHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("cidrListAliases"))
|
|
{
|
|
Array<JsonView> cidrListAliasesJsonList = jsonValue.GetArray("cidrListAliases");
|
|
for(unsigned cidrListAliasesIndex = 0; cidrListAliasesIndex < cidrListAliasesJsonList.GetLength(); ++cidrListAliasesIndex)
|
|
{
|
|
m_cidrListAliases.push_back(cidrListAliasesJsonList[cidrListAliasesIndex].AsString());
|
|
}
|
|
m_cidrListAliasesHasBeenSet = true;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
JsonValue InstancePortInfo::Jsonize() const
|
|
{
|
|
JsonValue payload;
|
|
|
|
if(m_fromPortHasBeenSet)
|
|
{
|
|
payload.WithInteger("fromPort", m_fromPort);
|
|
|
|
}
|
|
|
|
if(m_toPortHasBeenSet)
|
|
{
|
|
payload.WithInteger("toPort", m_toPort);
|
|
|
|
}
|
|
|
|
if(m_protocolHasBeenSet)
|
|
{
|
|
payload.WithString("protocol", NetworkProtocolMapper::GetNameForNetworkProtocol(m_protocol));
|
|
}
|
|
|
|
if(m_accessFromHasBeenSet)
|
|
{
|
|
payload.WithString("accessFrom", m_accessFrom);
|
|
|
|
}
|
|
|
|
if(m_accessTypeHasBeenSet)
|
|
{
|
|
payload.WithString("accessType", PortAccessTypeMapper::GetNameForPortAccessType(m_accessType));
|
|
}
|
|
|
|
if(m_commonNameHasBeenSet)
|
|
{
|
|
payload.WithString("commonName", m_commonName);
|
|
|
|
}
|
|
|
|
if(m_accessDirectionHasBeenSet)
|
|
{
|
|
payload.WithString("accessDirection", AccessDirectionMapper::GetNameForAccessDirection(m_accessDirection));
|
|
}
|
|
|
|
if(m_cidrsHasBeenSet)
|
|
{
|
|
Array<JsonValue> cidrsJsonList(m_cidrs.size());
|
|
for(unsigned cidrsIndex = 0; cidrsIndex < cidrsJsonList.GetLength(); ++cidrsIndex)
|
|
{
|
|
cidrsJsonList[cidrsIndex].AsString(m_cidrs[cidrsIndex]);
|
|
}
|
|
payload.WithArray("cidrs", std::move(cidrsJsonList));
|
|
|
|
}
|
|
|
|
if(m_cidrListAliasesHasBeenSet)
|
|
{
|
|
Array<JsonValue> cidrListAliasesJsonList(m_cidrListAliases.size());
|
|
for(unsigned cidrListAliasesIndex = 0; cidrListAliasesIndex < cidrListAliasesJsonList.GetLength(); ++cidrListAliasesIndex)
|
|
{
|
|
cidrListAliasesJsonList[cidrListAliasesIndex].AsString(m_cidrListAliases[cidrListAliasesIndex]);
|
|
}
|
|
payload.WithArray("cidrListAliases", std::move(cidrListAliasesJsonList));
|
|
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace Lightsail
|
|
} // namespace Aws
|