software.amazon.awssdk.services.apigateway.model.CreateModelRequest 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 java.util.function.Consumer;
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 add a new Model to an existing RestApi resource.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class CreateModelRequest extends APIGatewayRequest implements
ToCopyableBuilder {
private final String restApiId;
private final String name;
private final String description;
private final String schema;
private final String contentType;
private CreateModelRequest(BuilderImpl builder) {
super(builder);
this.restApiId = builder.restApiId;
this.name = builder.name;
this.description = builder.description;
this.schema = builder.schema;
this.contentType = builder.contentType;
}
/**
*
* The RestApi identifier under which the Model will be created.
*
*
* @return The RestApi identifier under which the Model will be created.
*/
public String restApiId() {
return restApiId;
}
/**
*
* The name of the model. Must be alphanumeric.
*
*
* @return The name of the model. Must be alphanumeric.
*/
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.
*
*
* @return The schema for the model. For application/json
models, this should be JSON-schema draft v4 model.
*/
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(restApiId());
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 CreateModelRequest)) {
return false;
}
CreateModelRequest other = (CreateModelRequest) obj;
return Objects.equals(restApiId(), other.restApiId()) && 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("CreateModelRequest").add("RestApiId", restApiId()).add("Name", name())
.add("Description", description()).add("Schema", schema()).add("ContentType", contentType()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "restApiId":
return Optional.of(clazz.cast(restApiId()));
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 APIGatewayRequest.Builder, CopyableBuilder {
/**
*
* The RestApi identifier under which the Model will be created.
*
*
* @param restApiId
* The RestApi identifier under which the Model will be created.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder restApiId(String restApiId);
/**
*
* The name of the model. Must be alphanumeric.
*
*
* @param name
* The name of the model. Must be alphanumeric.
* @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.
*
*
* @param schema
* The schema for the model. For application/json
models, this should be JSON-schema draft v4 model.
* @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);
@Override
Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig);
}
static final class BuilderImpl extends APIGatewayRequest.BuilderImpl implements Builder {
private String restApiId;
private String name;
private String description;
private String schema;
private String contentType;
private BuilderImpl() {
}
private BuilderImpl(CreateModelRequest model) {
restApiId(model.restApiId);
name(model.name);
description(model.description);
schema(model.schema);
contentType(model.contentType);
}
public final String getRestApiId() {
return restApiId;
}
@Override
public final Builder restApiId(String restApiId) {
this.restApiId = restApiId;
return this;
}
public final void setRestApiId(String restApiId) {
this.restApiId = restApiId;
}
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 Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig) {
super.requestOverrideConfig(awsRequestOverrideConfig);
return this;
}
@Override
public Builder requestOverrideConfig(Consumer builderConsumer) {
super.requestOverrideConfig(builderConsumer);
return this;
}
@Override
public CreateModelRequest build() {
return new CreateModelRequest(this);
}
}
}