Search in sources :

Example 6 with SearchResponse

use of io.cdap.cdap.spi.metadata.SearchResponse in project cdap by caskdata.

the class MetadataHttpHandler method searchNamespace.

@GET
@Path("/namespaces/{namespace-id}/metadata/search")
public void searchNamespace(HttpRequest request, HttpResponder responder, @PathParam("namespace-id") String namespaceId, @Nullable @QueryParam("scope") String scope, @Nullable @QueryParam("query") String searchQuery, @Nullable @QueryParam("target") List<String> targets, @Nullable @QueryParam("sort") String sort, @QueryParam("offset") @DefaultValue("0") int offset, // 2147483647 is Integer.MAX_VALUE
@QueryParam("limit") @DefaultValue("2147483647") int limit, @Nullable @QueryParam("numCursors") Integer numCursors, @QueryParam("cursorRequested") @DefaultValue("false") boolean cursorRequested, @Nullable @QueryParam("cursor") String cursor, @QueryParam("showHidden") @DefaultValue("false") boolean showHidden, @Nullable @QueryParam("entityScope") String entityScope, @Nullable @QueryParam("responseFormat") @DefaultValue("v5") String responseFormat) throws Exception {
    SearchRequest searchRequest = getValidatedSearchRequest(scope, ImmutableList.of(namespaceId), searchQuery, targets, sort, offset, limit, numCursors, cursorRequested, cursor, showHidden, entityScope);
    SearchResponse response = metadataAdmin.search(searchRequest);
    responder.sendJson(HttpResponseStatus.OK, GSON.toJson("v5".equals(responseFormat) ? MetadataCompatibility.toV5Response(response, entityScope) : response));
}
Also used : SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) Path(javax.ws.rs.Path) GET(javax.ws.rs.GET)

Example 7 with SearchResponse

use of io.cdap.cdap.spi.metadata.SearchResponse in project cdap by caskdata.

the class AuditMetadataStorage method search.

@Override
public SearchResponse search(SearchRequest request) throws IOException {
    try {
        SearchResponse result = storage.search(request);
        emitMetrics("search.count");
        return result;
    } catch (Exception e) {
        emitMetrics("search.error");
        throw e;
    }
}
Also used : IOException(java.io.IOException) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse)

Aggregations

SearchResponse (io.cdap.cdap.spi.metadata.SearchResponse)7 SearchRequest (io.cdap.cdap.spi.metadata.SearchRequest)5 MetadataEntity (io.cdap.cdap.api.metadata.MetadataEntity)4 Metadata (io.cdap.cdap.spi.metadata.Metadata)4 IOException (java.io.IOException)4 MetadataScope (io.cdap.cdap.api.metadata.MetadataScope)3 NamespaceId (io.cdap.cdap.proto.id.NamespaceId)3 ImmutableList (com.google.common.collect.ImmutableList)2 ImmutableMap (com.google.common.collect.ImmutableMap)2 ImmutableSet (com.google.common.collect.ImmutableSet)2 Cursor (io.cdap.cdap.common.metadata.Cursor)2 MetadataKind (io.cdap.cdap.spi.metadata.MetadataKind)2 MetadataRecord (io.cdap.cdap.spi.metadata.MetadataRecord)2 MetadataStorage (io.cdap.cdap.spi.metadata.MetadataStorage)2 MutationOptions (io.cdap.cdap.spi.metadata.MutationOptions)2 ScopedName (io.cdap.cdap.spi.metadata.ScopedName)2 ScopedNameOfKind (io.cdap.cdap.spi.metadata.ScopedNameOfKind)2 Collections (java.util.Collections)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2