software.amazon.awssdk.services.apigateway.model.CreateApiKeyRequest 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;
/**
*
* Request to create an ApiKey resource.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class CreateApiKeyRequest extends APIGatewayRequest implements
ToCopyableBuilder {
private final String name;
private final String description;
private final Boolean enabled;
private final Boolean generateDistinctId;
private final String value;
private final List stageKeys;
private final String customerId;
private CreateApiKeyRequest(BuilderImpl builder) {
super(builder);
this.name = builder.name;
this.description = builder.description;
this.enabled = builder.enabled;
this.generateDistinctId = builder.generateDistinctId;
this.value = builder.value;
this.stageKeys = builder.stageKeys;
this.customerId = builder.customerId;
}
/**
*
* The name of the ApiKey.
*
*
* @return The name of the ApiKey.
*/
public String name() {
return name;
}
/**
*
* The description of the ApiKey.
*
*
* @return The description of the ApiKey.
*/
public String description() {
return description;
}
/**
*
* Specifies whether the ApiKey can be used by callers.
*
*
* @return Specifies whether the ApiKey can be used by callers.
*/
public Boolean enabled() {
return enabled;
}
/**
*
* Specifies whether (true
) or not (false
) the key identifier is distinct from the created
* API key value.
*
*
* @return Specifies whether (true
) or not (false
) the key identifier is distinct from the
* created API key value.
*/
public Boolean generateDistinctId() {
return generateDistinctId;
}
/**
*
* Specifies a value of the API key.
*
*
* @return Specifies a value of the API key.
*/
public String value() {
return value;
}
/**
*
* DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
*/
public List stageKeys() {
return stageKeys;
}
/**
*
* An AWS Marketplace customer identifier , when integrating with the AWS SaaS Marketplace.
*
*
* @return An AWS Marketplace customer identifier , when integrating with the AWS SaaS Marketplace.
*/
public String customerId() {
return customerId;
}
@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(enabled());
hashCode = 31 * hashCode + Objects.hashCode(generateDistinctId());
hashCode = 31 * hashCode + Objects.hashCode(value());
hashCode = 31 * hashCode + Objects.hashCode(stageKeys());
hashCode = 31 * hashCode + Objects.hashCode(customerId());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateApiKeyRequest)) {
return false;
}
CreateApiKeyRequest other = (CreateApiKeyRequest) obj;
return Objects.equals(name(), other.name()) && Objects.equals(description(), other.description())
&& Objects.equals(enabled(), other.enabled()) && Objects.equals(generateDistinctId(), other.generateDistinctId())
&& Objects.equals(value(), other.value()) && Objects.equals(stageKeys(), other.stageKeys())
&& Objects.equals(customerId(), other.customerId());
}
@Override
public String toString() {
return ToString.builder("CreateApiKeyRequest").add("Name", name()).add("Description", description())
.add("Enabled", enabled()).add("GenerateDistinctId", generateDistinctId()).add("Value", value())
.add("StageKeys", stageKeys()).add("CustomerId", customerId()).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 "enabled":
return Optional.of(clazz.cast(enabled()));
case "generateDistinctId":
return Optional.of(clazz.cast(generateDistinctId()));
case "value":
return Optional.of(clazz.cast(value()));
case "stageKeys":
return Optional.of(clazz.cast(stageKeys()));
case "customerId":
return Optional.of(clazz.cast(customerId()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayRequest.Builder, CopyableBuilder {
/**
*
* The name of the ApiKey.
*
*
* @param name
* The name of the ApiKey.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder name(String name);
/**
*
* The description of the ApiKey.
*
*
* @param description
* The description of the ApiKey.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* Specifies whether the ApiKey can be used by callers.
*
*
* @param enabled
* Specifies whether the ApiKey can be used by callers.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder enabled(Boolean enabled);
/**
*
* Specifies whether (true
) or not (false
) the key identifier is distinct from the
* created API key value.
*
*
* @param generateDistinctId
* Specifies whether (true
) or not (false
) the key identifier is distinct from
* the created API key value.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder generateDistinctId(Boolean generateDistinctId);
/**
*
* Specifies a value of the API key.
*
*
* @param value
* Specifies a value of the API key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder value(String value);
/**
*
* DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
*
*
* @param stageKeys
* DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder stageKeys(Collection stageKeys);
/**
*
* DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
*
*
* @param stageKeys
* DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API key.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder stageKeys(StageKey... stageKeys);
/**
*
* An AWS Marketplace customer identifier , when integrating with the AWS SaaS Marketplace.
*
*
* @param customerId
* An AWS Marketplace customer identifier , when integrating with the AWS SaaS Marketplace.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder customerId(String customerId);
@Override
Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig);
}
static final class BuilderImpl extends APIGatewayRequest.BuilderImpl implements Builder {
private String name;
private String description;
private Boolean enabled;
private Boolean generateDistinctId;
private String value;
private List stageKeys;
private String customerId;
private BuilderImpl() {
}
private BuilderImpl(CreateApiKeyRequest model) {
name(model.name);
description(model.description);
enabled(model.enabled);
generateDistinctId(model.generateDistinctId);
value(model.value);
stageKeys(model.stageKeys);
customerId(model.customerId);
}
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 Boolean getEnabled() {
return enabled;
}
@Override
public final Builder enabled(Boolean enabled) {
this.enabled = enabled;
return this;
}
public final void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
public final Boolean getGenerateDistinctId() {
return generateDistinctId;
}
@Override
public final Builder generateDistinctId(Boolean generateDistinctId) {
this.generateDistinctId = generateDistinctId;
return this;
}
public final void setGenerateDistinctId(Boolean generateDistinctId) {
this.generateDistinctId = generateDistinctId;
}
public final String getValue() {
return value;
}
@Override
public final Builder value(String value) {
this.value = value;
return this;
}
public final void setValue(String value) {
this.value = value;
}
public final Collection getStageKeys() {
return stageKeys != null ? stageKeys.stream().map(StageKey::toBuilder).collect(Collectors.toList()) : null;
}
@Override
public final Builder stageKeys(Collection stageKeys) {
this.stageKeys = ListOfStageKeysCopier.copy(stageKeys);
return this;
}
@Override
@SafeVarargs
public final Builder stageKeys(StageKey... stageKeys) {
stageKeys(Arrays.asList(stageKeys));
return this;
}
public final void setStageKeys(Collection stageKeys) {
this.stageKeys = ListOfStageKeysCopier.copyFromBuilder(stageKeys);
}
public final String getCustomerId() {
return customerId;
}
@Override
public final Builder customerId(String customerId) {
this.customerId = customerId;
return this;
}
public final void setCustomerId(String customerId) {
this.customerId = customerId;
}
@Override
public Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig) {
super.requestOverrideConfig(awsRequestOverrideConfig);
return this;
}
@Override
public Builder requestOverrideConfig(Consumer builderConsumer) {
super.requestOverrideConfig(builderConsumer);
return this;
}
@Override
public CreateApiKeyRequest build() {
return new CreateApiKeyRequest(this);
}
}
}