software.amazon.awssdk.services.apigateway.model.RestApi 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.time.Instant;
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 javax.annotation.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.apigateway.transform.RestApiMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Represents a REST API.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public class RestApi implements StructuredPojo, ToCopyableBuilder {
private final String id;
private final String name;
private final String description;
private final Instant createdDate;
private final String version;
private final List warnings;
private final List binaryMediaTypes;
private final EndpointConfiguration endpointConfiguration;
private RestApi(BuilderImpl builder) {
this.id = builder.id;
this.name = builder.name;
this.description = builder.description;
this.createdDate = builder.createdDate;
this.version = builder.version;
this.warnings = builder.warnings;
this.binaryMediaTypes = builder.binaryMediaTypes;
this.endpointConfiguration = builder.endpointConfiguration;
}
/**
*
* The API's identifier. This identifier is unique across all of your APIs in Amazon API Gateway.
*
*
* @return The API's identifier. This identifier is unique across all of your APIs in Amazon API Gateway.
*/
public String id() {
return id;
}
/**
*
* The API's name.
*
*
* @return The API's name.
*/
public String name() {
return name;
}
/**
*
* The API's description.
*
*
* @return The API's description.
*/
public String description() {
return description;
}
/**
*
* The timestamp when the API was created.
*
*
* @return The timestamp when the API was created.
*/
public Instant createdDate() {
return createdDate;
}
/**
*
* A version identifier for the API.
*
*
* @return A version identifier for the API.
*/
public String version() {
return version;
}
/**
*
* The warning messages reported when failonwarnings
is turned on during API import.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The warning messages reported when failonwarnings
is turned on during API import.
*/
public List warnings() {
return warnings;
}
/**
*
* The list of binary media types supported by the RestApi. By default, the RestApi supports only
* UTF-8-encoded text payloads.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return The list of binary media types supported by the RestApi. By default, the RestApi supports
* only UTF-8-encoded text payloads.
*/
public List binaryMediaTypes() {
return binaryMediaTypes;
}
/**
*
* The endpoint configuration of this RestApi showing the endpoint types of the API.
*
*
* @return The endpoint configuration of this RestApi showing the endpoint types of the API.
*/
public EndpointConfiguration endpointConfiguration() {
return endpointConfiguration;
}
@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(createdDate());
hashCode = 31 * hashCode + Objects.hashCode(version());
hashCode = 31 * hashCode + Objects.hashCode(warnings());
hashCode = 31 * hashCode + Objects.hashCode(binaryMediaTypes());
hashCode = 31 * hashCode + Objects.hashCode(endpointConfiguration());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof RestApi)) {
return false;
}
RestApi other = (RestApi) obj;
return Objects.equals(id(), other.id()) && Objects.equals(name(), other.name())
&& Objects.equals(description(), other.description()) && Objects.equals(createdDate(), other.createdDate())
&& Objects.equals(version(), other.version()) && Objects.equals(warnings(), other.warnings())
&& Objects.equals(binaryMediaTypes(), other.binaryMediaTypes())
&& Objects.equals(endpointConfiguration(), other.endpointConfiguration());
}
@Override
public String toString() {
return ToString.builder("RestApi").add("Id", id()).add("Name", name()).add("Description", description())
.add("CreatedDate", createdDate()).add("Version", version()).add("Warnings", warnings())
.add("BinaryMediaTypes", binaryMediaTypes()).add("EndpointConfiguration", endpointConfiguration()).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 "createdDate":
return Optional.of(clazz.cast(createdDate()));
case "version":
return Optional.of(clazz.cast(version()));
case "warnings":
return Optional.of(clazz.cast(warnings()));
case "binaryMediaTypes":
return Optional.of(clazz.cast(binaryMediaTypes()));
case "endpointConfiguration":
return Optional.of(clazz.cast(endpointConfiguration()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
RestApiMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* The API's identifier. This identifier is unique across all of your APIs in Amazon API Gateway.
*
*
* @param id
* The API's identifier. This identifier is unique across all of your APIs in Amazon API Gateway.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder id(String id);
/**
*
* The API's name.
*
*
* @param name
* The API's name.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder name(String name);
/**
*
* The API's description.
*
*
* @param description
* The API's description.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* The timestamp when the API was created.
*
*
* @param createdDate
* The timestamp when the API was created.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder createdDate(Instant createdDate);
/**
*
* A version identifier for the API.
*
*
* @param version
* A version identifier for the API.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder version(String version);
/**
*
* The warning messages reported when failonwarnings
is turned on during API import.
*
*
* @param warnings
* The warning messages reported when failonwarnings
is turned on during API import.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder warnings(Collection warnings);
/**
*
* The warning messages reported when failonwarnings
is turned on during API import.
*
*
* @param warnings
* The warning messages reported when failonwarnings
is turned on during API import.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder warnings(String... warnings);
/**
*
* The list of binary media types supported by the RestApi. By default, the RestApi supports only
* UTF-8-encoded text payloads.
*
*
* @param binaryMediaTypes
* The list of binary media types supported by the RestApi. By default, the RestApi
* supports only UTF-8-encoded text payloads.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder binaryMediaTypes(Collection binaryMediaTypes);
/**
*
* The list of binary media types supported by the RestApi. By default, the RestApi supports only
* UTF-8-encoded text payloads.
*
*
* @param binaryMediaTypes
* The list of binary media types supported by the RestApi. By default, the RestApi
* supports only UTF-8-encoded text payloads.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder binaryMediaTypes(String... binaryMediaTypes);
/**
*
* The endpoint configuration of this RestApi showing the endpoint types of the API.
*
*
* @param endpointConfiguration
* The endpoint configuration of this RestApi showing the endpoint types of the API.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder endpointConfiguration(EndpointConfiguration endpointConfiguration);
/**
*
* The endpoint configuration of this RestApi showing the endpoint types of the API.
*
* This is a convenience that creates an instance of the {@link EndpointConfiguration.Builder} avoiding the need
* to create one manually via {@link EndpointConfiguration#builder()}.
*
* When the {@link Consumer} completes, {@link EndpointConfiguration.Builder#build()} is called immediately and
* its result is passed to {@link #endpointConfiguration(EndpointConfiguration)}.
*
* @param endpointConfiguration
* a consumer that will call methods on {@link EndpointConfiguration.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #endpointConfiguration(EndpointConfiguration)
*/
default Builder endpointConfiguration(Consumer endpointConfiguration) {
return endpointConfiguration(EndpointConfiguration.builder().apply(endpointConfiguration).build());
}
}
static final class BuilderImpl implements Builder {
private String id;
private String name;
private String description;
private Instant createdDate;
private String version;
private List warnings;
private List binaryMediaTypes;
private EndpointConfiguration endpointConfiguration;
private BuilderImpl() {
}
private BuilderImpl(RestApi model) {
id(model.id);
name(model.name);
description(model.description);
createdDate(model.createdDate);
version(model.version);
warnings(model.warnings);
binaryMediaTypes(model.binaryMediaTypes);
endpointConfiguration(model.endpointConfiguration);
}
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 Instant getCreatedDate() {
return createdDate;
}
@Override
public final Builder createdDate(Instant createdDate) {
this.createdDate = createdDate;
return this;
}
public final void setCreatedDate(Instant createdDate) {
this.createdDate = createdDate;
}
public final String getVersion() {
return version;
}
@Override
public final Builder version(String version) {
this.version = version;
return this;
}
public final void setVersion(String version) {
this.version = version;
}
public final Collection getWarnings() {
return warnings;
}
@Override
public final Builder warnings(Collection warnings) {
this.warnings = ListOfStringCopier.copy(warnings);
return this;
}
@Override
@SafeVarargs
public final Builder warnings(String... warnings) {
warnings(Arrays.asList(warnings));
return this;
}
public final void setWarnings(Collection warnings) {
this.warnings = ListOfStringCopier.copy(warnings);
}
public final Collection getBinaryMediaTypes() {
return binaryMediaTypes;
}
@Override
public final Builder binaryMediaTypes(Collection binaryMediaTypes) {
this.binaryMediaTypes = ListOfStringCopier.copy(binaryMediaTypes);
return this;
}
@Override
@SafeVarargs
public final Builder binaryMediaTypes(String... binaryMediaTypes) {
binaryMediaTypes(Arrays.asList(binaryMediaTypes));
return this;
}
public final void setBinaryMediaTypes(Collection binaryMediaTypes) {
this.binaryMediaTypes = ListOfStringCopier.copy(binaryMediaTypes);
}
public final EndpointConfiguration.Builder getEndpointConfiguration() {
return endpointConfiguration != null ? endpointConfiguration.toBuilder() : null;
}
@Override
public final Builder endpointConfiguration(EndpointConfiguration endpointConfiguration) {
this.endpointConfiguration = endpointConfiguration;
return this;
}
public final void setEndpointConfiguration(EndpointConfiguration.BuilderImpl endpointConfiguration) {
this.endpointConfiguration = endpointConfiguration != null ? endpointConfiguration.build() : null;
}
@Override
public RestApi build() {
return new RestApi(this);
}
}
}