import Foundation
extension RegistrationsAPI {
/// Polls a registry action until it is `succeeded`, `failed` or `cancelled` and
/// returns it; failures are results the caller reads, not errors.
public func waitForAction(id: String, options: PollOptions = .actions) async throws -> RegistrationAction {
try await pollUntil(options, clock: client.configuration.clock,
step: { try await getAction(id: id).action },
done: { [.succeeded, .failed, .cancelled].contains($0.state) })
}
}
extension VPSAPI {
/// Polls a VPS action until it is `succeeded`, `failed` or `cancelled` and returns it.
public func waitForAction(id: String, options: PollOptions = .actions) async throws -> VPSAction {
try await pollUntil(options, clock: client.configuration.clock,
step: { try await getAction(id: id).action },
done: { [.succeeded, .failed, .cancelled].contains($0.state) })
}
}