software.amazon.awssdk.services.apigateway.model.GetDocumentationPartResponse 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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A documentation part for a targeted API entity.
*
*
*
* A documentation part consists of a content map (properties
) and a target (location
). The
* target specifies an API entity to which the documentation content applies. The supported API entity types are
* API
, AUTHORIZER
, MODEL
, RESOURCE
, METHOD
,
* PATH_PARAMETER
, QUERY_PARAMETER
, REQUEST_HEADER
, REQUEST_BODY
,
* RESPONSE
, RESPONSE_HEADER
, and RESPONSE_BODY
. Valid location
* fields depend on the API entity type. All valid fields are not required.
*
*
* The content map is a JSON string of API-specific key-value pairs. Although an API can use any shape for the content
* map, only the Swagger-compliant documentation fields will be injected into the associated API entity definition in
* the exported Swagger definition file.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public class GetDocumentationPartResponse extends APIGatewayResponse implements
ToCopyableBuilder {
private final String id;
private final DocumentationPartLocation location;
private final String properties;
private GetDocumentationPartResponse(BuilderImpl builder) {
super(builder);
this.id = builder.id;
this.location = builder.location;
this.properties = builder.properties;
}
/**
*
* The DocumentationPart identifier, generated by Amazon API Gateway when the DocumentationPart
* is created.
*
*
* @return The DocumentationPart identifier, generated by Amazon API Gateway when the
* DocumentationPart
is created.
*/
public String id() {
return id;
}
/**
*
* The location of the API entity to which the documentation applies. Valid fields depend on the targeted API entity
* type. All the valid location fields are not required. If not explicitly specified, a valid location field is
* treated as a wildcard and associated documentation content may be inherited by matching entities, unless
* overridden.
*
*
* @return The location of the API entity to which the documentation applies. Valid fields depend on the targeted
* API entity type. All the valid location fields are not required. If not explicitly specified, a valid
* location field is treated as a wildcard and associated documentation content may be inherited by matching
* entities, unless overridden.
*/
public DocumentationPartLocation location() {
return location;
}
/**
*
* A content map of API-specific key-value pairs describing the targeted API entity. The map must be encoded as a
* JSON string, e.g., "{ \"description\": \"The API does ...\" }"
. Only Swagger-compliant
* documentation-related fields from the properties map are exported and, hence, published as
* part of the API entity definitions, while the original documentation parts are exported in a Swagger extension of
* x-amazon-apigateway-documentation
.
*
*
* @return A content map of API-specific key-value pairs describing the targeted API entity. The map must be encoded
* as a JSON string, e.g., "{ \"description\": \"The API does ...\" }"
. Only Swagger-compliant
* documentation-related fields from the properties map are exported and, hence,
* published as part of the API entity definitions, while the original documentation parts are exported in a
* Swagger extension of x-amazon-apigateway-documentation
.
*/
public String properties() {
return properties;
}
@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(location());
hashCode = 31 * hashCode + Objects.hashCode(properties());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof GetDocumentationPartResponse)) {
return false;
}
GetDocumentationPartResponse other = (GetDocumentationPartResponse) obj;
return Objects.equals(id(), other.id()) && Objects.equals(location(), other.location())
&& Objects.equals(properties(), other.properties());
}
@Override
public String toString() {
return ToString.builder("GetDocumentationPartResponse").add("Id", id()).add("Location", location())
.add("Properties", properties()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "id":
return Optional.of(clazz.cast(id()));
case "location":
return Optional.of(clazz.cast(location()));
case "properties":
return Optional.of(clazz.cast(properties()));
default:
return Optional.empty();
}
}
public interface Builder extends APIGatewayResponse.Builder, CopyableBuilder {
/**
*
* The DocumentationPart identifier, generated by Amazon API Gateway when the
* DocumentationPart
is created.
*
*
* @param id
* The DocumentationPart identifier, generated by Amazon API Gateway when the
* DocumentationPart
is created.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder id(String id);
/**
*
* The location of the API entity to which the documentation applies. Valid fields depend on the targeted API
* entity type. All the valid location fields are not required. If not explicitly specified, a valid location
* field is treated as a wildcard and associated documentation content may be inherited by matching entities,
* unless overridden.
*
*
* @param location
* The location of the API entity to which the documentation applies. Valid fields depend on the targeted
* API entity type. All the valid location fields are not required. If not explicitly specified, a valid
* location field is treated as a wildcard and associated documentation content may be inherited by
* matching entities, unless overridden.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder location(DocumentationPartLocation location);
/**
*
* The location of the API entity to which the documentation applies. Valid fields depend on the targeted API
* entity type. All the valid location fields are not required. If not explicitly specified, a valid location
* field is treated as a wildcard and associated documentation content may be inherited by matching entities,
* unless overridden.
*
* This is a convenience that creates an instance of the {@link DocumentationPartLocation.Builder} avoiding the
* need to create one manually via {@link DocumentationPartLocation#builder()}.
*
* When the {@link Consumer} completes, {@link DocumentationPartLocation.Builder#build()} is called immediately
* and its result is passed to {@link #location(DocumentationPartLocation)}.
*
* @param location
* a consumer that will call methods on {@link DocumentationPartLocation.Builder}
* @return Returns a reference to this object so that method calls can be chained together.
* @see #location(DocumentationPartLocation)
*/
default Builder location(Consumer location) {
return location(DocumentationPartLocation.builder().apply(location).build());
}
/**
*
* A content map of API-specific key-value pairs describing the targeted API entity. The map must be encoded as
* a JSON string, e.g., "{ \"description\": \"The API does ...\" }"
. Only Swagger-compliant
* documentation-related fields from the properties map are exported and, hence, published as
* part of the API entity definitions, while the original documentation parts are exported in a Swagger
* extension of x-amazon-apigateway-documentation
.
*
*
* @param properties
* A content map of API-specific key-value pairs describing the targeted API entity. The map must be
* encoded as a JSON string, e.g., "{ \"description\": \"The API does ...\" }"
. Only
* Swagger-compliant documentation-related fields from the properties map are exported
* and, hence, published as part of the API entity definitions, while the original documentation parts
* are exported in a Swagger extension of x-amazon-apigateway-documentation
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder properties(String properties);
}
static final class BuilderImpl extends APIGatewayResponse.BuilderImpl implements Builder {
private String id;
private DocumentationPartLocation location;
private String properties;
private BuilderImpl() {
}
private BuilderImpl(GetDocumentationPartResponse model) {
id(model.id);
location(model.location);
properties(model.properties);
}
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 DocumentationPartLocation.Builder getLocation() {
return location != null ? location.toBuilder() : null;
}
@Override
public final Builder location(DocumentationPartLocation location) {
this.location = location;
return this;
}
public final void setLocation(DocumentationPartLocation.BuilderImpl location) {
this.location = location != null ? location.build() : null;
}
public final String getProperties() {
return properties;
}
@Override
public final Builder properties(String properties) {
this.properties = properties;
return this;
}
public final void setProperties(String properties) {
this.properties = properties;
}
@Override
public GetDocumentationPartResponse build() {
return new GetDocumentationPartResponse(this);
}
}
}