software.amazon.awssdk.services.apigateway.model.CreateModelResponse 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.Objects;
import java.util.Optional;
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 the data structure of a method's request or response payload.
*
*
*
* A request model defines the data structure of the client-supplied request payload. A response model defines the data
* structure of the response payload returned by the back end. Although not required, models are useful for mapping
* payloads between the front end and back end.
*
*
* A model is used for generating an API's SDK, validating the input request body, and creating a skeletal mapping
* template.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public class CreateModelResponse extends APIGatewayResponse implements
ToCopyableBuilder {
private final String id;
private final String name;
private final String description;
private final String schema;
private final String contentType;
private CreateModelResponse(BuilderImpl builder) {
super(builder);
this.id = builder.id;
this.name = builder.name;
this.description = builder.description;
this.schema = builder.schema;
this.contentType = builder.contentType;
}
/**
*
* The identifier for the model resource.
*
*
* @return The identifier for the model resource.
*/
public String id() {
return id;
}
/**
*
* The name of the model. Must be an alphanumeric string.
*
*
* @return The name of the model. Must be an alphanumeric string.
*/
public String name() {
return name;
}
/**
*
* The description of the model.
*
*
* @return The description of the model.
*/
public String description() {
return description;
}
/**
*
* The schema for the model. For application/json
models, this should be JSON-schema draft v4 model. Do not include
* "\*/" characters in the description of any properties because such "\*/" characters may be interpreted as
* the closing marker for comments in some languages, such as Java or JavaScript, causing the installation of your
* API's SDK generated by API Gateway to fail.
*
*
* @return The schema for the model. For application/json
models, this should be JSON-schema draft v4 model. Do not
* include "\*/" characters in the description of any properties because such "\*/" characters may
* be interpreted as the closing marker for comments in some languages, such as Java or JavaScript, causing
* the installation of your API's SDK generated by API Gateway to fail.
*/
public String schema() {
return schema;
}
/**
*
* The content-type for the model.
*
*
* @return The content-type for the model.
*/
public String contentType() {
return contentType;
}
@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(schema());
hashCode = 31 * hashCode + Objects.hashCode(contentType());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof CreateModelResponse)) {
return false;
}
CreateModelResponse other = (CreateModelResponse) obj;
return Objects.equals(id(), other.id()) && Objects.equals(name(), other.name())
&& Objects.equals(description(), other.description()) && Objects.equals(schema(), other.schema())
&& Objects.equals(contentType(), other.contentType());
}
@Override
public String toString() {
return ToString.builder("CreateModelResponse").add("Id", id()).add("Name", name()).add("Description", description())
.add("Schema", schema()).add("ContentType", contentType()).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 "schema":
return Optional.of(clazz.cast(schema()));
case "contentType":
return Optional.of(clazz.cast(contentType()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayResponse.Builder, CopyableBuilder {
/**
*
* The identifier for the model resource.
*
*
* @param id
* The identifier for the model resource.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder id(String id);
/**
*
* The name of the model. Must be an alphanumeric string.
*
*
* @param name
* The name of the model. Must be an alphanumeric string.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder name(String name);
/**
*
* The description of the model.
*
*
* @param description
* The description of the model.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder description(String description);
/**
*
* The schema for the model. For application/json
models, this should be JSON-schema draft v4 model. Do not
* include "\*/" characters in the description of any properties because such "\*/" characters may be
* interpreted as the closing marker for comments in some languages, such as Java or JavaScript, causing the
* installation of your API's SDK generated by API Gateway to fail.
*
*
* @param schema
* The schema for the model. For application/json
models, this should be JSON-schema draft v4 model. Do
* not include "\*/" characters in the description of any properties because such "\*/"
* characters may be interpreted as the closing marker for comments in some languages, such as Java or
* JavaScript, causing the installation of your API's SDK generated by API Gateway to fail.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder schema(String schema);
/**
*
* The content-type for the model.
*
*
* @param contentType
* The content-type for the model.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder contentType(String contentType);
}
static final class BuilderImpl extends APIGatewayResponse.BuilderImpl implements Builder {
private String id;
private String name;
private String description;
private String schema;
private String contentType;
private BuilderImpl() {
}
private BuilderImpl(CreateModelResponse model) {
id(model.id);
name(model.name);
description(model.description);
schema(model.schema);
contentType(model.contentType);
}
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 String getSchema() {
return schema;
}
@Override
public final Builder schema(String schema) {
this.schema = schema;
return this;
}
public final void setSchema(String schema) {
this.schema = schema;
}
public final String getContentType() {
return contentType;
}
@Override
public final Builder contentType(String contentType) {
this.contentType = contentType;
return this;
}
public final void setContentType(String contentType) {
this.contentType = contentType;
}
@Override
public CreateModelResponse build() {
return new CreateModelResponse(this);
}
}
}