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

com.palantir.atlasdb.backup.api.AtlasRestoreClientEndpoints Maven / Gradle / Ivy

There is a newer version: 0.1193.0
Show newest version
package com.palantir.atlasdb.backup.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 AtlasRestoreClientEndpoints implements UndertowService {
    private final UndertowAtlasRestoreClient delegate;

    private AtlasRestoreClientEndpoints(UndertowAtlasRestoreClient delegate) {
        this.delegate = delegate;
    }

    public static UndertowService of(UndertowAtlasRestoreClient delegate) {
        return new AtlasRestoreClientEndpoints(delegate);
    }

    @Override
    public List endpoints(UndertowRuntime runtime) {
        return ImmutableList.of(new CompleteRestoreEndpoint(runtime, delegate));
    }

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

        private final UndertowAtlasRestoreClient delegate;

        private final Deserializer deserializer;

        private final Serializer serializer;

        CompleteRestoreEndpoint(UndertowRuntime runtime, UndertowAtlasRestoreClient 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);
            CompleteRestoreRequest request = deserializer.deserialize(exchange);
            ListenableFuture result = delegate.completeRestore(authHeader, request);
            runtime.async().register(result, this, exchange);
        }

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

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

        @Override
        public String template() {
            return "/restore/complete";
        }

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy