software.amazon.awscdk.services.gamelift.alpha.ResourceCreationLimitPolicy Maven / Gradle / Ivy
Show all versions of gamelift-alpha Show documentation
package software.amazon.awscdk.services.gamelift.alpha;
/**
* (experimental) A policy that limits the number of game sessions a player can create on the same fleet.
*
* This optional policy gives game owners control over how players can consume available game server resources.
* A resource creation policy makes the following statement: "An individual player can create a maximum number of new game sessions within a specified time period".
*
* The policy is evaluated when a player tries to create a new game session.
* For example, assume you have a policy of 10 new game sessions and a time period of 60 minutes.
* On receiving a CreateGameSession
request, Amazon GameLift checks that the player (identified by CreatorId) has created fewer than 10 game sessions in the past 60 minutes.
*
* Example:
*
*
* // The code below shows an example of how to instantiate this type.
* // The values are placeholders you should change.
* import software.amazon.awscdk.services.gamelift.alpha.*;
* import software.amazon.awscdk.*;
* ResourceCreationLimitPolicy resourceCreationLimitPolicy = ResourceCreationLimitPolicy.builder()
* .newGameSessionsPerCreator(123)
* .policyPeriod(Duration.minutes(30))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.104.0 (build e79254c)", date = "2024-12-27T17:02:12.140Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.gamelift.alpha.$Module.class, fqn = "@aws-cdk/aws-gamelift-alpha.ResourceCreationLimitPolicy")
@software.amazon.jsii.Jsii.Proxy(ResourceCreationLimitPolicy.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface ResourceCreationLimitPolicy extends software.amazon.jsii.JsiiSerializable {
/**
* (experimental) The maximum number of game sessions that an individual can create during the policy period.
*
* Default: no limit on the number of game sessions that an individual can create during the policy period
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable java.lang.Number getNewGameSessionsPerCreator() {
return null;
}
/**
* (experimental) The time span used in evaluating the resource creation limit policy.
*
* Default: no policy period
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
default @org.jetbrains.annotations.Nullable software.amazon.awscdk.Duration getPolicyPeriod() {
return null;
}
/**
* @return a {@link Builder} of {@link ResourceCreationLimitPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link ResourceCreationLimitPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.Number newGameSessionsPerCreator;
software.amazon.awscdk.Duration policyPeriod;
/**
* Sets the value of {@link ResourceCreationLimitPolicy#getNewGameSessionsPerCreator}
* @param newGameSessionsPerCreator The maximum number of game sessions that an individual can create during the policy period.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder newGameSessionsPerCreator(java.lang.Number newGameSessionsPerCreator) {
this.newGameSessionsPerCreator = newGameSessionsPerCreator;
return this;
}
/**
* Sets the value of {@link ResourceCreationLimitPolicy#getPolicyPeriod}
* @param policyPeriod The time span used in evaluating the resource creation limit policy.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public Builder policyPeriod(software.amazon.awscdk.Duration policyPeriod) {
this.policyPeriod = policyPeriod;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link ResourceCreationLimitPolicy}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@Override
public ResourceCreationLimitPolicy build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link ResourceCreationLimitPolicy}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements ResourceCreationLimitPolicy {
private final java.lang.Number newGameSessionsPerCreator;
private final software.amazon.awscdk.Duration policyPeriod;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.newGameSessionsPerCreator = software.amazon.jsii.Kernel.get(this, "newGameSessionsPerCreator", software.amazon.jsii.NativeType.forClass(java.lang.Number.class));
this.policyPeriod = software.amazon.jsii.Kernel.get(this, "policyPeriod", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.Duration.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.newGameSessionsPerCreator = builder.newGameSessionsPerCreator;
this.policyPeriod = builder.policyPeriod;
}
@Override
public final java.lang.Number getNewGameSessionsPerCreator() {
return this.newGameSessionsPerCreator;
}
@Override
public final software.amazon.awscdk.Duration getPolicyPeriod() {
return this.policyPeriod;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getNewGameSessionsPerCreator() != null) {
data.set("newGameSessionsPerCreator", om.valueToTree(this.getNewGameSessionsPerCreator()));
}
if (this.getPolicyPeriod() != null) {
data.set("policyPeriod", om.valueToTree(this.getPolicyPeriod()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-gamelift-alpha.ResourceCreationLimitPolicy"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ResourceCreationLimitPolicy.Jsii$Proxy that = (ResourceCreationLimitPolicy.Jsii$Proxy) o;
if (this.newGameSessionsPerCreator != null ? !this.newGameSessionsPerCreator.equals(that.newGameSessionsPerCreator) : that.newGameSessionsPerCreator != null) return false;
return this.policyPeriod != null ? this.policyPeriod.equals(that.policyPeriod) : that.policyPeriod == null;
}
@Override
public final int hashCode() {
int result = this.newGameSessionsPerCreator != null ? this.newGameSessionsPerCreator.hashCode() : 0;
result = 31 * result + (this.policyPeriod != null ? this.policyPeriod.hashCode() : 0);
return result;
}
}
}