package com.laschuet.spark.rest.sample;

import javax.servlet.ServletContext;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.apache.spark.sql.SparkSession;

@Path("info")
public class Info {
    @Context
    private ServletContext context = null;

    @Path("version")
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getSparkSessionVersion() {
        SparkSession sparkSession = (SparkSession) context.getAttribute("sparkSession");
        return sparkSession.version();
    }
}

@@ -218,16 +218,54 @@
 duces;%0A%0A
+import org.apache.spark.SparkContext;%0A
 import o
@@ -634,11 +634,321 @@
 );%0A    %7D
+%0A%0A    @Path(%22user%22)%0A    @GET%0A    @Produces(MediaType.TEXT_PLAIN)%0A    public String getSparkContextVersion() %7B%0A        SparkSession sparkSession = (SparkSession) context.getAttribute(%22sparkSession%22);%0A        SparkContext sparkContext = sparkSession.sparkContext();%0A        return sparkContext.sparkUser();%0A    %7D
 %0A%7D%0A

Add an endpoint to query the Spark user