Search in sources :

Example 6 with ServiceHttpEndpoint

use of co.cask.cdap.api.service.http.ServiceHttpEndpoint in project cdap by caskdata.

the class GetServiceEndpointsCommand method perform.

@Override
public void perform(Arguments arguments, PrintStream output) throws Exception {
    ServiceId serviceId = new ServiceId(parseProgramId(arguments, ElementType.SERVICE));
    List<ServiceHttpEndpoint> endpoints = serviceClient.getEndpoints(serviceId);
    Table table = Table.builder().setHeader("method", "path").setRows(endpoints, new RowMaker<ServiceHttpEndpoint>() {

        @Override
        public List<?> makeRow(ServiceHttpEndpoint endpoint) {
            return Lists.newArrayList(endpoint.getMethod(), endpoint.getPath());
        }
    }).build();
    cliConfig.getTableRenderer().render(cliConfig, output, table);
}
Also used : ServiceHttpEndpoint(co.cask.cdap.api.service.http.ServiceHttpEndpoint) Table(co.cask.cdap.cli.util.table.Table) RowMaker(co.cask.cdap.cli.util.RowMaker) ServiceId(co.cask.cdap.proto.id.ServiceId)

Example 7 with ServiceHttpEndpoint

use of co.cask.cdap.api.service.http.ServiceHttpEndpoint in project cdap by caskdata.

the class ServiceClientTestRun method testGetEndpoints.

@Test
public void testGetEndpoints() throws Exception {
    List<ServiceHttpEndpoint> endpoints = serviceClient.getEndpoints(service);
    assertEquals(1, endpoints.size());
    ServiceHttpEndpoint endpoint = endpoints.get(0);
    assertEquals("GET", endpoint.getMethod());
    assertEquals("/ping", endpoint.getPath());
}
Also used : ServiceHttpEndpoint(co.cask.cdap.api.service.http.ServiceHttpEndpoint) Test(org.junit.Test)

Aggregations

ServiceHttpEndpoint (co.cask.cdap.api.service.http.ServiceHttpEndpoint)7 HttpServiceHandlerSpecification (co.cask.cdap.api.service.http.HttpServiceHandlerSpecification)4 ServiceSpecification (co.cask.cdap.api.service.ServiceSpecification)3 Test (org.junit.Test)2 Resources (co.cask.cdap.api.Resources)1 RowMaker (co.cask.cdap.cli.util.RowMaker)1 Table (co.cask.cdap.cli.util.table.Table)1 ServiceSpecificationCodec (co.cask.cdap.internal.app.ServiceSpecificationCodec)1 DataSetFieldExtractor (co.cask.cdap.internal.specification.DataSetFieldExtractor)1 PropertyFieldExtractor (co.cask.cdap.internal.specification.PropertyFieldExtractor)1 ServiceId (co.cask.cdap.proto.id.ServiceId)1 ImmutableList (com.google.common.collect.ImmutableList)1 TypeToken (com.google.common.reflect.TypeToken)1 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 JsonObject (com.google.gson.JsonObject)1 Annotation (java.lang.annotation.Annotation)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 HttpMethod (javax.ws.rs.HttpMethod)1