software.amazon.awssdk.services.medialive.waiters.DefaultMediaLiveWaiter 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.medialive.waiters;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.internal.waiters.WaiterAttribute;
import software.amazon.awssdk.core.retry.backoff.BackoffStrategy;
import software.amazon.awssdk.core.retry.backoff.FixedDelayBackoffStrategy;
import software.amazon.awssdk.core.waiters.Waiter;
import software.amazon.awssdk.core.waiters.WaiterAcceptor;
import software.amazon.awssdk.core.waiters.WaiterOverrideConfiguration;
import software.amazon.awssdk.core.waiters.WaiterResponse;
import software.amazon.awssdk.core.waiters.WaiterState;
import software.amazon.awssdk.services.medialive.MediaLiveClient;
import software.amazon.awssdk.services.medialive.model.DescribeChannelRequest;
import software.amazon.awssdk.services.medialive.model.DescribeChannelResponse;
import software.amazon.awssdk.services.medialive.model.DescribeInputRequest;
import software.amazon.awssdk.services.medialive.model.DescribeInputResponse;
import software.amazon.awssdk.services.medialive.model.DescribeMultiplexRequest;
import software.amazon.awssdk.services.medialive.model.DescribeMultiplexResponse;
import software.amazon.awssdk.services.medialive.model.MediaLiveRequest;
import software.amazon.awssdk.services.medialive.waiters.internal.WaitersRuntime;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.SdkAutoCloseable;
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
@ThreadSafe
final class DefaultMediaLiveWaiter implements MediaLiveWaiter {
private static final WaiterAttribute CLIENT_ATTRIBUTE = new WaiterAttribute<>(SdkAutoCloseable.class);
private final MediaLiveClient client;
private final AttributeMap managedResources;
private final Waiter channelCreatedWaiter;
private final Waiter channelRunningWaiter;
private final Waiter channelStoppedWaiter;
private final Waiter channelDeletedWaiter;
private final Waiter inputAttachedWaiter;
private final Waiter inputDetachedWaiter;
private final Waiter inputDeletedWaiter;
private final Waiter multiplexCreatedWaiter;
private final Waiter multiplexRunningWaiter;
private final Waiter multiplexStoppedWaiter;
private final Waiter multiplexDeletedWaiter;
private DefaultMediaLiveWaiter(DefaultBuilder builder) {
AttributeMap.Builder attributeMapBuilder = AttributeMap.builder();
if (builder.client == null) {
this.client = MediaLiveClient.builder().build();
attributeMapBuilder.put(CLIENT_ATTRIBUTE, this.client);
} else {
this.client = builder.client;
}
managedResources = attributeMapBuilder.build();
this.channelCreatedWaiter = Waiter.builder(DescribeChannelResponse.class).acceptors(channelCreatedWaiterAcceptors())
.overrideConfiguration(channelCreatedWaiterConfig(builder.overrideConfiguration)).build();
this.channelRunningWaiter = Waiter.builder(DescribeChannelResponse.class).acceptors(channelRunningWaiterAcceptors())
.overrideConfiguration(channelRunningWaiterConfig(builder.overrideConfiguration)).build();
this.channelStoppedWaiter = Waiter.builder(DescribeChannelResponse.class).acceptors(channelStoppedWaiterAcceptors())
.overrideConfiguration(channelStoppedWaiterConfig(builder.overrideConfiguration)).build();
this.channelDeletedWaiter = Waiter.builder(DescribeChannelResponse.class).acceptors(channelDeletedWaiterAcceptors())
.overrideConfiguration(channelDeletedWaiterConfig(builder.overrideConfiguration)).build();
this.inputAttachedWaiter = Waiter.builder(DescribeInputResponse.class).acceptors(inputAttachedWaiterAcceptors())
.overrideConfiguration(inputAttachedWaiterConfig(builder.overrideConfiguration)).build();
this.inputDetachedWaiter = Waiter.builder(DescribeInputResponse.class).acceptors(inputDetachedWaiterAcceptors())
.overrideConfiguration(inputDetachedWaiterConfig(builder.overrideConfiguration)).build();
this.inputDeletedWaiter = Waiter.builder(DescribeInputResponse.class).acceptors(inputDeletedWaiterAcceptors())
.overrideConfiguration(inputDeletedWaiterConfig(builder.overrideConfiguration)).build();
this.multiplexCreatedWaiter = Waiter.builder(DescribeMultiplexResponse.class)
.acceptors(multiplexCreatedWaiterAcceptors())
.overrideConfiguration(multiplexCreatedWaiterConfig(builder.overrideConfiguration)).build();
this.multiplexRunningWaiter = Waiter.builder(DescribeMultiplexResponse.class)
.acceptors(multiplexRunningWaiterAcceptors())
.overrideConfiguration(multiplexRunningWaiterConfig(builder.overrideConfiguration)).build();
this.multiplexStoppedWaiter = Waiter.builder(DescribeMultiplexResponse.class)
.acceptors(multiplexStoppedWaiterAcceptors())
.overrideConfiguration(multiplexStoppedWaiterConfig(builder.overrideConfiguration)).build();
this.multiplexDeletedWaiter = Waiter.builder(DescribeMultiplexResponse.class)
.acceptors(multiplexDeletedWaiterAcceptors())
.overrideConfiguration(multiplexDeletedWaiterConfig(builder.overrideConfiguration)).build();
}
private static String errorCode(Throwable error) {
if (error instanceof AwsServiceException) {
return ((AwsServiceException) error).awsErrorDetails().errorCode();
}
return null;
}
@Override
public WaiterResponse waitUntilChannelCreated(DescribeChannelRequest describeChannelRequest) {
return channelCreatedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)));
}
@Override
public WaiterResponse waitUntilChannelCreated(DescribeChannelRequest describeChannelRequest,
WaiterOverrideConfiguration overrideConfig) {
return channelCreatedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)),
channelCreatedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilChannelDeleted(DescribeChannelRequest describeChannelRequest) {
return channelDeletedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)));
}
@Override
public WaiterResponse waitUntilChannelDeleted(DescribeChannelRequest describeChannelRequest,
WaiterOverrideConfiguration overrideConfig) {
return channelDeletedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)),
channelDeletedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilChannelRunning(DescribeChannelRequest describeChannelRequest) {
return channelRunningWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)));
}
@Override
public WaiterResponse waitUntilChannelRunning(DescribeChannelRequest describeChannelRequest,
WaiterOverrideConfiguration overrideConfig) {
return channelRunningWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)),
channelRunningWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilChannelStopped(DescribeChannelRequest describeChannelRequest) {
return channelStoppedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)));
}
@Override
public WaiterResponse waitUntilChannelStopped(DescribeChannelRequest describeChannelRequest,
WaiterOverrideConfiguration overrideConfig) {
return channelStoppedWaiter.run(() -> client.describeChannel(applyWaitersUserAgent(describeChannelRequest)),
channelStoppedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilInputAttached(DescribeInputRequest describeInputRequest) {
return inputAttachedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)));
}
@Override
public WaiterResponse waitUntilInputAttached(DescribeInputRequest describeInputRequest,
WaiterOverrideConfiguration overrideConfig) {
return inputAttachedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)),
inputAttachedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilInputDeleted(DescribeInputRequest describeInputRequest) {
return inputDeletedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)));
}
@Override
public WaiterResponse waitUntilInputDeleted(DescribeInputRequest describeInputRequest,
WaiterOverrideConfiguration overrideConfig) {
return inputDeletedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)),
inputDeletedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilInputDetached(DescribeInputRequest describeInputRequest) {
return inputDetachedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)));
}
@Override
public WaiterResponse waitUntilInputDetached(DescribeInputRequest describeInputRequest,
WaiterOverrideConfiguration overrideConfig) {
return inputDetachedWaiter.run(() -> client.describeInput(applyWaitersUserAgent(describeInputRequest)),
inputDetachedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilMultiplexCreated(DescribeMultiplexRequest describeMultiplexRequest) {
return multiplexCreatedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)));
}
@Override
public WaiterResponse waitUntilMultiplexCreated(DescribeMultiplexRequest describeMultiplexRequest,
WaiterOverrideConfiguration overrideConfig) {
return multiplexCreatedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)),
multiplexCreatedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilMultiplexDeleted(DescribeMultiplexRequest describeMultiplexRequest) {
return multiplexDeletedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)));
}
@Override
public WaiterResponse waitUntilMultiplexDeleted(DescribeMultiplexRequest describeMultiplexRequest,
WaiterOverrideConfiguration overrideConfig) {
return multiplexDeletedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)),
multiplexDeletedWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilMultiplexRunning(DescribeMultiplexRequest describeMultiplexRequest) {
return multiplexRunningWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)));
}
@Override
public WaiterResponse waitUntilMultiplexRunning(DescribeMultiplexRequest describeMultiplexRequest,
WaiterOverrideConfiguration overrideConfig) {
return multiplexRunningWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)),
multiplexRunningWaiterConfig(overrideConfig));
}
@Override
public WaiterResponse waitUntilMultiplexStopped(DescribeMultiplexRequest describeMultiplexRequest) {
return multiplexStoppedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)));
}
@Override
public WaiterResponse waitUntilMultiplexStopped(DescribeMultiplexRequest describeMultiplexRequest,
WaiterOverrideConfiguration overrideConfig) {
return multiplexStoppedWaiter.run(() -> client.describeMultiplex(applyWaitersUserAgent(describeMultiplexRequest)),
multiplexStoppedWaiterConfig(overrideConfig));
}
private static List> channelCreatedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "IDLE");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "CREATING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "CREATE_FAILED");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> channelRunningWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "RUNNING");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "STARTING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> channelStoppedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "IDLE");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "STOPPING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> channelDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETED");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> inputAttachedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "ATTACHED");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DETACHED");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> inputDetachedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DETACHED");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "CREATING");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "ATTACHED");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> inputDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETED");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> multiplexCreatedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "IDLE");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "CREATING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "CREATE_FAILED");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> multiplexRunningWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "RUNNING");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "STARTING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> multiplexStoppedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "IDLE");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "STOPPING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> multiplexDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETED");
}));
result.add(WaiterAcceptor.retryOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("State").value(), "DELETING");
}));
result.add(new WaitersRuntime.ResponseStatusAcceptor(500, WaiterState.RETRY));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static WaiterOverrideConfiguration channelCreatedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(5);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(3)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration channelRunningWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(120);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration channelStoppedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(60);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration channelDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(84);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration inputAttachedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(20);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration inputDetachedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(84);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration inputDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(20);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration multiplexCreatedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(5);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(3)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration multiplexRunningWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(120);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration multiplexStoppedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(28);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration multiplexDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(20);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(5)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
@Override
public void close() {
managedResources.close();
}
public static MediaLiveWaiter.Builder builder() {
return new DefaultBuilder();
}
private T applyWaitersUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version("waiter").name("hll").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
public static final class DefaultBuilder implements MediaLiveWaiter.Builder {
private MediaLiveClient client;
private WaiterOverrideConfiguration overrideConfiguration;
private DefaultBuilder() {
}
@Override
public MediaLiveWaiter.Builder overrideConfiguration(WaiterOverrideConfiguration overrideConfiguration) {
this.overrideConfiguration = overrideConfiguration;
return this;
}
@Override
public MediaLiveWaiter.Builder client(MediaLiveClient client) {
this.client = client;
return this;
}
public MediaLiveWaiter build() {
return new DefaultMediaLiveWaiter(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy