software.amazon.awssdk.services.ivs.model.Stream Maven / Gradle / Ivy
Show all versions of ivs 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.ivs.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.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.core.traits.TimestampFormatTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Specifies a live video stream that has been ingested and distributed.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class Stream implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField CHANNEL_ARN_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("channelArn").getter(getter(Stream::channelArn)).setter(setter(Builder::channelArn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("channelArn").build()).build();
private static final SdkField STREAM_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("streamId").getter(getter(Stream::streamId)).setter(setter(Builder::streamId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("streamId").build()).build();
private static final SdkField PLAYBACK_URL_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("playbackUrl").getter(getter(Stream::playbackUrl)).setter(setter(Builder::playbackUrl))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("playbackUrl").build()).build();
private static final SdkField START_TIME_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("startTime")
.getter(getter(Stream::startTime))
.setter(setter(Builder::startTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("startTime").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField STATE_FIELD = SdkField. builder(MarshallingType.STRING).memberName("state")
.getter(getter(Stream::stateAsString)).setter(setter(Builder::state))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("state").build()).build();
private static final SdkField HEALTH_FIELD = SdkField. builder(MarshallingType.STRING).memberName("health")
.getter(getter(Stream::healthAsString)).setter(setter(Builder::health))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("health").build()).build();
private static final SdkField VIEWER_COUNT_FIELD = SdkField. builder(MarshallingType.LONG)
.memberName("viewerCount").getter(getter(Stream::viewerCount)).setter(setter(Builder::viewerCount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("viewerCount").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(CHANNEL_ARN_FIELD,
STREAM_ID_FIELD, PLAYBACK_URL_FIELD, START_TIME_FIELD, STATE_FIELD, HEALTH_FIELD, VIEWER_COUNT_FIELD));
private static final long serialVersionUID = 1L;
private final String channelArn;
private final String streamId;
private final String playbackUrl;
private final Instant startTime;
private final String state;
private final String health;
private final Long viewerCount;
private Stream(BuilderImpl builder) {
this.channelArn = builder.channelArn;
this.streamId = builder.streamId;
this.playbackUrl = builder.playbackUrl;
this.startTime = builder.startTime;
this.state = builder.state;
this.health = builder.health;
this.viewerCount = builder.viewerCount;
}
/**
*
* Channel ARN for the stream.
*
*
* @return Channel ARN for the stream.
*/
public final String channelArn() {
return channelArn;
}
/**
*
* Unique identifier for a live or previously live stream in the specified channel.
*
*
* @return Unique identifier for a live or previously live stream in the specified channel.
*/
public final String streamId() {
return streamId;
}
/**
*
* URL of the master playlist, required by the video player to play the HLS stream.
*
*
* @return URL of the master playlist, required by the video player to play the HLS stream.
*/
public final String playbackUrl() {
return playbackUrl;
}
/**
*
* Time of the stream’s start. This is an ISO 8601 timestamp; note that this is returned as a string.
*
*
* @return Time of the stream’s start. This is an ISO 8601 timestamp; note that this is returned as a string.
*/
public final Instant startTime() {
return startTime;
}
/**
*
* The stream’s state. Do not rely on the OFFLINE
state, as the API may not return it; instead, a
* "NotBroadcasting" error will indicate that the stream is not live.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link StreamState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The stream’s state. Do not rely on the OFFLINE
state, as the API may not return it; instead,
* a "NotBroadcasting" error will indicate that the stream is not live.
* @see StreamState
*/
public final StreamState state() {
return StreamState.fromValue(state);
}
/**
*
* The stream’s state. Do not rely on the OFFLINE
state, as the API may not return it; instead, a
* "NotBroadcasting" error will indicate that the stream is not live.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #state} will return
* {@link StreamState#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #stateAsString}.
*
*
* @return The stream’s state. Do not rely on the OFFLINE
state, as the API may not return it; instead,
* a "NotBroadcasting" error will indicate that the stream is not live.
* @see StreamState
*/
public final String stateAsString() {
return state;
}
/**
*
* The stream’s health.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #health} will
* return {@link StreamHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #healthAsString}.
*
*
* @return The stream’s health.
* @see StreamHealth
*/
public final StreamHealth health() {
return StreamHealth.fromValue(health);
}
/**
*
* The stream’s health.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #health} will
* return {@link StreamHealth#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #healthAsString}.
*
*
* @return The stream’s health.
* @see StreamHealth
*/
public final String healthAsString() {
return health;
}
/**
*
* A count of concurrent views of the stream. Typically, a new view appears in viewerCount
within 15
* seconds of when video playback starts and a view is removed from viewerCount
within 1 minute of when
* video playback ends. A value of -1 indicates that the request timed out; in this case, retry.
*
*
* @return A count of concurrent views of the stream. Typically, a new view appears in viewerCount
* within 15 seconds of when video playback starts and a view is removed from viewerCount
* within 1 minute of when video playback ends. A value of -1 indicates that the request timed out; in this
* case, retry.
*/
public final Long viewerCount() {
return viewerCount;
}
@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(channelArn());
hashCode = 31 * hashCode + Objects.hashCode(streamId());
hashCode = 31 * hashCode + Objects.hashCode(playbackUrl());
hashCode = 31 * hashCode + Objects.hashCode(startTime());
hashCode = 31 * hashCode + Objects.hashCode(stateAsString());
hashCode = 31 * hashCode + Objects.hashCode(healthAsString());
hashCode = 31 * hashCode + Objects.hashCode(viewerCount());
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 Stream)) {
return false;
}
Stream other = (Stream) obj;
return Objects.equals(channelArn(), other.channelArn()) && Objects.equals(streamId(), other.streamId())
&& Objects.equals(playbackUrl(), other.playbackUrl()) && Objects.equals(startTime(), other.startTime())
&& Objects.equals(stateAsString(), other.stateAsString())
&& Objects.equals(healthAsString(), other.healthAsString()) && Objects.equals(viewerCount(), other.viewerCount());
}
/**
* 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("Stream").add("ChannelArn", channelArn()).add("StreamId", streamId())
.add("PlaybackUrl", playbackUrl()).add("StartTime", startTime()).add("State", stateAsString())
.add("Health", healthAsString()).add("ViewerCount", viewerCount()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "channelArn":
return Optional.ofNullable(clazz.cast(channelArn()));
case "streamId":
return Optional.ofNullable(clazz.cast(streamId()));
case "playbackUrl":
return Optional.ofNullable(clazz.cast(playbackUrl()));
case "startTime":
return Optional.ofNullable(clazz.cast(startTime()));
case "state":
return Optional.ofNullable(clazz.cast(stateAsString()));
case "health":
return Optional.ofNullable(clazz.cast(healthAsString()));
case "viewerCount":
return Optional.ofNullable(clazz.cast(viewerCount()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function