software.amazon.awssdk.services.apigateway.model.CreateUsagePlanRequest Maven / Gradle / Ivy
Show all versions of api-gateway Show documentation
/*
* Copyright 2013-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.apigateway.model;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import javax.annotation.Generated;
import software.amazon.awssdk.core.AwsRequestOverrideConfig;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The POST request to create a usage plan with the name, description, throttle limits and quota limits, as well as the
* associated API stages, specified in the payload.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class CreateUsagePlanRequest extends APIGatewayRequest implements
ToCopyableBuilder {
private final String name;
private final String description;
private final List apiStages;
private final ThrottleSettings throttle;
private final QuotaSettings quota;
private CreateUsagePlanRequest(BuilderImpl builder) {
super(builder);
this.name = builder.name;
this.description = builder.description;
this.apiStages = builder.apiStages;
this.throttle = builder.throttle;
this.quota = builder.quota;
}
/**
*
* The name of the usage plan.
*
*
* @return The name of the usage plan.
*/
public String name() {
return name;
}
/**
*
* The description of the usage plan.
*
*
* @return The description of the usage plan.
*/
public String description() {
return description;
}
/**
*
* The associated API stages of the usage plan.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The associated API stages of the usage plan.
*/
public List apiStages() {
return apiStages;
}
/**
*
* The throttling limits of the usage plan.
*
*
* @return The throttling limits of the usage plan.
*/
public ThrottleSettings throttle() {
return throttle;
}
/**
*
* The quota of the usage plan.
*
*
* @return The quota of the usage plan.
*/
public QuotaSettings quota() {
return quota;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(apiStages());
hashCode = 31 * hashCode + Objects.hashCode(throttle());
hashCode = 31 * hashCode + Objects.hashCode(quota());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateUsagePlanRequest)) {
return false;
}
CreateUsagePlanRequest other = (CreateUsagePlanRequest) obj;
return Objects.equals(name(), other.name()) && Objects.equals(description(), other.description())
&& Objects.equals(apiStages(), other.apiStages()) && Objects.equals(throttle(), other.throttle())
&& Objects.equals(quota(), other.quota());
}
@Override
public String toString() {
return ToString.builder("CreateUsagePlanRequest").add("Name", name()).add("Description", description())
.add("ApiStages", apiStages()).add("Throttle", throttle()).add("Quota", quota()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "name":
return Optional.of(clazz.cast(name()));
case "description":
return Optional.of(clazz.cast(description()));
case "apiStages":
return Optional.of(clazz.cast(apiStages()));
case "throttle":
return Optional.of(clazz.cast(throttle()));
case "quota":
return Optional.of(clazz.cast(quota()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayRequest.Builder, CopyableBuilder {
/**
*
* The name of the usage plan.
*
*
* @param name
* The name of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder name(String name);
/**
*
* The description of the usage plan.
*
*
* @param description
* The description of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* The associated API stages of the usage plan.
*
*
* @param apiStages
* The associated API stages of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder apiStages(Collection apiStages);
/**
*
* The associated API stages of the usage plan.
*
*
* @param apiStages
* The associated API stages of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder apiStages(ApiStage... apiStages);
/**
*
* The throttling limits of the usage plan.
*
*
* @param throttle
* The throttling limits of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder throttle(ThrottleSettings throttle);
/**
*
* The throttling limits of the usage plan.
*
* This is a convenience that creates an instance of the {@link ThrottleSettings.Builder} avoiding the need to
* create one manually via {@link ThrottleSettings#builder()}.
*
* When the {@link Consumer} completes, {@link ThrottleSettings.Builder#build()} is called immediately and its
* result is passed to {@link #throttle(ThrottleSettings)}.
*
* @param throttle
* a consumer that will call methods on {@link ThrottleSettings.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #throttle(ThrottleSettings)
*/
default Builder throttle(Consumer throttle) {
return throttle(ThrottleSettings.builder().apply(throttle).build());
}
/**
*
* The quota of the usage plan.
*
*
* @param quota
* The quota of the usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder quota(QuotaSettings quota);
/**
*
* The quota of the usage plan.
*
* This is a convenience that creates an instance of the {@link QuotaSettings.Builder} avoiding the need to
* create one manually via {@link QuotaSettings#builder()}.
*
* When the {@link Consumer} completes, {@link QuotaSettings.Builder#build()} is called immediately and its
* result is passed to {@link #quota(QuotaSettings)}.
*
* @param quota
* a consumer that will call methods on {@link QuotaSettings.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #quota(QuotaSettings)
*/
default Builder quota(Consumer quota) {
return quota(QuotaSettings.builder().apply(quota).build());
}
@Override
Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig);
}
static final class BuilderImpl extends APIGatewayRequest.BuilderImpl implements Builder {
private String name;
private String description;
private List apiStages;
private ThrottleSettings throttle;
private QuotaSettings quota;
private BuilderImpl() {
}
private BuilderImpl(CreateUsagePlanRequest model) {
name(model.name);
description(model.description);
apiStages(model.apiStages);
throttle(model.throttle);
quota(model.quota);
}
public final String getName() {
return name;
}
@Override
public final Builder name(String name) {
this.name = name;
return this;
}
public final void setName(String name) {
this.name = name;
}
public final String getDescription() {
return description;
}
@Override
public final Builder description(String description) {
this.description = description;
return this;
}
public final void setDescription(String description) {
this.description = description;
}
public final Collection getApiStages() {
return apiStages != null ? apiStages.stream().map(ApiStage::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder apiStages(Collection apiStages) {
this.apiStages = ListOfApiStageCopier.copy(apiStages);
return this;
}
@Override
@SafeVarargs
public final Builder apiStages(ApiStage... apiStages) {
apiStages(Arrays.asList(apiStages));
return this;
}
public final void setApiStages(Collection apiStages) {
this.apiStages = ListOfApiStageCopier.copyFromBuilder(apiStages);
}
public final ThrottleSettings.Builder getThrottle() {
return throttle != null ? throttle.toBuilder() : null;
}
@Override
public final Builder throttle(ThrottleSettings throttle) {
this.throttle = throttle;
return this;
}
public final void setThrottle(ThrottleSettings.BuilderImpl throttle) {
this.throttle = throttle != null ? throttle.build() : null;
}
public final QuotaSettings.Builder getQuota() {
return quota != null ? quota.toBuilder() : null;
}
@Override
public final Builder quota(QuotaSettings quota) {
this.quota = quota;
return this;
}
public final void setQuota(QuotaSettings.BuilderImpl quota) {
this.quota = quota != null ? quota.build() : null;
}
@Override
public Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig) {
super.requestOverrideConfig(awsRequestOverrideConfig);
return this;
}
@Override
public Builder requestOverrideConfig(Consumer builderConsumer) {
super.requestOverrideConfig(builderConsumer);
return this;
}
@Override
public CreateUsagePlanRequest build() {
return new CreateUsagePlanRequest(this);
}
}
}