// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub use crate::operation::put_scaling_policy::_put_scaling_policy_input::PutScalingPolicyInputBuilder;
pub use crate::operation::put_scaling_policy::_put_scaling_policy_output::PutScalingPolicyOutputBuilder;
impl crate::operation::put_scaling_policy::builders::PutScalingPolicyInputBuilder {
/// Sends a request with this input using the given client.
pub async fn send_with(
self,
client: &crate::Client,
) -> ::std::result::Result<
crate::operation::put_scaling_policy::PutScalingPolicyOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::put_scaling_policy::PutScalingPolicyError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let mut fluent_builder = client.put_scaling_policy();
fluent_builder.inner = self;
fluent_builder.send().await
}
}
/// Fluent builder constructing a request to `PutScalingPolicy`.
///
/// <p><b>This API works with the following fleet types:</b> EC2</p>
/// <p>Creates or updates a scaling policy for a fleet. Scaling policies are used to automatically scale a fleet's hosting capacity to meet player demand. An active scaling policy instructs Amazon GameLift Servers to track a fleet metric and automatically change the fleet's capacity when a certain threshold is reached. There are two types of scaling policies: target-based and rule-based. Use a target-based policy to quickly and efficiently manage fleet scaling; this option is the most commonly used. Use rule-based policies when you need to exert fine-grained control over auto-scaling.</p>
/// <p>Fleets can have multiple scaling policies of each type in force at the same time; you can have one target-based policy, one or multiple rule-based scaling policies, or both. We recommend caution, however, because multiple auto-scaling policies can have unintended consequences.</p>
/// <p>Learn more about how to work with auto-scaling in <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/fleets-autoscaling.html">Set Up Fleet Automatic Scaling</a>.</p>
/// <p><b>Target-based policy</b></p>
/// <p>A target-based policy tracks a single metric: PercentAvailableGameSessions. This metric tells us how much of a fleet's hosting capacity is ready to host game sessions but is not currently in use. This is the fleet's buffer; it measures the additional player demand that the fleet could handle at current capacity. With a target-based policy, you set your ideal buffer size and leave it to Amazon GameLift Servers to take whatever action is needed to maintain that target.</p>
/// <p>For example, you might choose to maintain a 10% buffer for a fleet that has the capacity to host 100 simultaneous game sessions. This policy tells Amazon GameLift Servers to take action whenever the fleet's available capacity falls below or rises above 10 game sessions. Amazon GameLift Servers will start new instances or stop unused instances in order to return to the 10% buffer.</p>
/// <p>To create or update a target-based policy, specify a fleet ID and name, and set the policy type to "TargetBased". Specify the metric to track (PercentAvailableGameSessions) and reference a <code>TargetConfiguration</code> object with your desired buffer value. Exclude all other parameters. On a successful request, the policy name is returned. The scaling policy is automatically in force as soon as it's successfully created. If the fleet's auto-scaling actions are temporarily suspended, the new policy will be in force once the fleet actions are restarted.</p>
/// <p><b>Rule-based policy</b></p>
/// <p>A rule-based policy tracks specified fleet metric, sets a threshold value, and specifies the type of action to initiate when triggered. With a rule-based policy, you can select from several available fleet metrics. Each policy specifies whether to scale up or scale down (and by how much), so you need one policy for each type of action.</p>
/// <p>For example, a policy may make the following statement: "If the percentage of idle instances is greater than 20% for more than 15 minutes, then reduce the fleet capacity by 10%."</p>
/// <p>A policy's rule statement has the following structure:</p>
/// <p>If <code>\[MetricName\]</code> is <code>\[ComparisonOperator\]</code> <code>\[Threshold\]</code> for <code>\[EvaluationPeriods\]</code> minutes, then <code>\[ScalingAdjustmentType\]</code> to/by <code>\[ScalingAdjustment\]</code>.</p>
/// <p>To implement the example, the rule statement would look like this:</p>
/// <p>If <code>\[PercentIdleInstances\]</code> is <code>\[GreaterThanThreshold\]</code> <code>\[20\]</code> for <code>\[15\]</code> minutes, then <code>\[PercentChangeInCapacity\]</code> to/by <code>\[10\]</code>.</p>
/// <p>To create or update a scaling policy, specify a unique combination of name and fleet ID, and set the policy type to "RuleBased". Specify the parameter values for a policy rule statement. On a successful request, the policy name is returned. Scaling policies are automatically in force as soon as they're successfully created. If the fleet's auto-scaling actions are temporarily suspended, the new policy will be in force once the fleet actions are restarted.</p>
#[derive(::std::clone::Clone, ::std::fmt::Debug)]
pub struct PutScalingPolicyFluentBuilder {
handle: ::std::sync::Arc<crate::client::Handle>,
inner: crate::operation::put_scaling_policy::builders::PutScalingPolicyInputBuilder,
config_override: ::std::option::Option<crate::config::Builder>,
}
impl
crate::client::customize::internal::CustomizableSend<
crate::operation::put_scaling_policy::PutScalingPolicyOutput,
crate::operation::put_scaling_policy::PutScalingPolicyError,
> for PutScalingPolicyFluentBuilder
{
fn send(
self,
config_override: crate::config::Builder,
) -> crate::client::customize::internal::BoxFuture<
crate::client::customize::internal::SendResult<
crate::operation::put_scaling_policy::PutScalingPolicyOutput,
crate::operation::put_scaling_policy::PutScalingPolicyError,
>,
> {
::std::boxed::Box::pin(async move { self.config_override(config_override).send().await })
}
}
impl PutScalingPolicyFluentBuilder {
/// Creates a new `PutScalingPolicyFluentBuilder`.
pub(crate) fn new(handle: ::std::sync::Arc<crate::client::Handle>) -> Self {
Self {
handle,
inner: ::std::default::Default::default(),
config_override: ::std::option::Option::None,
}
}
/// Access the PutScalingPolicy as a reference.
pub fn as_input(&self) -> &crate::operation::put_scaling_policy::builders::PutScalingPolicyInputBuilder {
&self.inner
}
/// Sends the request and returns the response.
///
/// If an error occurs, an `SdkError` will be returned with additional details that
/// can be matched against.
///
/// By default, any retryable failures will be retried twice. Retry behavior
/// is configurable with the [RetryConfig](aws_smithy_types::retry::RetryConfig), which can be
/// set when configuring the client.
pub async fn send(
self,
) -> ::std::result::Result<
crate::operation::put_scaling_policy::PutScalingPolicyOutput,
::aws_smithy_runtime_api::client::result::SdkError<
crate::operation::put_scaling_policy::PutScalingPolicyError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
> {
let input = self
.inner
.build()
.map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)?;
let runtime_plugins = crate::operation::put_scaling_policy::PutScalingPolicy::operation_runtime_plugins(
self.handle.runtime_plugins.clone(),
&self.handle.conf,
self.config_override,
);
crate::operation::put_scaling_policy::PutScalingPolicy::orchestrate(&runtime_plugins, input).await
}
/// Consumes this builder, creating a customizable operation that can be modified before being sent.
pub fn customize(
self,
) -> crate::client::customize::CustomizableOperation<
crate::operation::put_scaling_policy::PutScalingPolicyOutput,
crate::operation::put_scaling_policy::PutScalingPolicyError,
Self,
> {
crate::client::customize::CustomizableOperation::new(self)
}
pub(crate) fn config_override(mut self, config_override: impl ::std::convert::Into<crate::config::Builder>) -> Self {
self.set_config_override(::std::option::Option::Some(config_override.into()));
self
}
pub(crate) fn set_config_override(&mut self, config_override: ::std::option::Option<crate::config::Builder>) -> &mut Self {
self.config_override = config_override;
self
}
/// <p>A descriptive label that is associated with a fleet's scaling policy. Policy names do not need to be unique. A fleet can have only one scaling policy with the same name.</p>
pub fn name(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.name(input.into());
self
}
/// <p>A descriptive label that is associated with a fleet's scaling policy. Policy names do not need to be unique. A fleet can have only one scaling policy with the same name.</p>
pub fn set_name(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_name(input);
self
}
/// <p>A descriptive label that is associated with a fleet's scaling policy. Policy names do not need to be unique. A fleet can have only one scaling policy with the same name.</p>
pub fn get_name(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_name()
}
/// <p>A unique identifier for the fleet to apply this policy to. You can use either the fleet ID or ARN value. The fleet cannot be in any of the following statuses: ERROR or DELETING.</p>
pub fn fleet_id(mut self, input: impl ::std::convert::Into<::std::string::String>) -> Self {
self.inner = self.inner.fleet_id(input.into());
self
}
/// <p>A unique identifier for the fleet to apply this policy to. You can use either the fleet ID or ARN value. The fleet cannot be in any of the following statuses: ERROR or DELETING.</p>
pub fn set_fleet_id(mut self, input: ::std::option::Option<::std::string::String>) -> Self {
self.inner = self.inner.set_fleet_id(input);
self
}
/// <p>A unique identifier for the fleet to apply this policy to. You can use either the fleet ID or ARN value. The fleet cannot be in any of the following statuses: ERROR or DELETING.</p>
pub fn get_fleet_id(&self) -> &::std::option::Option<::std::string::String> {
self.inner.get_fleet_id()
}
/// <p>Amount of adjustment to make, based on the scaling adjustment type.</p>
pub fn scaling_adjustment(mut self, input: i32) -> Self {
self.inner = self.inner.scaling_adjustment(input);
self
}
/// <p>Amount of adjustment to make, based on the scaling adjustment type.</p>
pub fn set_scaling_adjustment(mut self, input: ::std::option::Option<i32>) -> Self {
self.inner = self.inner.set_scaling_adjustment(input);
self
}
/// <p>Amount of adjustment to make, based on the scaling adjustment type.</p>
pub fn get_scaling_adjustment(&self) -> &::std::option::Option<i32> {
self.inner.get_scaling_adjustment()
}
/// <p>The type of adjustment to make to a fleet's instance count:</p>
/// <ul>
/// <li>
/// <p><b>ChangeInCapacity</b> -- add (or subtract) the scaling adjustment value from the current instance count. Positive values scale up while negative values scale down.</p></li>
/// <li>
/// <p><b>ExactCapacity</b> -- set the instance count to the scaling adjustment value.</p></li>
/// <li>
/// <p><b>PercentChangeInCapacity</b> -- increase or reduce the current instance count by the scaling adjustment, read as a percentage. Positive values scale up while negative values scale down; for example, a value of "-10" scales the fleet down by 10%.</p></li>
/// </ul>
pub fn scaling_adjustment_type(mut self, input: crate::types::ScalingAdjustmentType) -> Self {
self.inner = self.inner.scaling_adjustment_type(input);
self
}
/// <p>The type of adjustment to make to a fleet's instance count:</p>
/// <ul>
/// <li>
/// <p><b>ChangeInCapacity</b> -- add (or subtract) the scaling adjustment value from the current instance count. Positive values scale up while negative values scale down.</p></li>
/// <li>
/// <p><b>ExactCapacity</b> -- set the instance count to the scaling adjustment value.</p></li>
/// <li>
/// <p><b>PercentChangeInCapacity</b> -- increase or reduce the current instance count by the scaling adjustment, read as a percentage. Positive values scale up while negative values scale down; for example, a value of "-10" scales the fleet down by 10%.</p></li>
/// </ul>
pub fn set_scaling_adjustment_type(mut self, input: ::std::option::Option<crate::types::ScalingAdjustmentType>) -> Self {
self.inner = self.inner.set_scaling_adjustment_type(input);
self
}
/// <p>The type of adjustment to make to a fleet's instance count:</p>
/// <ul>
/// <li>
/// <p><b>ChangeInCapacity</b> -- add (or subtract) the scaling adjustment value from the current instance count. Positive values scale up while negative values scale down.</p></li>
/// <li>
/// <p><b>ExactCapacity</b> -- set the instance count to the scaling adjustment value.</p></li>
/// <li>
/// <p><b>PercentChangeInCapacity</b> -- increase or reduce the current instance count by the scaling adjustment, read as a percentage. Positive values scale up while negative values scale down; for example, a value of "-10" scales the fleet down by 10%.</p></li>
/// </ul>
pub fn get_scaling_adjustment_type(&self) -> &::std::option::Option<crate::types::ScalingAdjustmentType> {
self.inner.get_scaling_adjustment_type()
}
/// <p>Metric value used to trigger a scaling event.</p>
pub fn threshold(mut self, input: f64) -> Self {
self.inner = self.inner.threshold(input);
self
}
/// <p>Metric value used to trigger a scaling event.</p>
pub fn set_threshold(mut self, input: ::std::option::Option<f64>) -> Self {
self.inner = self.inner.set_threshold(input);
self
}
/// <p>Metric value used to trigger a scaling event.</p>
pub fn get_threshold(&self) -> &::std::option::Option<f64> {
self.inner.get_threshold()
}
/// <p>Comparison operator to use when measuring the metric against the threshold value.</p>
pub fn comparison_operator(mut self, input: crate::types::ComparisonOperatorType) -> Self {
self.inner = self.inner.comparison_operator(input);
self
}
/// <p>Comparison operator to use when measuring the metric against the threshold value.</p>
pub fn set_comparison_operator(mut self, input: ::std::option::Option<crate::types::ComparisonOperatorType>) -> Self {
self.inner = self.inner.set_comparison_operator(input);
self
}
/// <p>Comparison operator to use when measuring the metric against the threshold value.</p>
pub fn get_comparison_operator(&self) -> &::std::option::Option<crate::types::ComparisonOperatorType> {
self.inner.get_comparison_operator()
}
/// <p>Length of time (in minutes) the metric must be at or beyond the threshold before a scaling event is triggered.</p>
pub fn evaluation_periods(mut self, input: i32) -> Self {
self.inner = self.inner.evaluation_periods(input);
self
}
/// <p>Length of time (in minutes) the metric must be at or beyond the threshold before a scaling event is triggered.</p>
pub fn set_evaluation_periods(mut self, input: ::std::option::Option<i32>) -> Self {
self.inner = self.inner.set_evaluation_periods(input);
self
}
/// <p>Length of time (in minutes) the metric must be at or beyond the threshold before a scaling event is triggered.</p>
pub fn get_evaluation_periods(&self) -> &::std::option::Option<i32> {
self.inner.get_evaluation_periods()
}
/// <p>Name of the Amazon GameLift Servers-defined metric that is used to trigger a scaling adjustment. For detailed descriptions of fleet metrics, see <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html">Monitor Amazon GameLift Servers with Amazon CloudWatch</a>.</p>
/// <ul>
/// <li>
/// <p><b>ActivatingGameSessions</b> -- Game sessions in the process of being created.</p></li>
/// <li>
/// <p><b>ActiveGameSessions</b> -- Game sessions that are currently running.</p></li>
/// <li>
/// <p><b>ActiveInstances</b> -- Fleet instances that are currently running at least one game session.</p></li>
/// <li>
/// <p><b>AvailableGameSessions</b> -- Additional game sessions that fleet could host simultaneously, given current capacity.</p></li>
/// <li>
/// <p><b>AvailablePlayerSessions</b> -- Empty player slots in currently active game sessions. This includes game sessions that are not currently accepting players. Reserved player slots are not included.</p></li>
/// <li>
/// <p><b>CurrentPlayerSessions</b> -- Player slots in active game sessions that are being used by a player or are reserved for a player.</p></li>
/// <li>
/// <p><b>IdleInstances</b> -- Active instances that are currently hosting zero game sessions.</p></li>
/// <li>
/// <p><b>PercentAvailableGameSessions</b> -- Unused percentage of the total number of game sessions that a fleet could host simultaneously, given current capacity. Use this metric for a target-based scaling policy.</p></li>
/// <li>
/// <p><b>PercentIdleInstances</b> -- Percentage of the total number of active instances that are hosting zero game sessions.</p></li>
/// <li>
/// <p><b>QueueDepth</b> -- Pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// <li>
/// <p><b>WaitTime</b> -- Current wait time for pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// </ul>
pub fn metric_name(mut self, input: crate::types::MetricName) -> Self {
self.inner = self.inner.metric_name(input);
self
}
/// <p>Name of the Amazon GameLift Servers-defined metric that is used to trigger a scaling adjustment. For detailed descriptions of fleet metrics, see <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html">Monitor Amazon GameLift Servers with Amazon CloudWatch</a>.</p>
/// <ul>
/// <li>
/// <p><b>ActivatingGameSessions</b> -- Game sessions in the process of being created.</p></li>
/// <li>
/// <p><b>ActiveGameSessions</b> -- Game sessions that are currently running.</p></li>
/// <li>
/// <p><b>ActiveInstances</b> -- Fleet instances that are currently running at least one game session.</p></li>
/// <li>
/// <p><b>AvailableGameSessions</b> -- Additional game sessions that fleet could host simultaneously, given current capacity.</p></li>
/// <li>
/// <p><b>AvailablePlayerSessions</b> -- Empty player slots in currently active game sessions. This includes game sessions that are not currently accepting players. Reserved player slots are not included.</p></li>
/// <li>
/// <p><b>CurrentPlayerSessions</b> -- Player slots in active game sessions that are being used by a player or are reserved for a player.</p></li>
/// <li>
/// <p><b>IdleInstances</b> -- Active instances that are currently hosting zero game sessions.</p></li>
/// <li>
/// <p><b>PercentAvailableGameSessions</b> -- Unused percentage of the total number of game sessions that a fleet could host simultaneously, given current capacity. Use this metric for a target-based scaling policy.</p></li>
/// <li>
/// <p><b>PercentIdleInstances</b> -- Percentage of the total number of active instances that are hosting zero game sessions.</p></li>
/// <li>
/// <p><b>QueueDepth</b> -- Pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// <li>
/// <p><b>WaitTime</b> -- Current wait time for pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// </ul>
pub fn set_metric_name(mut self, input: ::std::option::Option<crate::types::MetricName>) -> Self {
self.inner = self.inner.set_metric_name(input);
self
}
/// <p>Name of the Amazon GameLift Servers-defined metric that is used to trigger a scaling adjustment. For detailed descriptions of fleet metrics, see <a href="https://docs.aws.amazon.com/gamelift/latest/developerguide/monitoring-cloudwatch.html">Monitor Amazon GameLift Servers with Amazon CloudWatch</a>.</p>
/// <ul>
/// <li>
/// <p><b>ActivatingGameSessions</b> -- Game sessions in the process of being created.</p></li>
/// <li>
/// <p><b>ActiveGameSessions</b> -- Game sessions that are currently running.</p></li>
/// <li>
/// <p><b>ActiveInstances</b> -- Fleet instances that are currently running at least one game session.</p></li>
/// <li>
/// <p><b>AvailableGameSessions</b> -- Additional game sessions that fleet could host simultaneously, given current capacity.</p></li>
/// <li>
/// <p><b>AvailablePlayerSessions</b> -- Empty player slots in currently active game sessions. This includes game sessions that are not currently accepting players. Reserved player slots are not included.</p></li>
/// <li>
/// <p><b>CurrentPlayerSessions</b> -- Player slots in active game sessions that are being used by a player or are reserved for a player.</p></li>
/// <li>
/// <p><b>IdleInstances</b> -- Active instances that are currently hosting zero game sessions.</p></li>
/// <li>
/// <p><b>PercentAvailableGameSessions</b> -- Unused percentage of the total number of game sessions that a fleet could host simultaneously, given current capacity. Use this metric for a target-based scaling policy.</p></li>
/// <li>
/// <p><b>PercentIdleInstances</b> -- Percentage of the total number of active instances that are hosting zero game sessions.</p></li>
/// <li>
/// <p><b>QueueDepth</b> -- Pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// <li>
/// <p><b>WaitTime</b> -- Current wait time for pending game session placement requests, in any queue, where the current fleet is the top-priority destination.</p></li>
/// </ul>
pub fn get_metric_name(&self) -> &::std::option::Option<crate::types::MetricName> {
self.inner.get_metric_name()
}
/// <p>The type of scaling policy to create. For a target-based policy, set the parameter <i>MetricName</i> to 'PercentAvailableGameSessions' and specify a <i>TargetConfiguration</i>. For a rule-based policy set the following parameters: <i>MetricName</i>, <i>ComparisonOperator</i>, <i>Threshold</i>, <i>EvaluationPeriods</i>, <i>ScalingAdjustmentType</i>, and <i>ScalingAdjustment</i>.</p>
pub fn policy_type(mut self, input: crate::types::PolicyType) -> Self {
self.inner = self.inner.policy_type(input);
self
}
/// <p>The type of scaling policy to create. For a target-based policy, set the parameter <i>MetricName</i> to 'PercentAvailableGameSessions' and specify a <i>TargetConfiguration</i>. For a rule-based policy set the following parameters: <i>MetricName</i>, <i>ComparisonOperator</i>, <i>Threshold</i>, <i>EvaluationPeriods</i>, <i>ScalingAdjustmentType</i>, and <i>ScalingAdjustment</i>.</p>
pub fn set_policy_type(mut self, input: ::std::option::Option<crate::types::PolicyType>) -> Self {
self.inner = self.inner.set_policy_type(input);
self
}
/// <p>The type of scaling policy to create. For a target-based policy, set the parameter <i>MetricName</i> to 'PercentAvailableGameSessions' and specify a <i>TargetConfiguration</i>. For a rule-based policy set the following parameters: <i>MetricName</i>, <i>ComparisonOperator</i>, <i>Threshold</i>, <i>EvaluationPeriods</i>, <i>ScalingAdjustmentType</i>, and <i>ScalingAdjustment</i>.</p>
pub fn get_policy_type(&self) -> &::std::option::Option<crate::types::PolicyType> {
self.inner.get_policy_type()
}
/// <p>An object that contains settings for a target-based scaling policy.</p>
pub fn target_configuration(mut self, input: crate::types::TargetConfiguration) -> Self {
self.inner = self.inner.target_configuration(input);
self
}
/// <p>An object that contains settings for a target-based scaling policy.</p>
pub fn set_target_configuration(mut self, input: ::std::option::Option<crate::types::TargetConfiguration>) -> Self {
self.inner = self.inner.set_target_configuration(input);
self
}
/// <p>An object that contains settings for a target-based scaling policy.</p>
pub fn get_target_configuration(&self) -> &::std::option::Option<crate::types::TargetConfiguration> {
self.inner.get_target_configuration()
}
}