software.amazon.awssdk.services.appstream.model.AppBlock Maven / Gradle / Ivy
Show all versions of appstream 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.appstream.model;
import java.beans.Transient;
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 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;
/**
*
* Describes an app block.
*
*
* App blocks are an Amazon AppStream 2.0 resource that stores the details about the virtual hard disk in an S3 bucket.
* It also stores the setup script with details about how to mount the virtual hard disk. The virtual hard disk includes
* the application binaries and other files necessary to launch your applications. Multiple applications can be assigned
* to a single app block.
*
*
* This is only supported for Elastic fleets.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class AppBlock implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(AppBlock::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Arn")
.getter(getter(AppBlock::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Arn").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("Description").getter(getter(AppBlock::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Description").build()).build();
private static final SdkField DISPLAY_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("DisplayName").getter(getter(AppBlock::displayName)).setter(setter(Builder::displayName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DisplayName").build()).build();
private static final SdkField SOURCE_S3_LOCATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.memberName("SourceS3Location").getter(getter(AppBlock::sourceS3Location)).setter(setter(Builder::sourceS3Location))
.constructor(S3Location::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SourceS3Location").build()).build();
private static final SdkField SETUP_SCRIPT_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("SetupScriptDetails")
.getter(getter(AppBlock::setupScriptDetails)).setter(setter(Builder::setupScriptDetails))
.constructor(ScriptDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SetupScriptDetails").build())
.build();
private static final SdkField CREATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("CreatedTime").getter(getter(AppBlock::createdTime)).setter(setter(Builder::createdTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTime").build()).build();
private static final SdkField POST_SETUP_SCRIPT_DETAILS_FIELD = SdkField
. builder(MarshallingType.SDK_POJO).memberName("PostSetupScriptDetails")
.getter(getter(AppBlock::postSetupScriptDetails)).setter(setter(Builder::postSetupScriptDetails))
.constructor(ScriptDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PostSetupScriptDetails").build())
.build();
private static final SdkField PACKAGING_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("PackagingType").getter(getter(AppBlock::packagingTypeAsString)).setter(setter(Builder::packagingType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PackagingType").build()).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("State")
.getter(getter(AppBlock::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("State").build()).build();
private static final SdkField> APP_BLOCK_ERRORS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("AppBlockErrors")
.getter(getter(AppBlock::appBlockErrors))
.setter(setter(Builder::appBlockErrors))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("AppBlockErrors").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ErrorDetails::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, ARN_FIELD,
DESCRIPTION_FIELD, DISPLAY_NAME_FIELD, SOURCE_S3_LOCATION_FIELD, SETUP_SCRIPT_DETAILS_FIELD, CREATED_TIME_FIELD,
POST_SETUP_SCRIPT_DETAILS_FIELD, PACKAGING_TYPE_FIELD, STATE_FIELD, APP_BLOCK_ERRORS_FIELD));
private static final long serialVersionUID = 1L;
private final String name;
private final String arn;
private final String description;
private final String displayName;
private final S3Location sourceS3Location;
private final ScriptDetails setupScriptDetails;
private final Instant createdTime;
private final ScriptDetails postSetupScriptDetails;
private final String packagingType;
private final String state;
private final List appBlockErrors;
private AppBlock(BuilderImpl builder) {
this.name = builder.name;
this.arn = builder.arn;
this.description = builder.description;
this.displayName = builder.displayName;
this.sourceS3Location = builder.sourceS3Location;
this.setupScriptDetails = builder.setupScriptDetails;
this.createdTime = builder.createdTime;
this.postSetupScriptDetails = builder.postSetupScriptDetails;
this.packagingType = builder.packagingType;
this.state = builder.state;
this.appBlockErrors = builder.appBlockErrors;
}
/**
*
* The name of the app block.
*
*
* @return The name of the app block.
*/
public final String name() {
return name;
}
/**
*
* The ARN of the app block.
*
*
* @return The ARN of the app block.
*/
public final String arn() {
return arn;
}
/**
*
* The description of the app block.
*
*
* @return The description of the app block.
*/
public final String description() {
return description;
}
/**
*
* The display name of the app block.
*
*
* @return The display name of the app block.
*/
public final String displayName() {
return displayName;
}
/**
*
* The source S3 location of the app block.
*
*
* @return The source S3 location of the app block.
*/
public final S3Location sourceS3Location() {
return sourceS3Location;
}
/**
*
* The setup script details of the app block.
*
*
* This only applies to app blocks with PackagingType CUSTOM
.
*
*
* @return The setup script details of the app block.
*
* This only applies to app blocks with PackagingType CUSTOM
.
*/
public final ScriptDetails setupScriptDetails() {
return setupScriptDetails;
}
/**
*
* The created time of the app block.
*
*
* @return The created time of the app block.
*/
public final Instant createdTime() {
return createdTime;
}
/**
*
* The post setup script details of the app block.
*
*
* This only applies to app blocks with PackagingType APPSTREAM2
.
*
*
* @return The post setup script details of the app block.
*
* This only applies to app blocks with PackagingType APPSTREAM2
.
*/
public final ScriptDetails postSetupScriptDetails() {
return postSetupScriptDetails;
}
/**
*
* The packaging type of the app block.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #packagingType}
* will return {@link PackagingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #packagingTypeAsString}.
*
*
* @return The packaging type of the app block.
* @see PackagingType
*/
public final PackagingType packagingType() {
return PackagingType.fromValue(packagingType);
}
/**
*
* The packaging type of the app block.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #packagingType}
* will return {@link PackagingType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #packagingTypeAsString}.
*
*
* @return The packaging type of the app block.
* @see PackagingType
*/
public final String packagingTypeAsString() {
return packagingType;
}
/**
*
* The state of the app block.
*
*
* An app block with AppStream 2.0 packaging will be in the INACTIVE
state if no application package
* (VHD) is assigned to it. After an application package (VHD) is created by an app block builder for an app block,
* it becomes ACTIVE
.
*
*
* Custom app blocks are always in the ACTIVE
state and no action is required to use them.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link AppBlockState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the app block.
*
* An app block with AppStream 2.0 packaging will be in the INACTIVE
state if no application
* package (VHD) is assigned to it. After an application package (VHD) is created by an app block builder
* for an app block, it becomes ACTIVE
.
*
*
* Custom app blocks are always in the ACTIVE
state and no action is required to use them.
* @see AppBlockState
*/
public final AppBlockState state() {
return AppBlockState.fromValue(state);
}
/**
*
* The state of the app block.
*
*
* An app block with AppStream 2.0 packaging will be in the INACTIVE
state if no application package
* (VHD) is assigned to it. After an application package (VHD) is created by an app block builder for an app block,
* it becomes ACTIVE
.
*
*
* Custom app blocks are always in the ACTIVE
state and no action is required to use them.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link AppBlockState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The state of the app block.
*
* An app block with AppStream 2.0 packaging will be in the INACTIVE
state if no application
* package (VHD) is assigned to it. After an application package (VHD) is created by an app block builder
* for an app block, it becomes ACTIVE
.
*
*
* Custom app blocks are always in the ACTIVE
state and no action is required to use them.
* @see AppBlockState
*/
public final String stateAsString() {
return state;
}
/**
* For responses, this returns true if the service returned a value for the AppBlockErrors 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 hasAppBlockErrors() {
return appBlockErrors != null && !(appBlockErrors instanceof SdkAutoConstructList);
}
/**
*
* The errors of the app block.
*
*
* 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 #hasAppBlockErrors} method.
*
*
* @return The errors of the app block.
*/
public final List appBlockErrors() {
return appBlockErrors;
}
@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(name());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(displayName());
hashCode = 31 * hashCode + Objects.hashCode(sourceS3Location());
hashCode = 31 * hashCode + Objects.hashCode(setupScriptDetails());
hashCode = 31 * hashCode + Objects.hashCode(createdTime());
hashCode = 31 * hashCode + Objects.hashCode(postSetupScriptDetails());
hashCode = 31 * hashCode + Objects.hashCode(packagingTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(hasAppBlockErrors() ? appBlockErrors() : 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 AppBlock)) {
return false;
}
AppBlock other = (AppBlock) obj;
return Objects.equals(name(), other.name()) && Objects.equals(arn(), other.arn())
&& Objects.equals(description(), other.description()) && Objects.equals(displayName(), other.displayName())
&& Objects.equals(sourceS3Location(), other.sourceS3Location())
&& Objects.equals(setupScriptDetails(), other.setupScriptDetails())
&& Objects.equals(createdTime(), other.createdTime())
&& Objects.equals(postSetupScriptDetails(), other.postSetupScriptDetails())
&& Objects.equals(packagingTypeAsString(), other.packagingTypeAsString())
&& Objects.equals(stateAsString(), other.stateAsString()) && hasAppBlockErrors() == other.hasAppBlockErrors()
&& Objects.equals(appBlockErrors(), other.appBlockErrors());
}
/**
* 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("AppBlock").add("Name", name()).add("Arn", arn()).add("Description", description())
.add("DisplayName", displayName()).add("SourceS3Location", sourceS3Location())
.add("SetupScriptDetails", setupScriptDetails()).add("CreatedTime", createdTime())
.add("PostSetupScriptDetails", postSetupScriptDetails()).add("PackagingType", packagingTypeAsString())
.add("State", stateAsString()).add("AppBlockErrors", hasAppBlockErrors() ? appBlockErrors() : null).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Arn":
return Optional.ofNullable(clazz.cast(arn()));
case "Description":
return Optional.ofNullable(clazz.cast(description()));
case "DisplayName":
return Optional.ofNullable(clazz.cast(displayName()));
case "SourceS3Location":
return Optional.ofNullable(clazz.cast(sourceS3Location()));
case "SetupScriptDetails":
return Optional.ofNullable(clazz.cast(setupScriptDetails()));
case "CreatedTime":
return Optional.ofNullable(clazz.cast(createdTime()));
case "PostSetupScriptDetails":
return Optional.ofNullable(clazz.cast(postSetupScriptDetails()));
case "PackagingType":
return Optional.ofNullable(clazz.cast(packagingTypeAsString()));
case "State":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "AppBlockErrors":
return Optional.ofNullable(clazz.cast(appBlockErrors()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function