software.amazon.awssdk.services.apigateway.model.PatchOperation 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 javax.annotation.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.core.protocol.ProtocolMarshaller;
import software.amazon.awssdk.core.protocol.StructuredPojo;
import software.amazon.awssdk.services.apigateway.transform.PatchOperationMarshaller;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
* A single patch operation to apply to the specified resource. Please refer to
* http://tools.ietf.org/html/rfc6902#section-4 for an explanation of how each operation is used.
*/
@Generated("software.amazon.awssdk:codegen")
public class PatchOperation implements StructuredPojo, ToCopyableBuilder {
private final String op;
private final String path;
private final String value;
private final String from;
private PatchOperation(BuilderImpl builder) {
this.op = builder.op;
this.path = builder.path;
this.value = builder.value;
this.from = builder.from;
}
/**
*
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends on
* specific operational contexts. Attempts to apply an unsupported operation on a resource will return an error
* message.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #op} will return
* {@link Op#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from {@link #opString}.
*
*
* @return An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends
* on specific operational contexts. Attempts to apply an unsupported operation on a resource will return an
* error message.
* @see Op
*/
public Op op() {
return Op.fromValue(op);
}
/**
*
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends on
* specific operational contexts. Attempts to apply an unsupported operation on a resource will return an error
* message.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #op} will return
* {@link Op#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from {@link #opString}.
*
*
* @return An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends
* on specific operational contexts. Attempts to apply an unsupported operation on a resource will return an
* error message.
* @see Op
*/
public String opString() {
return op;
}
/**
*
* The op
operation's target, as identified by a JSON Pointer value that references a
* location within the targeted resource. For example, if the target resource has an updateable property of
* {"name":"value"}
, the path for this property is /name
. If the name
* property value is a JSON object (e.g., {"name": {"child/name": "child-value"}}
), the path for the
* child/name
property will be /name/child~1name
. Any slash ("/") character appearing in
* path names must be escaped with "~1", as shown in the example above. Each op
operation can have only
* one path
associated with it.
*
*
* @return The op
operation's target, as identified by a JSON Pointer value that
* references a location within the targeted resource. For example, if the target resource has an updateable
* property of {"name":"value"}
, the path for this property is /name
. If the
* name
property value is a JSON object (e.g.,
* {"name": {"child/name": "child-value"}}
), the path for the child/name
property
* will be /name/child~1name
. Any slash ("/") character appearing in path names must be escaped
* with "~1", as shown in the example above. Each op
operation can have only one
* path
associated with it.
*/
public String path() {
return path;
}
/**
*
* The new target value of the update operation. When using AWS CLI to update a property of a JSON value, enclose
* the JSON object with a pair of single quotes in a Linux shell, e.g., '{"a": ...}'. In a Windows shell, see Using JSON for
* Parameters.
*
*
* @return The new target value of the update operation. When using AWS CLI to update a property of a JSON value,
* enclose the JSON object with a pair of single quotes in a Linux shell, e.g., '{"a": ...}'. In a Windows
* shell, see Using
* JSON for Parameters.
*/
public String value() {
return value;
}
/**
*
* Not supported.
*
*
* @return Not supported.
*/
public String from() {
return from;
}
@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(opString());
hashCode = 31 * hashCode + Objects.hashCode(path());
hashCode = 31 * hashCode + Objects.hashCode(value());
hashCode = 31 * hashCode + Objects.hashCode(from());
return hashCode;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof PatchOperation)) {
return false;
}
PatchOperation other = (PatchOperation) obj;
return Objects.equals(opString(), other.opString()) && Objects.equals(path(), other.path())
&& Objects.equals(value(), other.value()) && Objects.equals(from(), other.from());
}
@Override
public String toString() {
return ToString.builder("PatchOperation").add("Op", opString()).add("Path", path()).add("Value", value())
.add("From", from()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "op":
return Optional.of(clazz.cast(opString()));
case "path":
return Optional.of(clazz.cast(path()));
case "value":
return Optional.of(clazz.cast(value()));
case "from":
return Optional.of(clazz.cast(from()));
default:
return Optional.empty();
}
}
@SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
PatchOperationMarshaller.getInstance().marshall(this, protocolMarshaller);
}
public interface Builder extends CopyableBuilder {
/**
*
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends on
* specific operational contexts. Attempts to apply an unsupported operation on a resource will return an error
* message.
*
*
* @param op
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove",
* or "replace". Not all valid operations are supported for a given resource. Support of the operations
* depends on specific operational contexts. Attempts to apply an unsupported operation on a resource
* will return an error message.
* @see Op
* @return Returns a reference to this object so that method calls can be chained together.
* @see Op
*/
Builder op(String op);
/**
*
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove", or
* "replace". Not all valid operations are supported for a given resource. Support of the operations depends on
* specific operational contexts. Attempts to apply an unsupported operation on a resource will return an error
* message.
*
*
* @param op
* An update operation to be performed with this PATCH request. The valid value can be "add", "remove",
* or "replace". Not all valid operations are supported for a given resource. Support of the operations
* depends on specific operational contexts. Attempts to apply an unsupported operation on a resource
* will return an error message.
* @see Op
* @return Returns a reference to this object so that method calls can be chained together.
* @see Op
*/
Builder op(Op op);
/**
*
* The op
operation's target, as identified by a JSON Pointer value that references
* a location within the targeted resource. For example, if the target resource has an updateable property of
* {"name":"value"}
, the path for this property is /name
. If the name
* property value is a JSON object (e.g., {"name": {"child/name": "child-value"}}
), the path for
* the child/name
property will be /name/child~1name
. Any slash ("/") character
* appearing in path names must be escaped with "~1", as shown in the example above. Each op
* operation can have only one path
associated with it.
*
*
* @param path
* The op
operation's target, as identified by a JSON Pointer value that
* references a location within the targeted resource. For example, if the target resource has an
* updateable property of {"name":"value"}
, the path for this property is /name
* . If the name
property value is a JSON object (e.g.,
* {"name": {"child/name": "child-value"}}
), the path for the child/name
* property will be /name/child~1name
. Any slash ("/") character appearing in path names
* must be escaped with "~1", as shown in the example above. Each op
operation can have only
* one path
associated with it.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder path(String path);
/**
*
* The new target value of the update operation. When using AWS CLI to update a property of a JSON value,
* enclose the JSON object with a pair of single quotes in a Linux shell, e.g., '{"a": ...}'. In a Windows
* shell, see Using JSON
* for Parameters.
*
*
* @param value
* The new target value of the update operation. When using AWS CLI to update a property of a JSON value,
* enclose the JSON object with a pair of single quotes in a Linux shell, e.g., '{"a": ...}'. In a
* Windows shell, see Using
* JSON for Parameters.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder value(String value);
/**
*
* Not supported.
*
*
* @param from
* Not supported.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder from(String from);
}
static final class BuilderImpl implements Builder {
private String op;
private String path;
private String value;
private String from;
private BuilderImpl() {
}
private BuilderImpl(PatchOperation model) {
op(model.op);
path(model.path);
value(model.value);
from(model.from);
}
public final String getOp() {
return op;
}
@Override
public final Builder op(String op) {
this.op = op;
return this;
}
@Override
public final Builder op(Op op) {
this.op(op.toString());
return this;
}
public final void setOp(String op) {
this.op = op;
}
public final String getPath() {
return path;
}
@Override
public final Builder path(String path) {
this.path = path;
return this;
}
public final void setPath(String path) {
this.path = path;
}
public final String getValue() {
return value;
}
@Override
public final Builder value(String value) {
this.value = value;
return this;
}
public final void setValue(String value) {
this.value = value;
}
public final String getFrom() {
return from;
}
@Override
public final Builder from(String from) {
this.from = from;
return this;
}
public final void setFrom(String from) {
this.from = from;
}
@Override
public PatchOperation build() {
return new PatchOperation(this);
}
}
}