All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.palantir.atlasdb.timelock.api.management.TimeLockManagementServiceEndpoints Maven / Gradle / Ivy

package com.palantir.atlasdb.timelock.api.management;

import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.palantir.atlasdb.timelock.api.DisableNamespacesRequest;
import com.palantir.atlasdb.timelock.api.DisableNamespacesResponse;
import com.palantir.atlasdb.timelock.api.ReenableNamespacesRequest;
import com.palantir.atlasdb.timelock.api.ReenableNamespacesResponse;
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 io.undertow.util.StatusCodes;
import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import javax.annotation.Generated;

@Generated("com.palantir.conjure.java.services.UndertowServiceHandlerGenerator")
public final class TimeLockManagementServiceEndpoints implements UndertowService {
    private final UndertowTimeLockManagementService delegate;

    private TimeLockManagementServiceEndpoints(UndertowTimeLockManagementService delegate) {
        this.delegate = delegate;
    }

    public static UndertowService of(UndertowTimeLockManagementService delegate) {
        return new TimeLockManagementServiceEndpoints(delegate);
    }

    @Override
    public List endpoints(UndertowRuntime runtime) {
        return ImmutableList.of(
                new GetNamespacesEndpoint(runtime, delegate),
                new AchieveConsensusEndpoint(runtime, delegate),
                new InvalidateResourcesEndpoint(runtime, delegate),
                new DisableTimelockEndpoint(runtime, delegate),
                new ReenableTimelockEndpoint(runtime, delegate),
                new GetServerLifecycleIdEndpoint(runtime, delegate),
                new ForceKillTimeLockServerEndpoint(runtime, delegate));
    }

    private static final class GetNamespacesEndpoint implements HttpHandler, Endpoint, ReturnValueWriter> {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Serializer> serializer;

        GetNamespacesEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService 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.getNamespaces(authHeader);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(Set result, HttpServerExchange exchange) throws IOException {
            serializer.serialize(result, exchange);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/getNamespaces";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "getNamespaces";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class AchieveConsensusEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Deserializer> deserializer;

        AchieveConsensusEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService delegate) {
            this.runtime = runtime;
            this.delegate = delegate;
            this.deserializer = runtime.bodySerDe().deserializer(new TypeMarker>() {}, this);
        }

        @Override
        public void handleRequest(HttpServerExchange exchange) throws IOException {
            AuthHeader authHeader = runtime.auth().header(exchange);
            Set namespaces = deserializer.deserialize(exchange);
            ListenableFuture result = delegate.achieveConsensus(authHeader, namespaces);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(Void result, HttpServerExchange exchange) throws IOException {
            exchange.setStatusCode(StatusCodes.NO_CONTENT);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/achieveConsensus";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "achieveConsensus";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class InvalidateResourcesEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Deserializer> deserializer;

        InvalidateResourcesEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService delegate) {
            this.runtime = runtime;
            this.delegate = delegate;
            this.deserializer = runtime.bodySerDe().deserializer(new TypeMarker>() {}, this);
        }

        @Override
        public void handleRequest(HttpServerExchange exchange) throws IOException {
            AuthHeader authHeader = runtime.auth().header(exchange);
            Set namespaces = deserializer.deserialize(exchange);
            ListenableFuture result = delegate.invalidateResources(authHeader, namespaces);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(Void result, HttpServerExchange exchange) throws IOException {
            exchange.setStatusCode(StatusCodes.NO_CONTENT);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/invalidateResources";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "invalidateResources";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class DisableTimelockEndpoint
            implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Deserializer deserializer;

        private final Serializer serializer;

        DisableTimelockEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService 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.disableTimelock(authHeader, request);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(DisableNamespacesResponse result, HttpServerExchange exchange) throws IOException {
            serializer.serialize(result, exchange);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/disable";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "disableTimelock";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class ReenableTimelockEndpoint
            implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Deserializer deserializer;

        private final Serializer serializer;

        ReenableTimelockEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService 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.reenableTimelock(authHeader, request);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(ReenableNamespacesResponse result, HttpServerExchange exchange) throws IOException {
            serializer.serialize(result, exchange);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/reenable";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "reenableTimelock";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class GetServerLifecycleIdEndpoint implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Serializer serializer;

        GetServerLifecycleIdEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService 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.getServerLifecycleId(authHeader);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(UUID result, HttpServerExchange exchange) throws IOException {
            serializer.serialize(result, exchange);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/getServerLifecycleId";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "getServerLifecycleId";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }

    private static final class ForceKillTimeLockServerEndpoint
            implements HttpHandler, Endpoint, ReturnValueWriter {
        private final UndertowRuntime runtime;

        private final UndertowTimeLockManagementService delegate;

        private final Serializer serializer;

        ForceKillTimeLockServerEndpoint(UndertowRuntime runtime, UndertowTimeLockManagementService 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.forceKillTimeLockServer(authHeader);
            runtime.async().register(result, this, exchange);
        }

        @Override
        public void write(UUID result, HttpServerExchange exchange) throws IOException {
            serializer.serialize(result, exchange);
        }

        @Override
        public HttpString method() {
            return Methods.POST;
        }

        @Override
        public String template() {
            return "/tl/management/forceKillTimeLockServer";
        }

        @Override
        public String serviceName() {
            return "TimeLockManagementService";
        }

        @Override
        public String name() {
            return "forceKillTimeLockServer";
        }

        @Override
        public HttpHandler handler() {
            return this;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy