software.amazon.awssdk.services.apigateway.model.PutRestApiRequest 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.nio.ByteBuffer;
import java.util.Map;
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.core.runtime.StandardMemberCopier;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A PUT request to update an existing API, with external API definitions specified as the request body.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class PutRestApiRequest extends APIGatewayRequest implements
ToCopyableBuilder {
private final String restApiId;
private final String mode;
private final Boolean failOnWarnings;
private final Map parameters;
private final ByteBuffer body;
private PutRestApiRequest(BuilderImpl builder) {
super(builder);
this.restApiId = builder.restApiId;
this.mode = builder.mode;
this.failOnWarnings = builder.failOnWarnings;
this.parameters = builder.parameters;
this.body = builder.body;
}
/**
*
* The string identifier of the associated RestApi.
*
*
* @return The string identifier of the associated RestApi.
*/
public String restApiId() {
return restApiId;
}
/**
*
* The mode
query parameter to specify the update mode. Valid values are "merge" and "overwrite". By
* default, the update mode is "merge".
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link PutMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeString}.
*
*
* @return The mode
query parameter to specify the update mode. Valid values are "merge" and
* "overwrite". By default, the update mode is "merge".
* @see PutMode
*/
public PutMode mode() {
return PutMode.fromValue(mode);
}
/**
*
* The mode
query parameter to specify the update mode. Valid values are "merge" and "overwrite". By
* default, the update mode is "merge".
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #mode} will return
* {@link PutMode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #modeString}.
*
*
* @return The mode
query parameter to specify the update mode. Valid values are "merge" and
* "overwrite". By default, the update mode is "merge".
* @see PutMode
*/
public String modeString() {
return mode;
}
/**
*
* A query parameter to indicate whether to rollback the API update (true
) or not (false
)
* when a warning is encountered. The default value is false
.
*
*
* @return A query parameter to indicate whether to rollback the API update (true
) or not (
* false
) when a warning is encountered. The default value is false
.
*/
public Boolean failOnWarnings() {
return failOnWarnings;
}
/**
*
* Custom header parameters as part of the request. For example, to exclude DocumentationParts from an
* imported API, set ignore=documentation
as a parameters
value, as in the AWS CLI command
* of
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
* .
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Custom header parameters as part of the request. For example, to exclude DocumentationParts from
* an imported API, set ignore=documentation
as a parameters
value, as in the AWS
* CLI command of
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
* .
*/
public Map parameters() {
return parameters;
}
/**
*
* The PUT request body containing external API definitions. Currently, only Swagger definition JSON files are
* supported. The maximum size of the API definition file is 2MB.
*
*
* This method will return a new read-only {@code ByteBuffer} each time it is invoked.
*
*
* @return The PUT request body containing external API definitions. Currently, only Swagger definition JSON files
* are supported. The maximum size of the API definition file is 2MB.
*/
public ByteBuffer body() {
return body == null ? null : body.asReadOnlyBuffer();
}
@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(modeString());
hashCode = 31 * hashCode + Objects.hashCode(failOnWarnings());
hashCode = 31 * hashCode + Objects.hashCode(parameters());
hashCode = 31 * hashCode + Objects.hashCode(body());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PutRestApiRequest)) {
return false;
}
PutRestApiRequest other = (PutRestApiRequest) obj;
return Objects.equals(restApiId(), other.restApiId()) && Objects.equals(modeString(), other.modeString())
&& Objects.equals(failOnWarnings(), other.failOnWarnings()) && Objects.equals(parameters(), other.parameters())
&& Objects.equals(body(), other.body());
}
@Override
public String toString() {
return ToString.builder("PutRestApiRequest").add("RestApiId", restApiId()).add("Mode", modeString())
.add("FailOnWarnings", failOnWarnings()).add("Parameters", parameters()).add("Body", body()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "restApiId":
return Optional.of(clazz.cast(restApiId()));
case "mode":
return Optional.of(clazz.cast(modeString()));
case "failOnWarnings":
return Optional.of(clazz.cast(failOnWarnings()));
case "parameters":
return Optional.of(clazz.cast(parameters()));
case "body":
return Optional.of(clazz.cast(body()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayRequest.Builder, CopyableBuilder {
/**
*
* The string identifier of the associated RestApi.
*
*
* @param restApiId
* The string identifier of the associated RestApi.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder restApiId(String restApiId);
/**
*
* The mode
query parameter to specify the update mode. Valid values are "merge" and "overwrite".
* By default, the update mode is "merge".
*
*
* @param mode
* The mode
query parameter to specify the update mode. Valid values are "merge" and
* "overwrite". By default, the update mode is "merge".
* @see PutMode
* @return Returns a reference to this object so that method calls can be chained together.
* @see PutMode
*/
Builder mode(String mode);
/**
*
* The mode
query parameter to specify the update mode. Valid values are "merge" and "overwrite".
* By default, the update mode is "merge".
*
*
* @param mode
* The mode
query parameter to specify the update mode. Valid values are "merge" and
* "overwrite". By default, the update mode is "merge".
* @see PutMode
* @return Returns a reference to this object so that method calls can be chained together.
* @see PutMode
*/
Builder mode(PutMode mode);
/**
*
* A query parameter to indicate whether to rollback the API update (true
) or not (
* false
) when a warning is encountered. The default value is false
.
*
*
* @param failOnWarnings
* A query parameter to indicate whether to rollback the API update (true
) or not (
* false
) when a warning is encountered. The default value is false
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder failOnWarnings(Boolean failOnWarnings);
/**
*
* Custom header parameters as part of the request. For example, to exclude DocumentationParts from an
* imported API, set ignore=documentation
as a parameters
value, as in the AWS CLI
* command of
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
* .
*
*
* @param parameters
* Custom header parameters as part of the request. For example, to exclude DocumentationParts
* from an imported API, set ignore=documentation
as a parameters
value, as in
* the AWS CLI command of
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
* .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder parameters(Map parameters);
/**
*
* The PUT request body containing external API definitions. Currently, only Swagger definition JSON files are
* supported. The maximum size of the API definition file is 2MB.
*
*
* To preserve immutability, the remaining bytes in the provided buffer will be copied into a new buffer when
* set.
*
*
* @param body
* The PUT request body containing external API definitions. Currently, only Swagger definition JSON
* files are supported. The maximum size of the API definition file is 2MB.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder body(ByteBuffer body);
@Override
Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig);
}
static final class BuilderImpl extends APIGatewayRequest.BuilderImpl implements Builder {
private String restApiId;
private String mode;
private Boolean failOnWarnings;
private Map parameters;
private ByteBuffer body;
private BuilderImpl() {
}
private BuilderImpl(PutRestApiRequest model) {
restApiId(model.restApiId);
mode(model.mode);
failOnWarnings(model.failOnWarnings);
parameters(model.parameters);
body(model.body);
}
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 getMode() {
return mode;
}
@Override
public final Builder mode(String mode) {
this.mode = mode;
return this;
}
@Override
public final Builder mode(PutMode mode) {
this.mode(mode.toString());
return this;
}
public final void setMode(String mode) {
this.mode = mode;
}
public final Boolean getFailOnWarnings() {
return failOnWarnings;
}
@Override
public final Builder failOnWarnings(Boolean failOnWarnings) {
this.failOnWarnings = failOnWarnings;
return this;
}
public final void setFailOnWarnings(Boolean failOnWarnings) {
this.failOnWarnings = failOnWarnings;
}
public final Map getParameters() {
return parameters;
}
@Override
public final Builder parameters(Map parameters) {
this.parameters = MapOfStringToStringCopier.copy(parameters);
return this;
}
public final void setParameters(Map parameters) {
this.parameters = MapOfStringToStringCopier.copy(parameters);
}
public final ByteBuffer getBody() {
return body;
}
@Override
public final Builder body(ByteBuffer body) {
this.body = StandardMemberCopier.copy(body);
return this;
}
public final void setBody(ByteBuffer body) {
this.body = StandardMemberCopier.copy(body);
}
@Override
public Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig) {
super.requestOverrideConfig(awsRequestOverrideConfig);
return this;
}
@Override
public Builder requestOverrideConfig(Consumer builderConsumer) {
super.requestOverrideConfig(builderConsumer);
return this;
}
@Override
public PutRestApiRequest build() {
return new PutRestApiRequest(this);
}
}
}