software.amazon.awssdk.services.inspector.model.AssessmentRunAgent Maven / Gradle / Ivy
Show all versions of inspector 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.inspector.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 java.util.stream.Collectors;
import java.util.stream.Stream;
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 information about an Amazon Inspector agent. This data type is used as a response element in the
* ListAssessmentRunAgents action.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AssessmentRunAgent implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField AGENT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("agentId").getter(getter(AssessmentRunAgent::agentId)).setter(setter(Builder::agentId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("agentId").build()).build();
private static final SdkField ASSESSMENT_RUN_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("assessmentRunArn").getter(getter(AssessmentRunAgent::assessmentRunArn))
.setter(setter(Builder::assessmentRunArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("assessmentRunArn").build()).build();
private static final SdkField AGENT_HEALTH_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("agentHealth").getter(getter(AssessmentRunAgent::agentHealthAsString))
.setter(setter(Builder::agentHealth))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("agentHealth").build()).build();
private static final SdkField AGENT_HEALTH_CODE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("agentHealthCode").getter(getter(AssessmentRunAgent::agentHealthCodeAsString))
.setter(setter(Builder::agentHealthCode))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("agentHealthCode").build()).build();
private static final SdkField AGENT_HEALTH_DETAILS_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("agentHealthDetails").getter(getter(AssessmentRunAgent::agentHealthDetails))
.setter(setter(Builder::agentHealthDetails))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("agentHealthDetails").build())
.build();
private static final SdkField AUTO_SCALING_GROUP_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("autoScalingGroup").getter(getter(AssessmentRunAgent::autoScalingGroup))
.setter(setter(Builder::autoScalingGroup))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("autoScalingGroup").build()).build();
private static final SdkField> TELEMETRY_METADATA_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("telemetryMetadata")
.getter(getter(AssessmentRunAgent::telemetryMetadata))
.setter(setter(Builder::telemetryMetadata))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("telemetryMetadata").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(TelemetryMetadata::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(AGENT_ID_FIELD,
ASSESSMENT_RUN_ARN_FIELD, AGENT_HEALTH_FIELD, AGENT_HEALTH_CODE_FIELD, AGENT_HEALTH_DETAILS_FIELD,
AUTO_SCALING_GROUP_FIELD, TELEMETRY_METADATA_FIELD));
private static final long serialVersionUID = 1L;
private final String agentId;
private final String assessmentRunArn;
private final String agentHealth;
private final String agentHealthCode;
private final String agentHealthDetails;
private final String autoScalingGroup;
private final List telemetryMetadata;
private AssessmentRunAgent(BuilderImpl builder) {
this.agentId = builder.agentId;
this.assessmentRunArn = builder.assessmentRunArn;
this.agentHealth = builder.agentHealth;
this.agentHealthCode = builder.agentHealthCode;
this.agentHealthDetails = builder.agentHealthDetails;
this.autoScalingGroup = builder.autoScalingGroup;
this.telemetryMetadata = builder.telemetryMetadata;
}
/**
*
* The AWS account of the EC2 instance where the agent is installed.
*
*
* @return The AWS account of the EC2 instance where the agent is installed.
*/
public final String agentId() {
return agentId;
}
/**
*
* The ARN of the assessment run that is associated with the agent.
*
*
* @return The ARN of the assessment run that is associated with the agent.
*/
public final String assessmentRunArn() {
return assessmentRunArn;
}
/**
*
* The current health state of the agent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #agentHealth} will
* return {@link AgentHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #agentHealthAsString}.
*
*
* @return The current health state of the agent.
* @see AgentHealth
*/
public final AgentHealth agentHealth() {
return AgentHealth.fromValue(agentHealth);
}
/**
*
* The current health state of the agent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #agentHealth} will
* return {@link AgentHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #agentHealthAsString}.
*
*
* @return The current health state of the agent.
* @see AgentHealth
*/
public final String agentHealthAsString() {
return agentHealth;
}
/**
*
* The detailed health state of the agent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #agentHealthCode}
* will return {@link AgentHealthCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #agentHealthCodeAsString}.
*
*
* @return The detailed health state of the agent.
* @see AgentHealthCode
*/
public final AgentHealthCode agentHealthCode() {
return AgentHealthCode.fromValue(agentHealthCode);
}
/**
*
* The detailed health state of the agent.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #agentHealthCode}
* will return {@link AgentHealthCode#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #agentHealthCodeAsString}.
*
*
* @return The detailed health state of the agent.
* @see AgentHealthCode
*/
public final String agentHealthCodeAsString() {
return agentHealthCode;
}
/**
*
* The description for the agent health code.
*
*
* @return The description for the agent health code.
*/
public final String agentHealthDetails() {
return agentHealthDetails;
}
/**
*
* The Auto Scaling group of the EC2 instance that is specified by the agent ID.
*
*
* @return The Auto Scaling group of the EC2 instance that is specified by the agent ID.
*/
public final String autoScalingGroup() {
return autoScalingGroup;
}
/**
* For responses, this returns true if the service returned a value for the TelemetryMetadata 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 hasTelemetryMetadata() {
return telemetryMetadata != null && !(telemetryMetadata instanceof SdkAutoConstructList);
}
/**
*
* The Amazon Inspector application data metrics that are collected by the agent.
*
*
* 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 #hasTelemetryMetadata} method.
*
*
* @return The Amazon Inspector application data metrics that are collected by the agent.
*/
public final List telemetryMetadata() {
return telemetryMetadata;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(agentId());
hashCode = 31 * hashCode + Objects.hashCode(assessmentRunArn());
hashCode = 31 * hashCode + Objects.hashCode(agentHealthAsString());
hashCode = 31 * hashCode + Objects.hashCode(agentHealthCodeAsString());
hashCode = 31 * hashCode + Objects.hashCode(agentHealthDetails());
hashCode = 31 * hashCode + Objects.hashCode(autoScalingGroup());
hashCode = 31 * hashCode + Objects.hashCode(hasTelemetryMetadata() ? telemetryMetadata() : null);
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 AssessmentRunAgent)) {
return false;
}
AssessmentRunAgent other = (AssessmentRunAgent) obj;
return Objects.equals(agentId(), other.agentId()) && Objects.equals(assessmentRunArn(), other.assessmentRunArn())
&& Objects.equals(agentHealthAsString(), other.agentHealthAsString())
&& Objects.equals(agentHealthCodeAsString(), other.agentHealthCodeAsString())
&& Objects.equals(agentHealthDetails(), other.agentHealthDetails())
&& Objects.equals(autoScalingGroup(), other.autoScalingGroup())
&& hasTelemetryMetadata() == other.hasTelemetryMetadata()
&& Objects.equals(telemetryMetadata(), other.telemetryMetadata());
}
/**
* 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("AssessmentRunAgent").add("AgentId", agentId()).add("AssessmentRunArn", assessmentRunArn())
.add("AgentHealth", agentHealthAsString()).add("AgentHealthCode", agentHealthCodeAsString())
.add("AgentHealthDetails", agentHealthDetails()).add("AutoScalingGroup", autoScalingGroup())
.add("TelemetryMetadata", hasTelemetryMetadata() ? telemetryMetadata() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "agentId":
return Optional.ofNullable(clazz.cast(agentId()));
case "assessmentRunArn":
return Optional.ofNullable(clazz.cast(assessmentRunArn()));
case "agentHealth":
return Optional.ofNullable(clazz.cast(agentHealthAsString()));
case "agentHealthCode":
return Optional.ofNullable(clazz.cast(agentHealthCodeAsString()));
case "agentHealthDetails":
return Optional.ofNullable(clazz.cast(agentHealthDetails()));
case "autoScalingGroup":
return Optional.ofNullable(clazz.cast(autoScalingGroup()));
case "telemetryMetadata":
return Optional.ofNullable(clazz.cast(telemetryMetadata()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function