
software.amazon.awssdk.services.ssmsap.model.OperationEvent 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.ssmsap.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* An operation event returns details for an operation, including key milestones which can be used to monitor and track
* operations in progress.
*
*
* Operation events contain:
*
*
* -
*
* Description string
*
*
* -
*
* Resource, including its ARN and type
*
*
* -
*
* Status
*
*
* -
*
* StatusMessage string
*
*
* -
*
* TimeStamp
*
*
*
*
* Operation event examples include StartApplication or StopApplication.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class OperationEvent implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(OperationEvent::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField RESOURCE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("Resource").getter(getter(OperationEvent::resource)).setter(setter(Builder::resource))
.constructor(Resource::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Resource").build()).build();
private static final SdkField STATUS_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Status")
.getter(getter(OperationEvent::statusAsString)).setter(setter(Builder::status))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Status").build()).build();
private static final SdkField STATUS_MESSAGE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("StatusMessage").getter(getter(OperationEvent::statusMessage)).setter(setter(Builder::statusMessage))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StatusMessage").build()).build();
private static final SdkField TIMESTAMP_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("Timestamp").getter(getter(OperationEvent::timestamp)).setter(setter(Builder::timestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Timestamp").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(DESCRIPTION_FIELD,
RESOURCE_FIELD, STATUS_FIELD, STATUS_MESSAGE_FIELD, TIMESTAMP_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("Description", DESCRIPTION_FIELD);
put("Resource", RESOURCE_FIELD);
put("Status", STATUS_FIELD);
put("StatusMessage", STATUS_MESSAGE_FIELD);
put("Timestamp", TIMESTAMP_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String description;
private final Resource resource;
private final String status;
private final String statusMessage;
private final Instant timestamp;
private OperationEvent(BuilderImpl builder) {
this.description = builder.description;
this.resource = builder.resource;
this.status = builder.status;
this.statusMessage = builder.statusMessage;
this.timestamp = builder.timestamp;
}
/**
*
* A description of the operation event. For example, "Stop the EC2 instance i-abcdefgh987654321".
*
*
* @return A description of the operation event. For example, "Stop the EC2 instance i-abcdefgh987654321".
*/
public final String description() {
return description;
}
/**
*
* The resource involved in the operations event.
*
*
* Contains ResourceArn
ARN and ResourceType
.
*
*
* @return The resource involved in the operations event.
*
* Contains ResourceArn
ARN and ResourceType
.
*/
public final Resource resource() {
return resource;
}
/**
*
* The status of the operation event. The possible statuses are: IN_PROGRESS
, COMPLETED
,
* and FAILED
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link OperationEventStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the operation event. The possible statuses are: IN_PROGRESS
,
* COMPLETED
, and FAILED
.
* @see OperationEventStatus
*/
public final OperationEventStatus status() {
return OperationEventStatus.fromValue(status);
}
/**
*
* The status of the operation event. The possible statuses are: IN_PROGRESS
, COMPLETED
,
* and FAILED
.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #status} will
* return {@link OperationEventStatus#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available
* from {@link #statusAsString}.
*
*
* @return The status of the operation event. The possible statuses are: IN_PROGRESS
,
* COMPLETED
, and FAILED
.
* @see OperationEventStatus
*/
public final String statusAsString() {
return status;
}
/**
*
* The status message relating to a specific operation event.
*
*
* @return The status message relating to a specific operation event.
*/
public final String statusMessage() {
return statusMessage;
}
/**
*
* The timestamp of the specified operation event.
*
*
* @return The timestamp of the specified operation event.
*/
public final Instant timestamp() {
return timestamp;
}
@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(description());
hashCode = 31 * hashCode + Objects.hashCode(resource());
hashCode = 31 * hashCode + Objects.hashCode(statusAsString());
hashCode = 31 * hashCode + Objects.hashCode(statusMessage());
hashCode = 31 * hashCode + Objects.hashCode(timestamp());
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 OperationEvent)) {
return false;
}
OperationEvent other = (OperationEvent) obj;
return Objects.equals(description(), other.description()) && Objects.equals(resource(), other.resource())
&& Objects.equals(statusAsString(), other.statusAsString())
&& Objects.equals(statusMessage(), other.statusMessage()) && Objects.equals(timestamp(), other.timestamp());
}
/**
* 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("OperationEvent").add("Description", description()).add("Resource", resource())
.add("Status", statusAsString()).add("StatusMessage", statusMessage()).add("Timestamp", timestamp()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "Resource":
return Optional.ofNullable(clazz.cast(resource()));
case "Status":
return Optional.ofNullable(clazz.cast(statusAsString()));
case "StatusMessage":
return Optional.ofNullable(clazz.cast(statusMessage()));
case "Timestamp":
return Optional.ofNullable(clazz.cast(timestamp()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function