128 lines
2.3 KiB
C++
128 lines
2.3 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/mobile/model/Resource.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
|
|
{
|
|
|
|
Resource::Resource() :
|
|
m_typeHasBeenSet(false),
|
|
m_nameHasBeenSet(false),
|
|
m_arnHasBeenSet(false),
|
|
m_featureHasBeenSet(false),
|
|
m_attributesHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
Resource::Resource(JsonView jsonValue) :
|
|
m_typeHasBeenSet(false),
|
|
m_nameHasBeenSet(false),
|
|
m_arnHasBeenSet(false),
|
|
m_featureHasBeenSet(false),
|
|
m_attributesHasBeenSet(false)
|
|
{
|
|
*this = jsonValue;
|
|
}
|
|
|
|
Resource& Resource::operator =(JsonView jsonValue)
|
|
{
|
|
if(jsonValue.ValueExists("type"))
|
|
{
|
|
m_type = jsonValue.GetString("type");
|
|
|
|
m_typeHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("name"))
|
|
{
|
|
m_name = jsonValue.GetString("name");
|
|
|
|
m_nameHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("arn"))
|
|
{
|
|
m_arn = jsonValue.GetString("arn");
|
|
|
|
m_arnHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("feature"))
|
|
{
|
|
m_feature = jsonValue.GetString("feature");
|
|
|
|
m_featureHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("attributes"))
|
|
{
|
|
Aws::Map<Aws::String, JsonView> attributesJsonMap = jsonValue.GetObject("attributes").GetAllObjects();
|
|
for(auto& attributesItem : attributesJsonMap)
|
|
{
|
|
m_attributes[attributesItem.first] = attributesItem.second.AsString();
|
|
}
|
|
m_attributesHasBeenSet = true;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
JsonValue Resource::Jsonize() const
|
|
{
|
|
JsonValue payload;
|
|
|
|
if(m_typeHasBeenSet)
|
|
{
|
|
payload.WithString("type", m_type);
|
|
|
|
}
|
|
|
|
if(m_nameHasBeenSet)
|
|
{
|
|
payload.WithString("name", m_name);
|
|
|
|
}
|
|
|
|
if(m_arnHasBeenSet)
|
|
{
|
|
payload.WithString("arn", m_arn);
|
|
|
|
}
|
|
|
|
if(m_featureHasBeenSet)
|
|
{
|
|
payload.WithString("feature", m_feature);
|
|
|
|
}
|
|
|
|
if(m_attributesHasBeenSet)
|
|
{
|
|
JsonValue attributesJsonMap;
|
|
for(auto& attributesItem : m_attributes)
|
|
{
|
|
attributesJsonMap.WithString(attributesItem.first, attributesItem.second);
|
|
}
|
|
payload.WithObject("attributes", std::move(attributesJsonMap));
|
|
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace Mobile
|
|
} // namespace Aws
|