software.amazon.awssdk.services.cloudfront.model.TestResult Maven / Gradle / Ivy
Show all versions of cloudfront Show documentation
/*
* Copyright 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.cloudfront.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains the result of testing a CloudFront function with TestFunction
.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class TestResult implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField FUNCTION_SUMMARY_FIELD = SdkField
. builder(MarshallingType.SDK_POJO)
.memberName("FunctionSummary")
.getter(getter(TestResult::functionSummary))
.setter(setter(Builder::functionSummary))
.constructor(FunctionSummary::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionSummary")
.unmarshallLocationName("FunctionSummary").build()).build();
private static final SdkField COMPUTE_UTILIZATION_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("ComputeUtilization")
.getter(getter(TestResult::computeUtilization))
.setter(setter(Builder::computeUtilization))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ComputeUtilization")
.unmarshallLocationName("ComputeUtilization").build()).build();
private static final SdkField> FUNCTION_EXECUTION_LOGS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("FunctionExecutionLogs")
.getter(getter(TestResult::functionExecutionLogs))
.setter(setter(Builder::functionExecutionLogs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionExecutionLogs")
.unmarshallLocationName("FunctionExecutionLogs").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.STRING)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").unmarshallLocationName("member").build()).build())
.build()).build();
private static final SdkField FUNCTION_ERROR_MESSAGE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FunctionErrorMessage")
.getter(getter(TestResult::functionErrorMessage))
.setter(setter(Builder::functionErrorMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionErrorMessage")
.unmarshallLocationName("FunctionErrorMessage").build()).build();
private static final SdkField FUNCTION_OUTPUT_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FunctionOutput")
.getter(getter(TestResult::functionOutput))
.setter(setter(Builder::functionOutput))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionOutput")
.unmarshallLocationName("FunctionOutput").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FUNCTION_SUMMARY_FIELD,
COMPUTE_UTILIZATION_FIELD, FUNCTION_EXECUTION_LOGS_FIELD, FUNCTION_ERROR_MESSAGE_FIELD, FUNCTION_OUTPUT_FIELD));
private static final long serialVersionUID = 1L;
private final FunctionSummary functionSummary;
private final String computeUtilization;
private final List functionExecutionLogs;
private final String functionErrorMessage;
private final String functionOutput;
private TestResult(BuilderImpl builder) {
this.functionSummary = builder.functionSummary;
this.computeUtilization = builder.computeUtilization;
this.functionExecutionLogs = builder.functionExecutionLogs;
this.functionErrorMessage = builder.functionErrorMessage;
this.functionOutput = builder.functionOutput;
}
/**
*
* Contains configuration information and metadata about the CloudFront function that was tested.
*
*
* @return Contains configuration information and metadata about the CloudFront function that was tested.
*/
public final FunctionSummary functionSummary() {
return functionSummary;
}
/**
*
* The amount of time that the function took to run as a percentage of the maximum allowed time. For example, a
* compute utilization of 35 means that the function completed in 35% of the maximum allowed time.
*
*
* @return The amount of time that the function took to run as a percentage of the maximum allowed time. For
* example, a compute utilization of 35 means that the function completed in 35% of the maximum allowed
* time.
*/
public final String computeUtilization() {
return computeUtilization;
}
/**
* For responses, this returns true if the service returned a value for the FunctionExecutionLogs property. This
* DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the
* property). This is useful because the SDK will never return a null collection or map, but you may need to
* differentiate between the service returning nothing (or null) and the service returning an empty collection or
* map. For requests, this returns true if a value for the property was specified in the request builder, and false
* if a value was not specified.
*/
public final boolean hasFunctionExecutionLogs() {
return functionExecutionLogs != null && !(functionExecutionLogs instanceof SdkAutoConstructList);
}
/**
*
* Contains the log lines that the function wrote (if any) when running the test.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasFunctionExecutionLogs} method.
*
*
* @return Contains the log lines that the function wrote (if any) when running the test.
*/
public final List functionExecutionLogs() {
return functionExecutionLogs;
}
/**
*
* If the result of testing the function was an error, this field contains the error message.
*
*
* @return If the result of testing the function was an error, this field contains the error message.
*/
public final String functionErrorMessage() {
return functionErrorMessage;
}
/**
*
* The event object returned by the function. For more information about the structure of the event object, see Event
* object structure in the Amazon CloudFront Developer Guide.
*
*
* @return The event object returned by the function. For more information about the structure of the event object,
* see Event
* object structure in the Amazon CloudFront Developer Guide.
*/
public final String functionOutput() {
return functionOutput;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(functionSummary());
hashCode = 31 * hashCode + Objects.hashCode(computeUtilization());
hashCode = 31 * hashCode + Objects.hashCode(hasFunctionExecutionLogs() ? functionExecutionLogs() : null);
hashCode = 31 * hashCode + Objects.hashCode(functionErrorMessage());
hashCode = 31 * hashCode + Objects.hashCode(functionOutput());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof TestResult)) {
return false;
}
TestResult other = (TestResult) obj;
return Objects.equals(functionSummary(), other.functionSummary())
&& Objects.equals(computeUtilization(), other.computeUtilization())
&& hasFunctionExecutionLogs() == other.hasFunctionExecutionLogs()
&& Objects.equals(functionExecutionLogs(), other.functionExecutionLogs())
&& Objects.equals(functionErrorMessage(), other.functionErrorMessage())
&& Objects.equals(functionOutput(), other.functionOutput());
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*/
@Override
public final String toString() {
return ToString.builder("TestResult").add("FunctionSummary", functionSummary())
.add("ComputeUtilization", computeUtilization())
.add("FunctionExecutionLogs", functionExecutionLogs() == null ? null : "*** Sensitive Data Redacted ***")
.add("FunctionErrorMessage", functionErrorMessage() == null ? null : "*** Sensitive Data Redacted ***")
.add("FunctionOutput", functionOutput() == null ? null : "*** Sensitive Data Redacted ***").build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FunctionSummary":
return Optional.ofNullable(clazz.cast(functionSummary()));
case "ComputeUtilization":
return Optional.ofNullable(clazz.cast(computeUtilization()));
case "FunctionExecutionLogs":
return Optional.ofNullable(clazz.cast(functionExecutionLogs()));
case "FunctionErrorMessage":
return Optional.ofNullable(clazz.cast(functionErrorMessage()));
case "FunctionOutput":
return Optional.ofNullable(clazz.cast(functionOutput()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function