software.amazon.awssdk.services.apigateway.model.PutMethodRequest 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.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.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Request to add a method to an existing Resource resource.
*
*/
@Generated("software.amazon.awssdk:codegen")
public class PutMethodRequest extends APIGatewayRequest implements ToCopyableBuilder {
private final String restApiId;
private final String resourceId;
private final String httpMethod;
private final String authorizationType;
private final String authorizerId;
private final Boolean apiKeyRequired;
private final String operationName;
private final Map requestParameters;
private final Map requestModels;
private final String requestValidatorId;
private PutMethodRequest(BuilderImpl builder) {
super(builder);
this.restApiId = builder.restApiId;
this.resourceId = builder.resourceId;
this.httpMethod = builder.httpMethod;
this.authorizationType = builder.authorizationType;
this.authorizerId = builder.authorizerId;
this.apiKeyRequired = builder.apiKeyRequired;
this.operationName = builder.operationName;
this.requestParameters = builder.requestParameters;
this.requestModels = builder.requestModels;
this.requestValidatorId = builder.requestValidatorId;
}
/**
*
* The string identifier of the associated RestApi.
*
*
* @return The string identifier of the associated RestApi.
*/
public String restApiId() {
return restApiId;
}
/**
*
* The Resource identifier for the new Method resource.
*
*
* @return The Resource identifier for the new Method resource.
*/
public String resourceId() {
return resourceId;
}
/**
*
* Specifies the method request's HTTP method type.
*
*
* @return Specifies the method request's HTTP method type.
*/
public String httpMethod() {
return httpMethod;
}
/**
*
* The method's authorization type. Valid values are NONE
for open access, AWS_IAM
for
* using AWS IAM permissions, CUSTOM
for using a custom authorizer, or COGNITO_USER_POOLS
* for using a Cognito user pool.
*
*
* @return The method's authorization type. Valid values are NONE
for open access, AWS_IAM
* for using AWS IAM permissions, CUSTOM
for using a custom authorizer, or
* COGNITO_USER_POOLS
for using a Cognito user pool.
*/
public String authorizationType() {
return authorizationType;
}
/**
*
* Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM.
*
*
* @return Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM.
*/
public String authorizerId() {
return authorizerId;
}
/**
*
* Specifies whether the method required a valid ApiKey.
*
*
* @return Specifies whether the method required a valid ApiKey.
*/
public Boolean apiKeyRequired() {
return apiKeyRequired;
}
/**
*
* A human-friendly operation identifier for the method. For example, you can assign the operationName
* of ListPets
for the GET /pets
method in PetStore example.
*
*
* @return A human-friendly operation identifier for the method. For example, you can assign the
* operationName
of ListPets
for the GET /pets
method in PetStore example.
*/
public String operationName() {
return operationName;
}
/**
*
* A key-value map defining required or optional method request parameters that can be accepted by Amazon API
* Gateway. A key defines a method request parameter name matching the pattern of
* method.request.{location}.{name}
, where location
is querystring
,
* path
, or header
and name
is a valid and unique parameter name. The value
* associated with the key is a Boolean flag indicating whether the parameter is required (true
) or
* optional (false
). The method request parameter names defined here are available in
* Integration to be mapped to integration request parameters or body-mapping templates.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return A key-value map defining required or optional method request parameters that can be accepted by Amazon
* API Gateway. A key defines a method request parameter name matching the pattern of
* method.request.{location}.{name}
, where location
is querystring
,
* path
, or header
and name
is a valid and unique parameter name. The
* value associated with the key is a Boolean flag indicating whether the parameter is required (
* true
) or optional (false
). The method request parameter names defined here are
* available in Integration to be mapped to integration request parameters or body-mapping templates.
*/
public Map requestParameters() {
return requestParameters;
}
/**
*
* Specifies the Model resources used for the request's content type. Request models are represented as a
* key/value map, with a content type as the key and a Model name as the value.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* @return Specifies the Model resources used for the request's content type. Request models are represented
* as a key/value map, with a content type as the key and a Model name as the value.
*/
public Map requestModels() {
return requestModels;
}
/**
*
* The identifier of a RequestValidator for validating the method request.
*
*
* @return The identifier of a RequestValidator for validating the method request.
*/
public String requestValidatorId() {
return requestValidatorId;
}
@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(resourceId());
hashCode = 31 * hashCode + Objects.hashCode(httpMethod());
hashCode = 31 * hashCode + Objects.hashCode(authorizationType());
hashCode = 31 * hashCode + Objects.hashCode(authorizerId());
hashCode = 31 * hashCode + Objects.hashCode(apiKeyRequired());
hashCode = 31 * hashCode + Objects.hashCode(operationName());
hashCode = 31 * hashCode + Objects.hashCode(requestParameters());
hashCode = 31 * hashCode + Objects.hashCode(requestModels());
hashCode = 31 * hashCode + Objects.hashCode(requestValidatorId());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PutMethodRequest)) {
return false;
}
PutMethodRequest other = (PutMethodRequest) obj;
return Objects.equals(restApiId(), other.restApiId()) && Objects.equals(resourceId(), other.resourceId())
&& Objects.equals(httpMethod(), other.httpMethod())
&& Objects.equals(authorizationType(), other.authorizationType())
&& Objects.equals(authorizerId(), other.authorizerId())
&& Objects.equals(apiKeyRequired(), other.apiKeyRequired())
&& Objects.equals(operationName(), other.operationName())
&& Objects.equals(requestParameters(), other.requestParameters())
&& Objects.equals(requestModels(), other.requestModels())
&& Objects.equals(requestValidatorId(), other.requestValidatorId());
}
@Override
public String toString() {
return ToString.builder("PutMethodRequest").add("RestApiId", restApiId()).add("ResourceId", resourceId())
.add("HttpMethod", httpMethod()).add("AuthorizationType", authorizationType())
.add("AuthorizerId", authorizerId()).add("ApiKeyRequired", apiKeyRequired())
.add("OperationName", operationName()).add("RequestParameters", requestParameters())
.add("RequestModels", requestModels()).add("RequestValidatorId", requestValidatorId()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "restApiId":
return Optional.of(clazz.cast(restApiId()));
case "resourceId":
return Optional.of(clazz.cast(resourceId()));
case "httpMethod":
return Optional.of(clazz.cast(httpMethod()));
case "authorizationType":
return Optional.of(clazz.cast(authorizationType()));
case "authorizerId":
return Optional.of(clazz.cast(authorizerId()));
case "apiKeyRequired":
return Optional.of(clazz.cast(apiKeyRequired()));
case "operationName":
return Optional.of(clazz.cast(operationName()));
case "requestParameters":
return Optional.of(clazz.cast(requestParameters()));
case "requestModels":
return Optional.of(clazz.cast(requestModels()));
case "requestValidatorId":
return Optional.of(clazz.cast(requestValidatorId()));
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 Resource identifier for the new Method resource.
*
*
* @param resourceId
* The Resource identifier for the new Method resource.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder resourceId(String resourceId);
/**
*
* Specifies the method request's HTTP method type.
*
*
* @param httpMethod
* Specifies the method request's HTTP method type.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder httpMethod(String httpMethod);
/**
*
* The method's authorization type. Valid values are NONE
for open access, AWS_IAM
for
* using AWS IAM permissions, CUSTOM
for using a custom authorizer, or
* COGNITO_USER_POOLS
for using a Cognito user pool.
*
*
* @param authorizationType
* The method's authorization type. Valid values are NONE
for open access,
* AWS_IAM
for using AWS IAM permissions, CUSTOM
for using a custom authorizer,
* or COGNITO_USER_POOLS
for using a Cognito user pool.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder authorizationType(String authorizationType);
/**
*
* Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM.
*
*
* @param authorizerId
* Specifies the identifier of an Authorizer to use on this Method, if the type is CUSTOM.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder authorizerId(String authorizerId);
/**
*
* Specifies whether the method required a valid ApiKey.
*
*
* @param apiKeyRequired
* Specifies whether the method required a valid ApiKey.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder apiKeyRequired(Boolean apiKeyRequired);
/**
*
* A human-friendly operation identifier for the method. For example, you can assign the
* operationName
of ListPets
for the GET /pets
method in PetStore example.
*
*
* @param operationName
* A human-friendly operation identifier for the method. For example, you can assign the
* operationName
of ListPets
for the GET /pets
method in PetStore example.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder operationName(String operationName);
/**
*
* A key-value map defining required or optional method request parameters that can be accepted by Amazon API
* Gateway. A key defines a method request parameter name matching the pattern of
* method.request.{location}.{name}
, where location
is querystring
,
* path
, or header
and name
is a valid and unique parameter name. The
* value associated with the key is a Boolean flag indicating whether the parameter is required (
* true
) or optional (false
). The method request parameter names defined here are
* available in Integration to be mapped to integration request parameters or body-mapping templates.
*
*
* @param requestParameters
* A key-value map defining required or optional method request parameters that can be accepted by Amazon
* API Gateway. A key defines a method request parameter name matching the pattern of
* method.request.{location}.{name}
, where location
is querystring
* , path
, or header
and name
is a valid and unique parameter
* name. The value associated with the key is a Boolean flag indicating whether the parameter is required
* (true
) or optional (false
). The method request parameter names defined here
* are available in Integration to be mapped to integration request parameters or body-mapping
* templates.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder requestParameters(Map requestParameters);
/**
*
* Specifies the Model resources used for the request's content type. Request models are represented as a
* key/value map, with a content type as the key and a Model name as the value.
*
*
* @param requestModels
* Specifies the Model resources used for the request's content type. Request models are
* represented as a key/value map, with a content type as the key and a Model name as the value.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder requestModels(Map requestModels);
/**
*
* The identifier of a RequestValidator for validating the method request.
*
*
* @param requestValidatorId
* The identifier of a RequestValidator for validating the method request.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder requestValidatorId(String requestValidatorId);
@Override
Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig);
}
static final class BuilderImpl extends APIGatewayRequest.BuilderImpl implements Builder {
private String restApiId;
private String resourceId;
private String httpMethod;
private String authorizationType;
private String authorizerId;
private Boolean apiKeyRequired;
private String operationName;
private Map requestParameters;
private Map requestModels;
private String requestValidatorId;
private BuilderImpl() {
}
private BuilderImpl(PutMethodRequest model) {
restApiId(model.restApiId);
resourceId(model.resourceId);
httpMethod(model.httpMethod);
authorizationType(model.authorizationType);
authorizerId(model.authorizerId);
apiKeyRequired(model.apiKeyRequired);
operationName(model.operationName);
requestParameters(model.requestParameters);
requestModels(model.requestModels);
requestValidatorId(model.requestValidatorId);
}
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 getResourceId() {
return resourceId;
}
@Override
public final Builder resourceId(String resourceId) {
this.resourceId = resourceId;
return this;
}
public final void setResourceId(String resourceId) {
this.resourceId = resourceId;
}
public final String getHttpMethod() {
return httpMethod;
}
@Override
public final Builder httpMethod(String httpMethod) {
this.httpMethod = httpMethod;
return this;
}
public final void setHttpMethod(String httpMethod) {
this.httpMethod = httpMethod;
}
public final String getAuthorizationType() {
return authorizationType;
}
@Override
public final Builder authorizationType(String authorizationType) {
this.authorizationType = authorizationType;
return this;
}
public final void setAuthorizationType(String authorizationType) {
this.authorizationType = authorizationType;
}
public final String getAuthorizerId() {
return authorizerId;
}
@Override
public final Builder authorizerId(String authorizerId) {
this.authorizerId = authorizerId;
return this;
}
public final void setAuthorizerId(String authorizerId) {
this.authorizerId = authorizerId;
}
public final Boolean getApiKeyRequired() {
return apiKeyRequired;
}
@Override
public final Builder apiKeyRequired(Boolean apiKeyRequired) {
this.apiKeyRequired = apiKeyRequired;
return this;
}
public final void setApiKeyRequired(Boolean apiKeyRequired) {
this.apiKeyRequired = apiKeyRequired;
}
public final String getOperationName() {
return operationName;
}
@Override
public final Builder operationName(String operationName) {
this.operationName = operationName;
return this;
}
public final void setOperationName(String operationName) {
this.operationName = operationName;
}
public final Map getRequestParameters() {
return requestParameters;
}
@Override
public final Builder requestParameters(Map requestParameters) {
this.requestParameters = MapOfStringToBooleanCopier.copy(requestParameters);
return this;
}
public final void setRequestParameters(Map requestParameters) {
this.requestParameters = MapOfStringToBooleanCopier.copy(requestParameters);
}
public final Map getRequestModels() {
return requestModels;
}
@Override
public final Builder requestModels(Map requestModels) {
this.requestModels = MapOfStringToStringCopier.copy(requestModels);
return this;
}
public final void setRequestModels(Map requestModels) {
this.requestModels = MapOfStringToStringCopier.copy(requestModels);
}
public final String getRequestValidatorId() {
return requestValidatorId;
}
@Override
public final Builder requestValidatorId(String requestValidatorId) {
this.requestValidatorId = requestValidatorId;
return this;
}
public final void setRequestValidatorId(String requestValidatorId) {
this.requestValidatorId = requestValidatorId;
}
@Override
public Builder requestOverrideConfig(AwsRequestOverrideConfig awsRequestOverrideConfig) {
super.requestOverrideConfig(awsRequestOverrideConfig);
return this;
}
@Override
public Builder requestOverrideConfig(Consumer builderConsumer) {
super.requestOverrideConfig(builderConsumer);
return this;
}
@Override
public PutMethodRequest build() {
return new PutMethodRequest(this);
}
}
}