205 lines
5.2 KiB
C++
205 lines
5.2 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/application-autoscaling/model/ScalingPolicy.h>
|
|
#include <aws/core/utils/json/JsonSerializer.h>
|
|
|
|
#include <utility>
|
|
|
|
using namespace Aws::Utils::Json;
|
|
using namespace Aws::Utils;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace ApplicationAutoScaling
|
|
{
|
|
namespace Model
|
|
{
|
|
|
|
ScalingPolicy::ScalingPolicy() :
|
|
m_policyARNHasBeenSet(false),
|
|
m_policyNameHasBeenSet(false),
|
|
m_serviceNamespace(ServiceNamespace::NOT_SET),
|
|
m_serviceNamespaceHasBeenSet(false),
|
|
m_resourceIdHasBeenSet(false),
|
|
m_scalableDimension(ScalableDimension::NOT_SET),
|
|
m_scalableDimensionHasBeenSet(false),
|
|
m_policyType(PolicyType::NOT_SET),
|
|
m_policyTypeHasBeenSet(false),
|
|
m_stepScalingPolicyConfigurationHasBeenSet(false),
|
|
m_targetTrackingScalingPolicyConfigurationHasBeenSet(false),
|
|
m_alarmsHasBeenSet(false),
|
|
m_creationTimeHasBeenSet(false)
|
|
{
|
|
}
|
|
|
|
ScalingPolicy::ScalingPolicy(JsonView jsonValue) :
|
|
m_policyARNHasBeenSet(false),
|
|
m_policyNameHasBeenSet(false),
|
|
m_serviceNamespace(ServiceNamespace::NOT_SET),
|
|
m_serviceNamespaceHasBeenSet(false),
|
|
m_resourceIdHasBeenSet(false),
|
|
m_scalableDimension(ScalableDimension::NOT_SET),
|
|
m_scalableDimensionHasBeenSet(false),
|
|
m_policyType(PolicyType::NOT_SET),
|
|
m_policyTypeHasBeenSet(false),
|
|
m_stepScalingPolicyConfigurationHasBeenSet(false),
|
|
m_targetTrackingScalingPolicyConfigurationHasBeenSet(false),
|
|
m_alarmsHasBeenSet(false),
|
|
m_creationTimeHasBeenSet(false)
|
|
{
|
|
*this = jsonValue;
|
|
}
|
|
|
|
ScalingPolicy& ScalingPolicy::operator =(JsonView jsonValue)
|
|
{
|
|
if(jsonValue.ValueExists("PolicyARN"))
|
|
{
|
|
m_policyARN = jsonValue.GetString("PolicyARN");
|
|
|
|
m_policyARNHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("PolicyName"))
|
|
{
|
|
m_policyName = jsonValue.GetString("PolicyName");
|
|
|
|
m_policyNameHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("ServiceNamespace"))
|
|
{
|
|
m_serviceNamespace = ServiceNamespaceMapper::GetServiceNamespaceForName(jsonValue.GetString("ServiceNamespace"));
|
|
|
|
m_serviceNamespaceHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("ResourceId"))
|
|
{
|
|
m_resourceId = jsonValue.GetString("ResourceId");
|
|
|
|
m_resourceIdHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("ScalableDimension"))
|
|
{
|
|
m_scalableDimension = ScalableDimensionMapper::GetScalableDimensionForName(jsonValue.GetString("ScalableDimension"));
|
|
|
|
m_scalableDimensionHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("PolicyType"))
|
|
{
|
|
m_policyType = PolicyTypeMapper::GetPolicyTypeForName(jsonValue.GetString("PolicyType"));
|
|
|
|
m_policyTypeHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("StepScalingPolicyConfiguration"))
|
|
{
|
|
m_stepScalingPolicyConfiguration = jsonValue.GetObject("StepScalingPolicyConfiguration");
|
|
|
|
m_stepScalingPolicyConfigurationHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("TargetTrackingScalingPolicyConfiguration"))
|
|
{
|
|
m_targetTrackingScalingPolicyConfiguration = jsonValue.GetObject("TargetTrackingScalingPolicyConfiguration");
|
|
|
|
m_targetTrackingScalingPolicyConfigurationHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("Alarms"))
|
|
{
|
|
Array<JsonView> alarmsJsonList = jsonValue.GetArray("Alarms");
|
|
for(unsigned alarmsIndex = 0; alarmsIndex < alarmsJsonList.GetLength(); ++alarmsIndex)
|
|
{
|
|
m_alarms.push_back(alarmsJsonList[alarmsIndex].AsObject());
|
|
}
|
|
m_alarmsHasBeenSet = true;
|
|
}
|
|
|
|
if(jsonValue.ValueExists("CreationTime"))
|
|
{
|
|
m_creationTime = jsonValue.GetDouble("CreationTime");
|
|
|
|
m_creationTimeHasBeenSet = true;
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
JsonValue ScalingPolicy::Jsonize() const
|
|
{
|
|
JsonValue payload;
|
|
|
|
if(m_policyARNHasBeenSet)
|
|
{
|
|
payload.WithString("PolicyARN", m_policyARN);
|
|
|
|
}
|
|
|
|
if(m_policyNameHasBeenSet)
|
|
{
|
|
payload.WithString("PolicyName", m_policyName);
|
|
|
|
}
|
|
|
|
if(m_serviceNamespaceHasBeenSet)
|
|
{
|
|
payload.WithString("ServiceNamespace", ServiceNamespaceMapper::GetNameForServiceNamespace(m_serviceNamespace));
|
|
}
|
|
|
|
if(m_resourceIdHasBeenSet)
|
|
{
|
|
payload.WithString("ResourceId", m_resourceId);
|
|
|
|
}
|
|
|
|
if(m_scalableDimensionHasBeenSet)
|
|
{
|
|
payload.WithString("ScalableDimension", ScalableDimensionMapper::GetNameForScalableDimension(m_scalableDimension));
|
|
}
|
|
|
|
if(m_policyTypeHasBeenSet)
|
|
{
|
|
payload.WithString("PolicyType", PolicyTypeMapper::GetNameForPolicyType(m_policyType));
|
|
}
|
|
|
|
if(m_stepScalingPolicyConfigurationHasBeenSet)
|
|
{
|
|
payload.WithObject("StepScalingPolicyConfiguration", m_stepScalingPolicyConfiguration.Jsonize());
|
|
|
|
}
|
|
|
|
if(m_targetTrackingScalingPolicyConfigurationHasBeenSet)
|
|
{
|
|
payload.WithObject("TargetTrackingScalingPolicyConfiguration", m_targetTrackingScalingPolicyConfiguration.Jsonize());
|
|
|
|
}
|
|
|
|
if(m_alarmsHasBeenSet)
|
|
{
|
|
Array<JsonValue> alarmsJsonList(m_alarms.size());
|
|
for(unsigned alarmsIndex = 0; alarmsIndex < alarmsJsonList.GetLength(); ++alarmsIndex)
|
|
{
|
|
alarmsJsonList[alarmsIndex].AsObject(m_alarms[alarmsIndex].Jsonize());
|
|
}
|
|
payload.WithArray("Alarms", std::move(alarmsJsonList));
|
|
|
|
}
|
|
|
|
if(m_creationTimeHasBeenSet)
|
|
{
|
|
payload.WithDouble("CreationTime", m_creationTime.SecondsWithMSPrecision());
|
|
}
|
|
|
|
return payload;
|
|
}
|
|
|
|
} // namespace Model
|
|
} // namespace ApplicationAutoScaling
|
|
} // namespace Aws
|