software.amazon.awssdk.services.apigateway.model.UpdateUsagePlanResponse 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents a usage plan than can specify who can assess associated API stages with specified request limits and
* quotas.
*
*
*
* In a usage plan, you associate an API by specifying the API's Id and a stage name of the specified API. You add plan
* customers by adding API keys to the plan.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public class UpdateUsagePlanResponse extends APIGatewayResponse implements
ToCopyableBuilder {
private final String id;
private final String name;
private final String description;
private final List apiStages;
private final ThrottleSettings throttle;
private final QuotaSettings quota;
private final String productCode;
private UpdateUsagePlanResponse(BuilderImpl builder) {
super(builder);
this.id = builder.id;
this.name = builder.name;
this.description = builder.description;
this.apiStages = builder.apiStages;
this.throttle = builder.throttle;
this.quota = builder.quota;
this.productCode = builder.productCode;
}
/**
*
* The identifier of a UsagePlan resource.
*
*
* @return The identifier of a UsagePlan resource.
*/
public String id() {
return id;
}
/**
*
* The name of a usage plan.
*
*
* @return The name of a usage plan.
*/
public String name() {
return name;
}
/**
*
* The description of a usage plan.
*
*
* @return The description of a usage plan.
*/
public String description() {
return description;
}
/**
*
* The associated API stages of a usage plan.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The associated API stages of a usage plan.
*/
public List apiStages() {
return apiStages;
}
/**
*
* The request throttle limits of a usage plan.
*
*
* @return The request throttle limits of a usage plan.
*/
public ThrottleSettings throttle() {
return throttle;
}
/**
*
* The maximum number of permitted requests per a given unit time interval.
*
*
* @return The maximum number of permitted requests per a given unit time interval.
*/
public QuotaSettings quota() {
return quota;
}
/**
*
* The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.
*
*
* @return The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS
* Marketplace.
*/
public String productCode() {
return productCode;
}
@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(id());
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());
hashCode = 31 * hashCode + Objects.hashCode(productCode());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof UpdateUsagePlanResponse)) {
return false;
}
UpdateUsagePlanResponse other = (UpdateUsagePlanResponse) obj;
return Objects.equals(id(), other.id()) && 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())
&& Objects.equals(productCode(), other.productCode());
}
@Override
public String toString() {
return ToString.builder("UpdateUsagePlanResponse").add("Id", id()).add("Name", name()).add("Description", description())
.add("ApiStages", apiStages()).add("Throttle", throttle()).add("Quota", quota())
.add("ProductCode", productCode()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.of(clazz.cast(id()));
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()));
case "productCode":
return Optional.of(clazz.cast(productCode()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayResponse.Builder, CopyableBuilder {
/**
*
* The identifier of a UsagePlan resource.
*
*
* @param id
* The identifier of a UsagePlan resource.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder id(String id);
/**
*
* The name of a usage plan.
*
*
* @param name
* The name of a usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder name(String name);
/**
*
* The description of a usage plan.
*
*
* @param description
* The description of a 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 a usage plan.
*
*
* @param apiStages
* The associated API stages of a 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 a usage plan.
*
*
* @param apiStages
* The associated API stages of a usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder apiStages(ApiStage... apiStages);
/**
*
* The request throttle limits of a usage plan.
*
*
* @param throttle
* The request throttle limits of a usage plan.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder throttle(ThrottleSettings throttle);
/**
*
* The request throttle limits of a 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 maximum number of permitted requests per a given unit time interval.
*
*
* @param quota
* The maximum number of permitted requests per a given unit time interval.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder quota(QuotaSettings quota);
/**
*
* The maximum number of permitted requests per a given unit time interval.
*
* 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());
}
/**
*
* The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS Marketplace.
*
*
* @param productCode
* The AWS Markeplace product identifier to associate with the usage plan as a SaaS product on AWS
* Marketplace.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder productCode(String productCode);
}
static final class BuilderImpl extends APIGatewayResponse.BuilderImpl implements Builder {
private String id;
private String name;
private String description;
private List apiStages;
private ThrottleSettings throttle;
private QuotaSettings quota;
private String productCode;
private BuilderImpl() {
}
private BuilderImpl(UpdateUsagePlanResponse model) {
id(model.id);
name(model.name);
description(model.description);
apiStages(model.apiStages);
throttle(model.throttle);
quota(model.quota);
productCode(model.productCode);
}
public final String getId() {
return id;
}
@Override
public final Builder id(String id) {
this.id = id;
return this;
}
public final void setId(String id) {
this.id = id;
}
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;
}
public final String getProductCode() {
return productCode;
}
@Override
public final Builder productCode(String productCode) {
this.productCode = productCode;
return this;
}
public final void setProductCode(String productCode) {
this.productCode = productCode;
}
@Override
public UpdateUsagePlanResponse build() {
return new UpdateUsagePlanResponse(this);
}
}
}