com.palantir.atlasdb.timelock.api.DisabledNamespacesUpdaterServiceEndpoints Maven / Gradle / Ivy
package com.palantir.atlasdb.timelock.api;
import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.palantir.conjure.java.undertow.lib.Deserializer;
import com.palantir.conjure.java.undertow.lib.Endpoint;
import com.palantir.conjure.java.undertow.lib.ReturnValueWriter;
import com.palantir.conjure.java.undertow.lib.Serializer;
import com.palantir.conjure.java.undertow.lib.TypeMarker;
import com.palantir.conjure.java.undertow.lib.UndertowRuntime;
import com.palantir.conjure.java.undertow.lib.UndertowService;
import com.palantir.tokens.auth.AuthHeader;
import io.undertow.server.HttpHandler;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.HttpString;
import io.undertow.util.Methods;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;
@Generated("com.palantir.conjure.java.services.UndertowServiceHandlerGenerator")
public final class DisabledNamespacesUpdaterServiceEndpoints implements UndertowService {
private final UndertowDisabledNamespacesUpdaterService delegate;
private DisabledNamespacesUpdaterServiceEndpoints(UndertowDisabledNamespacesUpdaterService delegate) {
this.delegate = delegate;
}
public static UndertowService of(UndertowDisabledNamespacesUpdaterService delegate) {
return new DisabledNamespacesUpdaterServiceEndpoints(delegate);
}
@Override
public List endpoints(UndertowRuntime runtime) {
return ImmutableList.of(
new PingEndpoint(runtime, delegate),
new DisableEndpoint(runtime, delegate),
new ReenableEndpoint(runtime, delegate));
}
private static final class PingEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
private final UndertowRuntime runtime;
private final UndertowDisabledNamespacesUpdaterService delegate;
private final Serializer serializer;
PingEndpoint(UndertowRuntime runtime, UndertowDisabledNamespacesUpdaterService delegate) {
this.runtime = runtime;
this.delegate = delegate;
this.serializer = runtime.bodySerDe().serializer(new TypeMarker() {}, this);
}
@Override
public void handleRequest(HttpServerExchange exchange) throws IOException {
AuthHeader authHeader = runtime.auth().header(exchange);
ListenableFuture result = delegate.ping(authHeader);
runtime.async().register(result, this, exchange);
}
@Override
public void write(Boolean result, HttpServerExchange exchange) throws IOException {
serializer.serialize(result, exchange);
}
@Override
public HttpString method() {
return Methods.GET;
}
@Override
public String template() {
return "/dn/ping";
}
@Override
public String serviceName() {
return "DisabledNamespacesUpdaterService";
}
@Override
public String name() {
return "ping";
}
@Override
public HttpHandler handler() {
return this;
}
}
private static final class DisableEndpoint
implements HttpHandler, Endpoint, ReturnValueWriter {
private final UndertowRuntime runtime;
private final UndertowDisabledNamespacesUpdaterService delegate;
private final Deserializer deserializer;
private final Serializer serializer;
DisableEndpoint(UndertowRuntime runtime, UndertowDisabledNamespacesUpdaterService delegate) {
this.runtime = runtime;
this.delegate = delegate;
this.deserializer = runtime.bodySerDe().deserializer(new TypeMarker() {}, this);
this.serializer = runtime.bodySerDe().serializer(new TypeMarker() {}, this);
}
@Override
public void handleRequest(HttpServerExchange exchange) throws IOException {
AuthHeader authHeader = runtime.auth().header(exchange);
DisableNamespacesRequest request = deserializer.deserialize(exchange);
ListenableFuture result = delegate.disable(authHeader, request);
runtime.async().register(result, this, exchange);
}
@Override
public void write(SingleNodeUpdateResponse result, HttpServerExchange exchange) throws IOException {
serializer.serialize(result, exchange);
}
@Override
public HttpString method() {
return Methods.POST;
}
@Override
public String template() {
return "/dn/disable";
}
@Override
public String serviceName() {
return "DisabledNamespacesUpdaterService";
}
@Override
public String name() {
return "disable";
}
@Override
public HttpHandler handler() {
return this;
}
}
private static final class ReenableEndpoint
implements HttpHandler, Endpoint, ReturnValueWriter {
private final UndertowRuntime runtime;
private final UndertowDisabledNamespacesUpdaterService delegate;
private final Deserializer deserializer;
private final Serializer serializer;
ReenableEndpoint(UndertowRuntime runtime, UndertowDisabledNamespacesUpdaterService delegate) {
this.runtime = runtime;
this.delegate = delegate;
this.deserializer = runtime.bodySerDe().deserializer(new TypeMarker() {}, this);
this.serializer = runtime.bodySerDe().serializer(new TypeMarker() {}, this);
}
@Override
public void handleRequest(HttpServerExchange exchange) throws IOException {
AuthHeader authHeader = runtime.auth().header(exchange);
ReenableNamespacesRequest request = deserializer.deserialize(exchange);
ListenableFuture result = delegate.reenable(authHeader, request);
runtime.async().register(result, this, exchange);
}
@Override
public void write(SingleNodeUpdateResponse result, HttpServerExchange exchange) throws IOException {
serializer.serialize(result, exchange);
}
@Override
public HttpString method() {
return Methods.POST;
}
@Override
public String template() {
return "/dn/reenable";
}
@Override
public String serviceName() {
return "DisabledNamespacesUpdaterService";
}
@Override
public String name() {
return "reenable";
}
@Override
public HttpHandler handler() {
return this;
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy