com.palantir.atlasdb.timelock.paxos.api.NamespaceLeadershipTakeoverServiceBlocking Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of timelock-api-dialogue Show documentation
Show all versions of timelock-api-dialogue Show documentation
Palantir open source project
package com.palantir.atlasdb.timelock.paxos.api;
import com.palantir.conjure.java.lib.internal.ClientEndpoint;
import com.palantir.dialogue.Channel;
import com.palantir.dialogue.ConjureRuntime;
import com.palantir.dialogue.Deserializer;
import com.palantir.dialogue.DialogueService;
import com.palantir.dialogue.DialogueServiceFactory;
import com.palantir.dialogue.Endpoint;
import com.palantir.dialogue.EndpointChannel;
import com.palantir.dialogue.EndpointChannelFactory;
import com.palantir.dialogue.PlainSerDe;
import com.palantir.dialogue.Request;
import com.palantir.dialogue.Serializer;
import com.palantir.dialogue.TypeMarker;
import com.palantir.tokens.auth.AuthHeader;
import java.lang.Boolean;
import java.lang.Override;
import java.lang.String;
import java.util.Set;
import javax.annotation.Generated;
@Generated("com.palantir.conjure.java.services.dialogue.DialogueInterfaceGenerator")
@DialogueService(NamespaceLeadershipTakeoverServiceBlocking.Factory.class)
public interface NamespaceLeadershipTakeoverServiceBlocking {
/**
* @apiNote {@code POST /tl/paxos/takeover/{namespace}}
*/
@ClientEndpoint(method = "POST", path = "/tl/paxos/takeover/{namespace}")
boolean takeover(AuthHeader authHeader, String namespace);
/**
* @apiNote {@code POST /tl/paxos/takeoverNamespaces}
*/
@ClientEndpoint(method = "POST", path = "/tl/paxos/takeoverNamespaces")
Set takeoverNamespaces(AuthHeader authHeader, Set namespaces);
/**
* Creates a synchronous/blocking client for a NamespaceLeadershipTakeoverService service.
*/
static NamespaceLeadershipTakeoverServiceBlocking of(
EndpointChannelFactory _endpointChannelFactory, ConjureRuntime _runtime) {
return new NamespaceLeadershipTakeoverServiceBlocking() {
private final PlainSerDe _plainSerDe = _runtime.plainSerDe();
private final EndpointChannel takeoverChannel =
_endpointChannelFactory.endpoint(DialogueNamespaceLeadershipTakeoverEndpoints.takeover);
private final Deserializer takeoverDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker() {});
private final Serializer> takeoverNamespacesSerializer =
_runtime.bodySerDe().serializer(new TypeMarker>() {});
private final EndpointChannel takeoverNamespacesChannel =
_endpointChannelFactory.endpoint(DialogueNamespaceLeadershipTakeoverEndpoints.takeoverNamespaces);
private final Deserializer> takeoverNamespacesDeserializer =
_runtime.bodySerDe().deserializer(new TypeMarker>() {});
@Override
public boolean takeover(AuthHeader authHeader, String namespace) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.putPathParams("namespace", _plainSerDe.serializeString(namespace));
return _runtime.clients().callBlocking(takeoverChannel, _request.build(), takeoverDeserializer);
}
@Override
public Set takeoverNamespaces(AuthHeader authHeader, Set namespaces) {
Request.Builder _request = Request.builder();
_request.putHeaderParams("Authorization", authHeader.toString());
_request.body(takeoverNamespacesSerializer.serialize(namespaces));
return _runtime.clients()
.callBlocking(takeoverNamespacesChannel, _request.build(), takeoverNamespacesDeserializer);
}
@Override
public String toString() {
return "NamespaceLeadershipTakeoverServiceBlocking{_endpointChannelFactory=" + _endpointChannelFactory
+ ", runtime=" + _runtime + '}';
}
};
}
/**
* Creates an asynchronous/non-blocking client for a NamespaceLeadershipTakeoverService service.
*/
static NamespaceLeadershipTakeoverServiceBlocking of(Channel _channel, ConjureRuntime _runtime) {
if (_channel instanceof EndpointChannelFactory) {
return of((EndpointChannelFactory) _channel, _runtime);
}
return of(
new EndpointChannelFactory() {
@Override
public EndpointChannel endpoint(Endpoint endpoint) {
return _runtime.clients().bind(_channel, endpoint);
}
},
_runtime);
}
final class Factory implements DialogueServiceFactory {
@Override
public NamespaceLeadershipTakeoverServiceBlocking create(
EndpointChannelFactory endpointChannelFactory, ConjureRuntime runtime) {
return NamespaceLeadershipTakeoverServiceBlocking.of(endpointChannelFactory, runtime);
}
}
}