
software.amazon.awssdk.services.gamelift.model.Script 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.gamelift.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.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;
/**
*
* Properties describing a Realtime script.
*
*
* Related operations
*
*
* -
*
* CreateScript
*
*
* -
*
* ListScripts
*
*
* -
*
* DescribeScript
*
*
* -
*
* UpdateScript
*
*
* -
*
* DeleteScript
*
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Script implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SCRIPT_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Script::scriptId)).setter(setter(Builder::scriptId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScriptId").build()).build();
private static final SdkField SCRIPT_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Script::scriptArn)).setter(setter(Builder::scriptArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ScriptArn").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Script::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField VERSION_FIELD = SdkField. builder(MarshallingType.STRING)
.getter(getter(Script::version)).setter(setter(Builder::version))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Version").build()).build();
private static final SdkField SIZE_ON_DISK_FIELD = SdkField. builder(MarshallingType.LONG)
.getter(getter(Script::sizeOnDisk)).setter(setter(Builder::sizeOnDisk))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SizeOnDisk").build()).build();
private static final SdkField CREATION_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.getter(getter(Script::creationTime)).setter(setter(Builder::creationTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreationTime").build()).build();
private static final SdkField STORAGE_LOCATION_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
.getter(getter(Script::storageLocation)).setter(setter(Builder::storageLocation)).constructor(S3Location::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StorageLocation").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SCRIPT_ID_FIELD,
SCRIPT_ARN_FIELD, NAME_FIELD, VERSION_FIELD, SIZE_ON_DISK_FIELD, CREATION_TIME_FIELD, STORAGE_LOCATION_FIELD));
private static final long serialVersionUID = 1L;
private final String scriptId;
private final String scriptArn;
private final String name;
private final String version;
private final Long sizeOnDisk;
private final Instant creationTime;
private final S3Location storageLocation;
private Script(BuilderImpl builder) {
this.scriptId = builder.scriptId;
this.scriptArn = builder.scriptArn;
this.name = builder.name;
this.version = builder.version;
this.sizeOnDisk = builder.sizeOnDisk;
this.creationTime = builder.creationTime;
this.storageLocation = builder.storageLocation;
}
/**
*
* A unique identifier for a Realtime script
*
*
* @return A unique identifier for a Realtime script
*/
public String scriptId() {
return scriptId;
}
/**
*
* Amazon Resource Name (ARN) that is assigned to a
* GameLift script resource and uniquely identifies it. ARNs are unique across all Regions. In a GameLift script
* ARN, the resource ID matches the ScriptId value.
*
*
* @return Amazon Resource Name (ARN) that is
* assigned to a GameLift script resource and uniquely identifies it. ARNs are unique across all Regions. In
* a GameLift script ARN, the resource ID matches the ScriptId value.
*/
public String scriptArn() {
return scriptArn;
}
/**
*
* A descriptive label that is associated with a script. Script names do not need to be unique.
*
*
* @return A descriptive label that is associated with a script. Script names do not need to be unique.
*/
public String name() {
return name;
}
/**
*
* The version that is associated with a build or script. Version strings do not need to be unique.
*
*
* @return The version that is associated with a build or script. Version strings do not need to be unique.
*/
public String version() {
return version;
}
/**
*
* The file size of the uploaded Realtime script, expressed in bytes. When files are uploaded from an S3 location,
* this value remains at "0".
*
*
* @return The file size of the uploaded Realtime script, expressed in bytes. When files are uploaded from an S3
* location, this value remains at "0".
*/
public Long sizeOnDisk() {
return sizeOnDisk;
}
/**
*
* A time stamp indicating when this data object was created. The format is a number expressed in Unix time as
* milliseconds (for example "1469498468.057").
*
*
* @return A time stamp indicating when this data object was created. The format is a number expressed in Unix time
* as milliseconds (for example "1469498468.057").
*/
public Instant creationTime() {
return creationTime;
}
/**
* Returns the value of the StorageLocation property for this object.
*
* @return The value of the StorageLocation property for this object.
*/
public S3Location storageLocation() {
return storageLocation;
}
@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 int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode + Objects.hashCode(scriptId());
hashCode = 31 * hashCode + Objects.hashCode(scriptArn());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(version());
hashCode = 31 * hashCode + Objects.hashCode(sizeOnDisk());
hashCode = 31 * hashCode + Objects.hashCode(creationTime());
hashCode = 31 * hashCode + Objects.hashCode(storageLocation());
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 Script)) {
return false;
}
Script other = (Script) obj;
return Objects.equals(scriptId(), other.scriptId()) && Objects.equals(scriptArn(), other.scriptArn())
&& Objects.equals(name(), other.name()) && Objects.equals(version(), other.version())
&& Objects.equals(sizeOnDisk(), other.sizeOnDisk()) && Objects.equals(creationTime(), other.creationTime())
&& Objects.equals(storageLocation(), other.storageLocation());
}
/**
* 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("Script").add("ScriptId", scriptId()).add("ScriptArn", scriptArn()).add("Name", name())
.add("Version", version()).add("SizeOnDisk", sizeOnDisk()).add("CreationTime", creationTime())
.add("StorageLocation", storageLocation()).build();
}
public Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ScriptId":
return Optional.ofNullable(clazz.cast(scriptId()));
case "ScriptArn":
return Optional.ofNullable(clazz.cast(scriptArn()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Version":
return Optional.ofNullable(clazz.cast(version()));
case "SizeOnDisk":
return Optional.ofNullable(clazz.cast(sizeOnDisk()));
case "CreationTime":
return Optional.ofNullable(clazz.cast(creationTime()));
case "StorageLocation":
return Optional.ofNullable(clazz.cast(storageLocation()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function