software.amazon.awssdk.services.apigateway.model.ImportRestApiRequest 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 POST request to import an API to Amazon API Gateway using an input of an API definition file.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class ImportRestApiRequest extends APIGatewayRequest implements
ToCopyableBuilder {
private final Boolean failOnWarnings;
private final Map parameters;
private final ByteBuffer body;
private ImportRestApiRequest(BuilderImpl builder) {
super(builder);
this.failOnWarnings = builder.failOnWarnings;
this.parameters = builder.parameters;
this.body = builder.body;
}
/**
*
* A query parameter to indicate whether to rollback the API creation (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 creation (true
) or not (
* false
) when a warning is encountered. The default value is false
.
*/
public Boolean failOnWarnings() {
return failOnWarnings;
}
/**
*
* A key-value map of context-specific query string parameters specifying the behavior of different API importing
* operations. The following shows operation-specific parameters and their supported values.
*
*
* To exclude DocumentationParts from the import, set parameters
as
* ignore=documentation
.
*
*
* To configure the endpoint type, set parameters
as endpointConfigurationTypes=EDGE
or
* endpointConfigurationTypes=REGIONAL
. The default endpoint type is EDGE
.
*
*
* To handle imported basePath
, set parameters
as basePath=ignore
,
* basePath=prepend
or basePath=split
.
*
*
* For example, the AWS CLI command to exclude documentation from the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
*
*
* The AWS CLI command to set the regional endpoint on the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body 'file:///path/to/imported-api-body.json
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A key-value map of context-specific query string parameters specifying the behavior of different API
* importing operations. The following shows operation-specific parameters and their supported values.
*
* To exclude DocumentationParts from the import, set parameters
as
* ignore=documentation
.
*
*
* To configure the endpoint type, set parameters
as
* endpointConfigurationTypes=EDGE
orendpointConfigurationTypes=REGIONAL
. The
* default endpoint type is EDGE
.
*
*
* To handle imported basePath
, set parameters
as basePath=ignore
,
* basePath=prepend
or basePath=split
.
*
*
* For example, the AWS CLI command to exclude documentation from the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
*
*
* The AWS CLI command to set the regional endpoint on the imported API is:
*
*
* aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body 'file:///path/to/imported-api-body.json
*/
public Map parameters() {
return parameters;
}
/**
*
* The POST 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 POST 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(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 ImportRestApiRequest)) {
return false;
}
ImportRestApiRequest other = (ImportRestApiRequest) obj;
return Objects.equals(failOnWarnings(), other.failOnWarnings()) && Objects.equals(parameters(), other.parameters())
&& Objects.equals(body(), other.body());
}
@Override
public String toString() {
return ToString.builder("ImportRestApiRequest").add("FailOnWarnings", failOnWarnings()).add("Parameters", parameters())
.add("Body", body()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
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 {
/**
*
* A query parameter to indicate whether to rollback the API creation (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 creation (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);
/**
*
* A key-value map of context-specific query string parameters specifying the behavior of different API
* importing operations. The following shows operation-specific parameters and their supported values.
*
*
* To exclude DocumentationParts from the import, set parameters
as
* ignore=documentation
.
*
*
* To configure the endpoint type, set parameters
as endpointConfigurationTypes=EDGE
* orendpointConfigurationTypes=REGIONAL
. The default endpoint type is EDGE
.
*
*
* To handle imported basePath
, set parameters
as basePath=ignore
,
* basePath=prepend
or basePath=split
.
*
*
* For example, the AWS CLI command to exclude documentation from the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
*
*
* The AWS CLI command to set the regional endpoint on the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --body 'file:///path/to/imported-api-body.json
*
*
* @param parameters
* A key-value map of context-specific query string parameters specifying the behavior of different API
* importing operations. The following shows operation-specific parameters and their supported
* values.
*
* To exclude DocumentationParts from the import, set parameters
as
* ignore=documentation
.
*
*
* To configure the endpoint type, set parameters
as
* endpointConfigurationTypes=EDGE
orendpointConfigurationTypes=REGIONAL
. The
* default endpoint type is EDGE
.
*
*
* To handle imported basePath
, set parameters
as basePath=ignore
,
* basePath=prepend
or basePath=split
.
*
*
* For example, the AWS CLI command to exclude documentation from the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters ignore=documentation --body 'file:///path/to/imported-api-body.json
*
*
* The AWS CLI command to set the regional endpoint on the imported API is:
*
*
*
* aws apigateway import-rest-api --parameters endpointConfigurationTypes=REGIONAL --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 POST 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 POST 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 Boolean failOnWarnings;
private Map parameters;
private ByteBuffer body;
private BuilderImpl() {
}
private BuilderImpl(ImportRestApiRequest model) {
failOnWarnings(model.failOnWarnings);
parameters(model.parameters);
body(model.body);
}
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 ImportRestApiRequest build() {
return new ImportRestApiRequest(this);
}
}
}