
com.oracle.bmc.mysql.DbSystemWaiters Maven / Gradle / Ivy
/**
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
*/
package com.oracle.bmc.mysql;
import com.oracle.bmc.mysql.requests.*;
import com.oracle.bmc.mysql.responses.*;
/**
* Collection of helper methods to produce {@link com.oracle.bmc.waiter.Waiter}s for different
* resources of DbSystem.
*
* The default configuration used is defined by {@link com.oracle.bmc.waiter.Waiters.Waiters#DEFAULT_POLLING_WAITER}.
*/
@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20190415")
@lombok.RequiredArgsConstructor
public class DbSystemWaiters {
private final java.util.concurrent.ExecutorService executorService;
private final DbSystem client;
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the default configuration.
*
* @param request the request to send
* @param targetStates the desired states to wait for. If multiple states are provided then the waiter will return once the resource reaches any of the provided states
* @return a new {@code Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter
forAnalyticsCluster(
GetAnalyticsClusterRequest request,
com.oracle.bmc.mysql.model.AnalyticsCluster.LifecycleState... targetStates) {
org.apache.commons.lang3.Validate.notEmpty(
targetStates, "At least one targetState must be provided");
org.apache.commons.lang3.Validate.noNullElements(
targetStates, "Null targetState values are not permitted");
return forAnalyticsCluster(
com.oracle.bmc.waiter.Waiters.DEFAULT_POLLING_WAITER, request, targetStates);
}
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the provided configuration.
*
* @param request the request to send
* @param targetState the desired state to wait for
* @param terminationStrategy the {@link com.oracle.bmc.waiter.TerminationStrategy} to use
* @param delayStrategy the {@link com.oracle.bmc.waiter.DelayStrategy} to use
* @return a new {@code com.oracle.bmc.waiter.Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter
forAnalyticsCluster(
GetAnalyticsClusterRequest request,
com.oracle.bmc.mysql.model.AnalyticsCluster.LifecycleState targetState,
com.oracle.bmc.waiter.TerminationStrategy terminationStrategy,
com.oracle.bmc.waiter.DelayStrategy delayStrategy) {
org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null");
return forAnalyticsCluster(
com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy),
request,
targetState);
}
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the provided configuration.
*
* @param request the request to send
* @param terminationStrategy the {@link com.oracle.bmc.waiter.TerminationStrategy} to use
* @param delayStrategy the {@link com.oracle.bmc.waiter.DelayStrategy} to use
* @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states
* @return a new {@code com.oracle.bmc.waiter.Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter
forAnalyticsCluster(
GetAnalyticsClusterRequest request,
com.oracle.bmc.waiter.TerminationStrategy terminationStrategy,
com.oracle.bmc.waiter.DelayStrategy delayStrategy,
com.oracle.bmc.mysql.model.AnalyticsCluster.LifecycleState... targetStates) {
org.apache.commons.lang3.Validate.notEmpty(
targetStates, "At least one target state must be provided");
org.apache.commons.lang3.Validate.noNullElements(
targetStates, "Null target states are not permitted");
return forAnalyticsCluster(
com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy),
request,
targetStates);
}
// Helper method to create a new Waiter for AnalyticsCluster.
private com.oracle.bmc.waiter.Waiter
forAnalyticsCluster(
com.oracle.bmc.waiter.BmcGenericWaiter waiter,
final GetAnalyticsClusterRequest request,
final com.oracle.bmc.mysql.model.AnalyticsCluster.LifecycleState...
targetStates) {
final java.util.Set
targetStatesSet = new java.util.HashSet<>(java.util.Arrays.asList(targetStates));
return new com.oracle.bmc.waiter.internal.SimpleWaiterImpl<>(
executorService,
waiter.toCallable(
com.google.common.base.Suppliers.ofInstance(request),
new com.google.common.base.Function<
GetAnalyticsClusterRequest, GetAnalyticsClusterResponse>() {
@Override
public GetAnalyticsClusterResponse apply(
GetAnalyticsClusterRequest request) {
return client.getAnalyticsCluster(request);
}
},
new com.google.common.base.Predicate() {
@Override
public boolean apply(GetAnalyticsClusterResponse response) {
return targetStatesSet.contains(
response.getAnalyticsCluster().getLifecycleState());
}
},
targetStatesSet.contains(
com.oracle.bmc.mysql.model.AnalyticsCluster.LifecycleState
.Deleted)),
request);
}
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the default configuration.
*
* @param request the request to send
* @param targetStates the desired states to wait for. If multiple states are provided then the waiter will return once the resource reaches any of the provided states
* @return a new {@code Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter forDbSystem(
GetDbSystemRequest request,
com.oracle.bmc.mysql.model.DbSystem.LifecycleState... targetStates) {
org.apache.commons.lang3.Validate.notEmpty(
targetStates, "At least one targetState must be provided");
org.apache.commons.lang3.Validate.noNullElements(
targetStates, "Null targetState values are not permitted");
return forDbSystem(
com.oracle.bmc.waiter.Waiters.DEFAULT_POLLING_WAITER, request, targetStates);
}
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the provided configuration.
*
* @param request the request to send
* @param targetState the desired state to wait for
* @param terminationStrategy the {@link com.oracle.bmc.waiter.TerminationStrategy} to use
* @param delayStrategy the {@link com.oracle.bmc.waiter.DelayStrategy} to use
* @return a new {@code com.oracle.bmc.waiter.Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter forDbSystem(
GetDbSystemRequest request,
com.oracle.bmc.mysql.model.DbSystem.LifecycleState targetState,
com.oracle.bmc.waiter.TerminationStrategy terminationStrategy,
com.oracle.bmc.waiter.DelayStrategy delayStrategy) {
org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null");
return forDbSystem(
com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy),
request,
targetState);
}
/**
* Creates a new {@link com.oracle.bmc.waiter.Waiter} using the provided configuration.
*
* @param request the request to send
* @param terminationStrategy the {@link com.oracle.bmc.waiter.TerminationStrategy} to use
* @param delayStrategy the {@link com.oracle.bmc.waiter.DelayStrategy} to use
* @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states
* @return a new {@code com.oracle.bmc.waiter.Waiter} instance
*/
public com.oracle.bmc.waiter.Waiter forDbSystem(
GetDbSystemRequest request,
com.oracle.bmc.waiter.TerminationStrategy terminationStrategy,
com.oracle.bmc.waiter.DelayStrategy delayStrategy,
com.oracle.bmc.mysql.model.DbSystem.LifecycleState... targetStates) {
org.apache.commons.lang3.Validate.notEmpty(
targetStates, "At least one target state must be provided");
org.apache.commons.lang3.Validate.noNullElements(
targetStates, "Null target states are not permitted");
return forDbSystem(
com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy),
request,
targetStates);
}
// Helper method to create a new Waiter for DbSystem.
private com.oracle.bmc.waiter.Waiter forDbSystem(
com.oracle.bmc.waiter.BmcGenericWaiter waiter,
final GetDbSystemRequest request,
final com.oracle.bmc.mysql.model.DbSystem.LifecycleState... targetStates) {
final java.util.Set targetStatesSet =
new java.util.HashSet<>(java.util.Arrays.asList(targetStates));
return new com.oracle.bmc.waiter.internal.SimpleWaiterImpl<>(
executorService,
waiter.toCallable(
com.google.common.base.Suppliers.ofInstance(request),
new com.google.common.base.Function<
GetDbSystemRequest, GetDbSystemResponse>() {
@Override
public GetDbSystemResponse apply(GetDbSystemRequest request) {
return client.getDbSystem(request);
}
},
new com.google.common.base.Predicate() {
@Override
public boolean apply(GetDbSystemResponse response) {
return targetStatesSet.contains(
response.getDbSystem().getLifecycleState());
}
},
targetStatesSet.contains(
com.oracle.bmc.mysql.model.DbSystem.LifecycleState.Deleted)),
request);
}
}