
io.vertx.rxjava.core.dns.DnsClient Maven / Gradle / Ivy
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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 io.vertx.rxjava.core.dns;
import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;
/**
* Provides a way to asynchronously lookup information from DNS servers.
*
* Please consult the documentation for more information on DNS clients.
*
* The client is thread safe and can be used from any thread.
*
*
* NOTE: This class has been automatically generated from the {@link io.vertx.core.dns.DnsClient original} non RX-ified interface using Vert.x codegen.
*/
@RxGen(io.vertx.core.dns.DnsClient.class)
public class DnsClient {
@Override
public String toString() {
return delegate.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
DnsClient that = (DnsClient) o;
return delegate.equals(that.delegate);
}
@Override
public int hashCode() {
return delegate.hashCode();
}
public static final TypeArg __TYPE_ARG = new TypeArg<>( obj -> new DnsClient((io.vertx.core.dns.DnsClient) obj),
DnsClient::getDelegate
);
private final io.vertx.core.dns.DnsClient delegate;
public DnsClient(io.vertx.core.dns.DnsClient delegate) {
this.delegate = delegate;
}
public DnsClient(Object delegate) {
this.delegate = (io.vertx.core.dns.DnsClient)delegate;
}
public io.vertx.core.dns.DnsClient getDelegate() {
return delegate;
}
/**
* Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved address if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future lookup(java.lang.String name) {
io.vertx.core.Future ret = delegate.lookup(name).map(val -> val);
return ret;
}
/**
* Try to lookup the A (ipv4) or AAAA (ipv6) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved address if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single rxLookup(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.lookup(name).onComplete(fut);
}));
}
/**
* Try to lookup the A (ipv4) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved {@link java.net.Inet4Address} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future lookup4(java.lang.String name) {
io.vertx.core.Future ret = delegate.lookup4(name).map(val -> val);
return ret;
}
/**
* Try to lookup the A (ipv4) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved {@link java.net.Inet4Address} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single rxLookup4(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.lookup4(name).onComplete(fut);
}));
}
/**
* Try to lookup the AAAA (ipv6) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved {@link java.net.Inet6Address} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future lookup6(java.lang.String name) {
io.vertx.core.Future ret = delegate.lookup6(name).map(val -> val);
return ret;
}
/**
* Try to lookup the AAAA (ipv6) record for the given name. The first found will be used.
* @param name the name to resolve
* @return a future notified with the resolved {@link java.net.Inet6Address} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single rxLookup6(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.lookup6(name).onComplete(fut);
}));
}
/**
* Try to resolve all A (ipv4) records for the given name.
* @param name the name to resolve
* @return a future notified with a {@link java.util.List} that contains all the resolved {@link java.net.Inet4Address}es. If none was found an empty {@link java.util.List} will be used. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveA(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveA(name).map(val -> val);
return ret;
}
/**
* Try to resolve all A (ipv4) records for the given name.
* @param name the name to resolve
* @return a future notified with a {@link java.util.List} that contains all the resolved {@link java.net.Inet4Address}es. If none was found an empty {@link java.util.List} will be used. If an error occurs it will get failed.
*/
public rx.Single> rxResolveA(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveA(name).onComplete(fut);
}));
}
/**
* Try to resolve all AAAA (ipv6) records for the given name.
* @param name the name to resolve
* @return a future notified with a {@link java.util.List} that contains all the resolved {@link java.net.Inet6Address}es. If none was found an empty {@link java.util.List} will be used. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveAAAA(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveAAAA(name).map(val -> val);
return ret;
}
/**
* Try to resolve all AAAA (ipv6) records for the given name.
* @param name the name to resolve
* @return a future notified with a {@link java.util.List} that contains all the resolved {@link java.net.Inet6Address}es. If none was found an empty {@link java.util.List} will be used. If an error occurs it will get failed.
*/
public rx.Single> rxResolveAAAA(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveAAAA(name).onComplete(fut);
}));
}
/**
* Try to resolve the CNAME record for the given name.
* @param name the name to resolve the CNAME for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveCNAME(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveCNAME(name).map(val -> val);
return ret;
}
/**
* Try to resolve the CNAME record for the given name.
* @param name the name to resolve the CNAME for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single> rxResolveCNAME(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveCNAME(name).onComplete(fut);
}));
}
/**
* Try to resolve the MX records for the given name.
* @param name the name for which the MX records should be resolved
* @return a future notified with a List that contains all resolved {@link io.vertx.core.dns.MxRecord}s, sorted by their {@link io.vertx.core.dns.MxRecord}. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveMX(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveMX(name).map(val -> val);
return ret;
}
/**
* Try to resolve the MX records for the given name.
* @param name the name for which the MX records should be resolved
* @return a future notified with a List that contains all resolved {@link io.vertx.core.dns.MxRecord}s, sorted by their {@link io.vertx.core.dns.MxRecord}. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public rx.Single> rxResolveMX(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveMX(name).onComplete(fut);
}));
}
/**
* Try to resolve the TXT records for the given name.
* @param name the name for which the TXT records should be resolved
* @return a future notified with a List that contains all resolved {@link java.lang.String}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveTXT(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveTXT(name).map(val -> val);
return ret;
}
/**
* Try to resolve the TXT records for the given name.
* @param name the name for which the TXT records should be resolved
* @return a future notified with a List that contains all resolved {@link java.lang.String}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public rx.Single> rxResolveTXT(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveTXT(name).onComplete(fut);
}));
}
/**
* Try to resolve the PTR record for the given name.
* @param name the name to resolve the PTR for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future resolvePTR(java.lang.String name) {
io.vertx.core.Future ret = delegate.resolvePTR(name).map(val -> val);
return ret;
}
/**
* Try to resolve the PTR record for the given name.
* @param name the name to resolve the PTR for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single rxResolvePTR(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolvePTR(name).onComplete(fut);
}));
}
/**
* Try to resolve the NS records for the given name.
* @param name the name for which the NS records should be resolved
* @return a future notified with a List that contains all resolved {@link java.lang.String}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveNS(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveNS(name).map(val -> val);
return ret;
}
/**
* Try to resolve the NS records for the given name.
* @param name the name for which the NS records should be resolved
* @return a future notified with a List that contains all resolved {@link java.lang.String}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public rx.Single> rxResolveNS(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveNS(name).onComplete(fut);
}));
}
/**
* Try to resolve the SRV records for the given name.
* @param name the name for which the SRV records should be resolved
* @return a future resolved with a List that contains all resolved {@link io.vertx.core.dns.SrvRecord}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public io.vertx.core.Future> resolveSRV(java.lang.String name) {
io.vertx.core.Future> ret = delegate.resolveSRV(name).map(val -> val);
return ret;
}
/**
* Try to resolve the SRV records for the given name.
* @param name the name for which the SRV records should be resolved
* @return a future resolved with a List that contains all resolved {@link io.vertx.core.dns.SrvRecord}s. If none was found it will get notified with an empty {@link java.util.List}. If an error occurs it will get failed.
*/
public rx.Single> rxResolveSRV(java.lang.String name) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.resolveSRV(name).onComplete(fut);
}));
}
/**
* Try to do a reverse lookup of an IP address. This is basically the same as doing trying to resolve a PTR record
* but allows you to just pass in the IP address and not a valid ptr query string.
* @param ipaddress the IP address to resolve the PTR for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public io.vertx.core.Future reverseLookup(java.lang.String ipaddress) {
io.vertx.core.Future ret = delegate.reverseLookup(ipaddress).map(val -> val);
return ret;
}
/**
* Try to do a reverse lookup of an IP address. This is basically the same as doing trying to resolve a PTR record
* but allows you to just pass in the IP address and not a valid ptr query string.
* @param ipaddress the IP address to resolve the PTR for
* @return a future notified with the resolved {@link java.lang.String} if a record was found. If none was found it will get notified with null
. If an error occurs it will get failed.
*/
public rx.Single rxReverseLookup(java.lang.String ipaddress) {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.reverseLookup(ipaddress).onComplete(fut);
}));
}
/**
* Close the client.
* @return the future completed when the client resources have been released
*/
public io.vertx.core.Future close() {
io.vertx.core.Future ret = delegate.close().map(val -> val);
return ret;
}
/**
* Close the client.
* @return the future completed when the client resources have been released
*/
public rx.Single rxClose() {
return Single.create(new SingleOnSubscribeAdapter<>(fut -> {
this.close().onComplete(fut);
}));
}
public static DnsClient newInstance(io.vertx.core.dns.DnsClient arg) {
return arg != null ? new DnsClient(arg) : null;
}
}