All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.ecr.model.LifecyclePolicyPreviewResult Maven / Gradle / Ivy

/*
 * 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.ecr.model;

import java.io.Serializable;
import java.time.Instant;
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;

/**
 * 

* The result of the lifecycle policy preview. *

*/ @Generated("software.amazon.awssdk:codegen") public final class LifecyclePolicyPreviewResult implements SdkPojo, Serializable, ToCopyableBuilder { private static final SdkField> IMAGE_TAGS_FIELD = SdkField .> builder(MarshallingType.LIST) .memberName("imageTags") .getter(getter(LifecyclePolicyPreviewResult::imageTags)) .setter(setter(Builder::imageTags)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("imageTags").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField. builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField IMAGE_DIGEST_FIELD = SdkField. builder(MarshallingType.STRING) .memberName("imageDigest").getter(getter(LifecyclePolicyPreviewResult::imageDigest)) .setter(setter(Builder::imageDigest)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("imageDigest").build()).build(); private static final SdkField IMAGE_PUSHED_AT_FIELD = SdkField. builder(MarshallingType.INSTANT) .memberName("imagePushedAt").getter(getter(LifecyclePolicyPreviewResult::imagePushedAt)) .setter(setter(Builder::imagePushedAt)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("imagePushedAt").build()).build(); private static final SdkField ACTION_FIELD = SdkField . builder(MarshallingType.SDK_POJO).memberName("action") .getter(getter(LifecyclePolicyPreviewResult::action)).setter(setter(Builder::action)) .constructor(LifecyclePolicyRuleAction::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("action").build()).build(); private static final SdkField APPLIED_RULE_PRIORITY_FIELD = SdkField. builder(MarshallingType.INTEGER) .memberName("appliedRulePriority").getter(getter(LifecyclePolicyPreviewResult::appliedRulePriority)) .setter(setter(Builder::appliedRulePriority)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("appliedRulePriority").build()) .build(); private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(IMAGE_TAGS_FIELD, IMAGE_DIGEST_FIELD, IMAGE_PUSHED_AT_FIELD, ACTION_FIELD, APPLIED_RULE_PRIORITY_FIELD)); private static final long serialVersionUID = 1L; private final List imageTags; private final String imageDigest; private final Instant imagePushedAt; private final LifecyclePolicyRuleAction action; private final Integer appliedRulePriority; private LifecyclePolicyPreviewResult(BuilderImpl builder) { this.imageTags = builder.imageTags; this.imageDigest = builder.imageDigest; this.imagePushedAt = builder.imagePushedAt; this.action = builder.action; this.appliedRulePriority = builder.appliedRulePriority; } /** * Returns true if the ImageTags property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public boolean hasImageTags() { return imageTags != null && !(imageTags instanceof SdkAutoConstructList); } /** *

* The list of tags associated with this image. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* You can use {@link #hasImageTags()} to see if a value was sent in this field. *

* * @return The list of tags associated with this image. */ public List imageTags() { return imageTags; } /** *

* The sha256 digest of the image manifest. *

* * @return The sha256 digest of the image manifest. */ public String imageDigest() { return imageDigest; } /** *

* The date and time, expressed in standard JavaScript date format, at which the current image was pushed to the * repository. *

* * @return The date and time, expressed in standard JavaScript date format, at which the current image was pushed to * the repository. */ public Instant imagePushedAt() { return imagePushedAt; } /** *

* The type of action to be taken. *

* * @return The type of action to be taken. */ public LifecyclePolicyRuleAction action() { return action; } /** *

* The priority of the applied rule. *

* * @return The priority of the applied rule. */ public Integer appliedRulePriority() { return appliedRulePriority; } @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(hasImageTags() ? imageTags() : null); hashCode = 31 * hashCode + Objects.hashCode(imageDigest()); hashCode = 31 * hashCode + Objects.hashCode(imagePushedAt()); hashCode = 31 * hashCode + Objects.hashCode(action()); hashCode = 31 * hashCode + Objects.hashCode(appliedRulePriority()); return hashCode; } @Override public boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof LifecyclePolicyPreviewResult)) { return false; } LifecyclePolicyPreviewResult other = (LifecyclePolicyPreviewResult) obj; return hasImageTags() == other.hasImageTags() && Objects.equals(imageTags(), other.imageTags()) && Objects.equals(imageDigest(), other.imageDigest()) && Objects.equals(imagePushedAt(), other.imagePushedAt()) && Objects.equals(action(), other.action()) && Objects.equals(appliedRulePriority(), other.appliedRulePriority()); } /** * 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 String toString() { return ToString.builder("LifecyclePolicyPreviewResult").add("ImageTags", hasImageTags() ? imageTags() : null) .add("ImageDigest", imageDigest()).add("ImagePushedAt", imagePushedAt()).add("Action", action()) .add("AppliedRulePriority", appliedRulePriority()).build(); } public Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "imageTags": return Optional.ofNullable(clazz.cast(imageTags())); case "imageDigest": return Optional.ofNullable(clazz.cast(imageDigest())); case "imagePushedAt": return Optional.ofNullable(clazz.cast(imagePushedAt())); case "action": return Optional.ofNullable(clazz.cast(action())); case "appliedRulePriority": return Optional.ofNullable(clazz.cast(appliedRulePriority())); default: return Optional.empty(); } } @Override public List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((LifecyclePolicyPreviewResult) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder { /** *

* The list of tags associated with this image. *

* * @param imageTags * The list of tags associated with this image. * @return Returns a reference to this object so that method calls can be chained together. */ Builder imageTags(Collection imageTags); /** *

* The list of tags associated with this image. *

* * @param imageTags * The list of tags associated with this image. * @return Returns a reference to this object so that method calls can be chained together. */ Builder imageTags(String... imageTags); /** *

* The sha256 digest of the image manifest. *

* * @param imageDigest * The sha256 digest of the image manifest. * @return Returns a reference to this object so that method calls can be chained together. */ Builder imageDigest(String imageDigest); /** *

* The date and time, expressed in standard JavaScript date format, at which the current image was pushed to the * repository. *

* * @param imagePushedAt * The date and time, expressed in standard JavaScript date format, at which the current image was pushed * to the repository. * @return Returns a reference to this object so that method calls can be chained together. */ Builder imagePushedAt(Instant imagePushedAt); /** *

* The type of action to be taken. *

* * @param action * The type of action to be taken. * @return Returns a reference to this object so that method calls can be chained together. */ Builder action(LifecyclePolicyRuleAction action); /** *

* The type of action to be taken. *

* This is a convenience that creates an instance of the {@link LifecyclePolicyRuleAction.Builder} avoiding the * need to create one manually via {@link LifecyclePolicyRuleAction#builder()}. * * When the {@link Consumer} completes, {@link LifecyclePolicyRuleAction.Builder#build()} is called immediately * and its result is passed to {@link #action(LifecyclePolicyRuleAction)}. * * @param action * a consumer that will call methods on {@link LifecyclePolicyRuleAction.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #action(LifecyclePolicyRuleAction) */ default Builder action(Consumer action) { return action(LifecyclePolicyRuleAction.builder().applyMutation(action).build()); } /** *

* The priority of the applied rule. *

* * @param appliedRulePriority * The priority of the applied rule. * @return Returns a reference to this object so that method calls can be chained together. */ Builder appliedRulePriority(Integer appliedRulePriority); } static final class BuilderImpl implements Builder { private List imageTags = DefaultSdkAutoConstructList.getInstance(); private String imageDigest; private Instant imagePushedAt; private LifecyclePolicyRuleAction action; private Integer appliedRulePriority; private BuilderImpl() { } private BuilderImpl(LifecyclePolicyPreviewResult model) { imageTags(model.imageTags); imageDigest(model.imageDigest); imagePushedAt(model.imagePushedAt); action(model.action); appliedRulePriority(model.appliedRulePriority); } public final Collection getImageTags() { if (imageTags instanceof SdkAutoConstructList) { return null; } return imageTags; } @Override public final Builder imageTags(Collection imageTags) { this.imageTags = ImageTagListCopier.copy(imageTags); return this; } @Override @SafeVarargs public final Builder imageTags(String... imageTags) { imageTags(Arrays.asList(imageTags)); return this; } public final void setImageTags(Collection imageTags) { this.imageTags = ImageTagListCopier.copy(imageTags); } public final String getImageDigest() { return imageDigest; } @Override public final Builder imageDigest(String imageDigest) { this.imageDigest = imageDigest; return this; } public final void setImageDigest(String imageDigest) { this.imageDigest = imageDigest; } public final Instant getImagePushedAt() { return imagePushedAt; } @Override public final Builder imagePushedAt(Instant imagePushedAt) { this.imagePushedAt = imagePushedAt; return this; } public final void setImagePushedAt(Instant imagePushedAt) { this.imagePushedAt = imagePushedAt; } public final LifecyclePolicyRuleAction.Builder getAction() { return action != null ? action.toBuilder() : null; } @Override public final Builder action(LifecyclePolicyRuleAction action) { this.action = action; return this; } public final void setAction(LifecyclePolicyRuleAction.BuilderImpl action) { this.action = action != null ? action.build() : null; } public final Integer getAppliedRulePriority() { return appliedRulePriority; } @Override public final Builder appliedRulePriority(Integer appliedRulePriority) { this.appliedRulePriority = appliedRulePriority; return this; } public final void setAppliedRulePriority(Integer appliedRulePriority) { this.appliedRulePriority = appliedRulePriority; } @Override public LifecyclePolicyPreviewResult build() { return new LifecyclePolicyPreviewResult(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy