software.amazon.awssdk.services.cloudfront.model.FunctionMetadata 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.time.Instant;
import java.util.Arrays;
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.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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Contains metadata about a CloudFront function.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class FunctionMetadata implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField FUNCTION_ARN_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("FunctionARN")
.getter(getter(FunctionMetadata::functionARN))
.setter(setter(Builder::functionARN))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FunctionARN")
.unmarshallLocationName("FunctionARN").build()).build();
private static final SdkField STAGE_FIELD = SdkField
. builder(MarshallingType.STRING)
.memberName("Stage")
.getter(getter(FunctionMetadata::stageAsString))
.setter(setter(Builder::stage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Stage")
.unmarshallLocationName("Stage").build()).build();
private static final SdkField CREATED_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreatedTime")
.getter(getter(FunctionMetadata::createdTime))
.setter(setter(Builder::createdTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTime")
.unmarshallLocationName("CreatedTime").build()).build();
private static final SdkField LAST_MODIFIED_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("LastModifiedTime")
.getter(getter(FunctionMetadata::lastModifiedTime))
.setter(setter(Builder::lastModifiedTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LastModifiedTime")
.unmarshallLocationName("LastModifiedTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(FUNCTION_ARN_FIELD,
STAGE_FIELD, CREATED_TIME_FIELD, LAST_MODIFIED_TIME_FIELD));
private static final long serialVersionUID = 1L;
private final String functionARN;
private final String stage;
private final Instant createdTime;
private final Instant lastModifiedTime;
private FunctionMetadata(BuilderImpl builder) {
this.functionARN = builder.functionARN;
this.stage = builder.stage;
this.createdTime = builder.createdTime;
this.lastModifiedTime = builder.lastModifiedTime;
}
/**
*
* The Amazon Resource Name (ARN) of the function. The ARN uniquely identifies the function.
*
*
* @return The Amazon Resource Name (ARN) of the function. The ARN uniquely identifies the function.
*/
public final String functionARN() {
return functionARN;
}
/**
*
* The stage that the function is in, either DEVELOPMENT
or LIVE
.
*
*
* When a function is in the DEVELOPMENT
stage, you can test the function with
* TestFunction
, and update it with UpdateFunction
.
*
*
* When a function is in the LIVE
stage, you can attach the function to a distribution's cache
* behavior, using the function's ARN.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #stage} will return
* {@link FunctionStage#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stageAsString}.
*
*
* @return The stage that the function is in, either DEVELOPMENT
or LIVE
.
*
* When a function is in the DEVELOPMENT
stage, you can test the function with
* TestFunction
, and update it with UpdateFunction
.
*
*
* When a function is in the LIVE
stage, you can attach the function to a distribution's cache
* behavior, using the function's ARN.
* @see FunctionStage
*/
public final FunctionStage stage() {
return FunctionStage.fromValue(stage);
}
/**
*
* The stage that the function is in, either DEVELOPMENT
or LIVE
.
*
*
* When a function is in the DEVELOPMENT
stage, you can test the function with
* TestFunction
, and update it with UpdateFunction
.
*
*
* When a function is in the LIVE
stage, you can attach the function to a distribution's cache
* behavior, using the function's ARN.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #stage} will return
* {@link FunctionStage#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stageAsString}.
*
*
* @return The stage that the function is in, either DEVELOPMENT
or LIVE
.
*
* When a function is in the DEVELOPMENT
stage, you can test the function with
* TestFunction
, and update it with UpdateFunction
.
*
*
* When a function is in the LIVE
stage, you can attach the function to a distribution's cache
* behavior, using the function's ARN.
* @see FunctionStage
*/
public final String stageAsString() {
return stage;
}
/**
*
* The date and time when the function was created.
*
*
* @return The date and time when the function was created.
*/
public final Instant createdTime() {
return createdTime;
}
/**
*
* The date and time when the function was most recently updated.
*
*
* @return The date and time when the function was most recently updated.
*/
public final Instant lastModifiedTime() {
return lastModifiedTime;
}
@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(functionARN());
hashCode = 31 * hashCode + Objects.hashCode(stageAsString());
hashCode = 31 * hashCode + Objects.hashCode(createdTime());
hashCode = 31 * hashCode + Objects.hashCode(lastModifiedTime());
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 FunctionMetadata)) {
return false;
}
FunctionMetadata other = (FunctionMetadata) obj;
return Objects.equals(functionARN(), other.functionARN()) && Objects.equals(stageAsString(), other.stageAsString())
&& Objects.equals(createdTime(), other.createdTime())
&& Objects.equals(lastModifiedTime(), other.lastModifiedTime());
}
/**
* 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("FunctionMetadata").add("FunctionARN", functionARN()).add("Stage", stageAsString())
.add("CreatedTime", createdTime()).add("LastModifiedTime", lastModifiedTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "FunctionARN":
return Optional.ofNullable(clazz.cast(functionARN()));
case "Stage":
return Optional.ofNullable(clazz.cast(stageAsString()));
case "CreatedTime":
return Optional.ofNullable(clazz.cast(createdTime()));
case "LastModifiedTime":
return Optional.ofNullable(clazz.cast(lastModifiedTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function