Search in sources :

Example 1 with SearchResponse

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

the class DatasetMetadataStorage method search.

@Override
public SearchResponse search(SearchRequest request) {
    Cursor cursor = request.getCursor() != null && !request.getCursor().isEmpty() ? Cursor.fromString(request.getCursor()) : null;
    Set<String> namespaces = cursor == null ? request.getNamespaces() : cursor.getNamespaces();
    ImmutablePair<NamespaceId, Set<EntityScope>> namespaceAndScopes = determineNamespaceAndScopes(namespaces);
    CursorAndOffsetInfo cursorOffsetAndLimits = determineCursorOffsetAndLimits(request, cursor);
    String query = cursor != null ? cursor.getQuery() : request.getQuery() == null || request.getQuery().isEmpty() ? "*" : request.getQuery();
    Set<String> types = cursor != null ? cursor.getTypes() : request.getTypes();
    types = types == null ? Collections.emptySet() : types;
    Sorting sorting = cursor == null ? request.getSorting() : cursor.getSorting() == null ? null : Sorting.of(cursor.getSorting());
    SortInfo sortInfo = sorting == null ? SortInfo.DEFAULT : new SortInfo(sorting.getKey(), SortInfo.SortOrder.valueOf(sorting.getOrder().name()));
    boolean showHidden = cursor != null ? cursor.isShowHidden() : request.isShowHidden();
    MetadataScope scope = cursor != null ? cursor.getScope() : request.getScope();
    MetadataSearchResponse response = search(new io.cdap.cdap.data2.metadata.dataset.SearchRequest(namespaceAndScopes.getFirst(), query, types, sortInfo, cursorOffsetAndLimits.getOffsetToRequest(), cursorOffsetAndLimits.getLimitToRequest(), request.isCursorRequested() ? 1 : 0, cursorOffsetAndLimits.getCursor(), showHidden, namespaceAndScopes.getSecond()), scope);
    // translate results back and limit them to at most what was requested (see above where we add 1)
    int limitToRespond = cursorOffsetAndLimits.getLimitToRespond();
    int offsetToRespond = cursorOffsetAndLimits.getOffsetToRespond();
    List<MetadataRecord> results = response.getResults().stream().limit(limitToRespond).map(record -> {
        Metadata metadata = Metadata.EMPTY;
        for (Map.Entry<MetadataScope, io.cdap.cdap.api.metadata.Metadata> entry : record.getMetadata().entrySet()) {
            Metadata toAdd = new Metadata(entry.getKey(), entry.getValue().getTags(), entry.getValue().getProperties());
            metadata = mergeDisjointMetadata(metadata, toAdd);
        }
        return new MetadataRecord(record.getMetadataEntity(), metadata);
    }).collect(Collectors.toList());
    Cursor newCursor = null;
    if (response.getCursors() != null && !response.getCursors().isEmpty()) {
        String actualCursor = response.getCursors().get(0);
        if (cursor != null) {
            // the new cursor's offset is the previous cursor's offset plus the number of results
            newCursor = new Cursor(cursor, cursor.getOffset() + results.size(), actualCursor);
        } else {
            newCursor = new Cursor(offsetToRespond + results.size(), limitToRespond, showHidden, scope, namespaces, types, sorting == null ? null : sorting.toString(), actualCursor, query);
        }
    }
    // adjust the total results by the difference of requested offset and the true offset that we respond back
    int totalResults = offsetToRespond - cursorOffsetAndLimits.getOffsetToRequest() + response.getTotal();
    return new SearchResponse(request, newCursor == null ? null : newCursor.toString(), offsetToRespond, limitToRespond, totalResults, results);
}
Also used : MetadataSearchResponse(io.cdap.cdap.proto.metadata.MetadataSearchResponse) ImmutablePair(io.cdap.cdap.common.utils.ImmutablePair) MetadataDirective(io.cdap.cdap.spi.metadata.MetadataDirective) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) Inject(com.google.inject.Inject) HashMap(java.util.HashMap) USER(io.cdap.cdap.api.metadata.MetadataScope.USER) MetadataChange(io.cdap.cdap.spi.metadata.MetadataChange) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) HashSet(java.util.HashSet) TAG(io.cdap.cdap.spi.metadata.MetadataKind.TAG) ScopedNameOfKind(io.cdap.cdap.spi.metadata.ScopedNameOfKind) Metadata(io.cdap.cdap.spi.metadata.Metadata) Map(java.util.Map) SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) MetadataMutation(io.cdap.cdap.spi.metadata.MetadataMutation) Read(io.cdap.cdap.spi.metadata.Read) EnumSet(java.util.EnumSet) Sorting(io.cdap.cdap.spi.metadata.Sorting) SortInfo(io.cdap.cdap.data2.metadata.dataset.SortInfo) TransactionSystemClient(org.apache.tephra.TransactionSystemClient) PROPERTY(io.cdap.cdap.spi.metadata.MetadataKind.PROPERTY) ImmutableMap(com.google.common.collect.ImmutableMap) Cursor(io.cdap.cdap.common.metadata.Cursor) SYSTEM(io.cdap.cdap.api.metadata.MetadataScope.SYSTEM) Set(java.util.Set) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) IOException(java.io.IOException) MetadataKind(io.cdap.cdap.spi.metadata.MetadataKind) ScopedName(io.cdap.cdap.spi.metadata.ScopedName) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) List(java.util.List) EntityScope(io.cdap.cdap.proto.EntityScope) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope) Named(com.google.inject.name.Named) Constants(io.cdap.cdap.common.conf.Constants) VisibleForTesting(com.google.common.annotations.VisibleForTesting) DatasetDefinition(io.cdap.cdap.api.dataset.DatasetDefinition) MetadataRecord(io.cdap.cdap.spi.metadata.MetadataRecord) MutationOptions(io.cdap.cdap.spi.metadata.MutationOptions) MetadataDataset(io.cdap.cdap.data2.metadata.dataset.MetadataDataset) Collections(java.util.Collections) HashSet(java.util.HashSet) EnumSet(java.util.EnumSet) Set(java.util.Set) Metadata(io.cdap.cdap.spi.metadata.Metadata) Cursor(io.cdap.cdap.common.metadata.Cursor) MetadataRecord(io.cdap.cdap.spi.metadata.MetadataRecord) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope) MetadataSearchResponse(io.cdap.cdap.proto.metadata.MetadataSearchResponse) Sorting(io.cdap.cdap.spi.metadata.Sorting) SortInfo(io.cdap.cdap.data2.metadata.dataset.SortInfo) MetadataSearchResponse(io.cdap.cdap.proto.metadata.MetadataSearchResponse) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) NamespaceId(io.cdap.cdap.proto.id.NamespaceId)

Example 2 with SearchResponse

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

the class ElasticsearchMetadataStorageTest method testScrollTimeout.

@Test
public void testScrollTimeout() throws IOException, InterruptedException {
    MetadataStorage mds = getMetadataStorage();
    MutationOptions options = MutationOptions.builder().setAsynchronous(false).build();
    List<MetadataRecord> records = IntStream.range(0, 20).boxed().map(i -> new MetadataRecord(MetadataEntity.ofDataset("ns" + i, "ds" + i), new Metadata(MetadataScope.USER, tags("tag", "t" + i), props("p", "v" + i)))).collect(Collectors.toList());
    mds.batch(records.stream().map(r -> new Update(r.getEntity(), r.getMetadata())).collect(Collectors.toList()), options);
    SearchRequest request = SearchRequest.of("t*").setCursorRequested(true).setLimit(5).build();
    SearchResponse response = mds.search(request);
    Assert.assertEquals(5, response.getResults().size());
    Assert.assertNotNull(response.getCursor());
    SearchRequest request2 = SearchRequest.of("t*").setCursor(response.getCursor()).build();
    SearchResponse response2 = mds.search(request2);
    Assert.assertEquals(5, response2.getResults().size());
    // it works despite a cursor and an offset (which is equal to the cursor's)
    SearchRequest request2a = SearchRequest.of("t*").setCursor(response.getCursor()).setOffset(5).build();
    SearchResponse response2a = mds.search(request2a);
    Assert.assertEquals(5, response2a.getOffset());
    Assert.assertEquals(5, response2a.getLimit());
    Assert.assertEquals(response2.getResults(), response2a.getResults());
    // it works despite a cursor and an offset (which is different from the cursor's)
    SearchRequest request2b = SearchRequest.of("t*").setCursor(response.getCursor()).setOffset(8).build();
    SearchResponse response2b = mds.search(request2b);
    Assert.assertEquals(5, response2b.getOffset());
    Assert.assertEquals(5, response2b.getLimit());
    Assert.assertEquals(response2.getResults(), response2b.getResults());
    // sleep 1 sec longer than the configured scroll timeout to invalidate cursor
    TimeUnit.SECONDS.sleep(3);
    SearchResponse response3 = mds.search(request2);
    Assert.assertEquals(response2.getResults(), response3.getResults());
    Assert.assertEquals(response2.getCursor(), response3.getCursor());
    // it works despite an expired cursor and an offset (which is different from the cursor's)
    SearchRequest request3a = SearchRequest.of("t*").setCursor(response.getCursor()).setOffset(8).build();
    SearchResponse response3a = mds.search(request3a);
    Assert.assertEquals(5, response3a.getOffset());
    Assert.assertEquals(5, response3a.getLimit());
    Assert.assertEquals(response2.getResults(), response3a.getResults());
    // create a nonsense cursor and search with that
    Cursor cursor = Cursor.fromString(response.getCursor());
    cursor = new Cursor(cursor, cursor.getOffset(), "nosuchcursor");
    SearchRequest request4 = SearchRequest.of("t*").setCursor(cursor.toString()).build();
    SearchResponse response4 = mds.search(request4);
    // compare only the results, not the entire response (the cursor is different)
    Assert.assertEquals(response2.getResults(), response4.getResults());
    // clean up
    mds.batch(records.stream().map(MetadataRecord::getEntity).map(Drop::new).collect(Collectors.toList()), options);
}
Also used : IntStream(java.util.stream.IntStream) Drop(io.cdap.cdap.spi.metadata.MetadataMutation.Drop) BeforeClass(org.junit.BeforeClass) LoggerFactory(org.slf4j.LoggerFactory) Random(java.util.Random) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) ImmutableList(com.google.common.collect.ImmutableList) ScopedNameOfKind(io.cdap.cdap.spi.metadata.ScopedNameOfKind) Metadata(io.cdap.cdap.spi.metadata.Metadata) Closeables(com.google.common.io.Closeables) MetadataStorageTest(io.cdap.cdap.spi.metadata.MetadataStorageTest) SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) AfterClass(org.junit.AfterClass) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Cursor(io.cdap.cdap.common.metadata.Cursor) Update(io.cdap.cdap.spi.metadata.MetadataMutation.Update) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) Test(org.junit.Test) IOException(java.io.IOException) MetadataKind(io.cdap.cdap.spi.metadata.MetadataKind) ScopedName(io.cdap.cdap.spi.metadata.ScopedName) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope) MetadataRecord(io.cdap.cdap.spi.metadata.MetadataRecord) MutationOptions(io.cdap.cdap.spi.metadata.MutationOptions) Assert(org.junit.Assert) Collections(java.util.Collections) SConfiguration(io.cdap.cdap.common.conf.SConfiguration) SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MutationOptions(io.cdap.cdap.spi.metadata.MutationOptions) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) Metadata(io.cdap.cdap.spi.metadata.Metadata) MetadataRecord(io.cdap.cdap.spi.metadata.MetadataRecord) Update(io.cdap.cdap.spi.metadata.MetadataMutation.Update) Cursor(io.cdap.cdap.common.metadata.Cursor) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) Drop(io.cdap.cdap.spi.metadata.MetadataMutation.Drop) MetadataStorageTest(io.cdap.cdap.spi.metadata.MetadataStorageTest) Test(org.junit.Test)

Example 3 with SearchResponse

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

the class DataPipelineConnectionTest method assertMetadataSearch.

private void assertMetadataSearch(Set<MetadataEntity> appsRelated, String query) throws Exception {
    SearchResponse search = getMetadataAdmin().search(SearchRequest.of(query).build());
    Set<MetadataEntity> actual = search.getResults().stream().map(record -> record.getEntity()).collect(Collectors.toSet());
    Assert.assertEquals(appsRelated, actual);
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Engine(io.cdap.cdap.etl.api.Engine) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) URL(java.net.URL) HttpResponse(io.cdap.common.http.HttpResponse) TimeoutException(java.util.concurrent.TimeoutException) PreviewConfig(io.cdap.cdap.proto.artifact.preview.PreviewConfig) MockSink(io.cdap.cdap.etl.mock.batch.MockSink) GsonBuilder(com.google.gson.GsonBuilder) Constants(io.cdap.cdap.etl.common.Constants) StructuredRecord(io.cdap.cdap.api.data.format.StructuredRecord) BrowseRequest(io.cdap.cdap.etl.api.connector.BrowseRequest) Principal(io.cdap.cdap.proto.security.Principal) MockSource(io.cdap.cdap.etl.mock.batch.MockSource) Gson(com.google.gson.Gson) ArtifactSummary(io.cdap.cdap.api.artifact.ArtifactSummary) Transform(io.cdap.cdap.etl.api.Transform) BrowseEntity(io.cdap.cdap.etl.api.connector.BrowseEntity) Metadata(io.cdap.cdap.spi.metadata.Metadata) Map(java.util.Map) EntityType(io.cdap.cdap.proto.element.EntityType) SearchRequest(io.cdap.cdap.spi.metadata.SearchRequest) MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) URI(java.net.URI) ClassRule(org.junit.ClassRule) PluginInfo(io.cdap.cdap.etl.proto.connection.PluginInfo) EnumSet(java.util.EnumSet) Tasks(io.cdap.cdap.common.utils.Tasks) ImmutableSet(com.google.common.collect.ImmutableSet) ImmutableMap(com.google.common.collect.ImmutableMap) ConnectionEntityId(io.cdap.cdap.proto.id.ConnectionEntityId) SampleResponseCodec(io.cdap.cdap.etl.proto.connection.SampleResponseCodec) Table(io.cdap.cdap.api.dataset.table.Table) Set(java.util.Set) ProgramRunStatus(io.cdap.cdap.proto.ProgramRunStatus) Collectors(java.util.stream.Collectors) Connector(io.cdap.cdap.etl.api.connector.Connector) StandardCharsets(java.nio.charset.StandardCharsets) List(java.util.List) PreviewManager(io.cdap.cdap.app.preview.PreviewManager) MetadataScope(io.cdap.cdap.api.metadata.MetadataScope) FileConnector(io.cdap.cdap.etl.mock.connector.FileConnector) ApplicationManager(io.cdap.cdap.test.ApplicationManager) DataSetManager(io.cdap.cdap.test.DataSetManager) ServiceManager(io.cdap.cdap.test.ServiceManager) IdentityTransform(io.cdap.cdap.etl.mock.transform.IdentityTransform) ApplicationId(io.cdap.cdap.proto.id.ApplicationId) ArtifactScope(io.cdap.cdap.api.artifact.ArtifactScope) StandardPermission(io.cdap.cdap.proto.security.StandardPermission) BeforeClass(org.junit.BeforeClass) SchemaTypeAdapter(io.cdap.cdap.internal.io.SchemaTypeAdapter) TestConfiguration(io.cdap.cdap.test.TestConfiguration) HydratorTestBase(io.cdap.cdap.etl.mock.test.HydratorTestBase) HashMap(java.util.HashMap) Callable(java.util.concurrent.Callable) DefaultHttpRequestConfig(io.cdap.cdap.common.http.DefaultHttpRequestConfig) ProgramType(io.cdap.cdap.proto.ProgramType) ArrayList(java.util.ArrayList) BrowseDetail(io.cdap.cdap.etl.api.connector.BrowseDetail) HashSet(java.util.HashSet) PluginDetail(io.cdap.cdap.etl.proto.connection.PluginDetail) ImmutableList(com.google.common.collect.ImmutableList) PluginValidationTransform(io.cdap.cdap.etl.mock.transform.PluginValidationTransform) Compat(io.cdap.cdap.etl.spark.Compat) HttpRequests(io.cdap.common.http.HttpRequests) ArtifactId(io.cdap.cdap.proto.id.ArtifactId) SampleResponse(io.cdap.cdap.etl.proto.connection.SampleResponse) Nullable(javax.annotation.Nullable) Before(org.junit.Before) Authorizable(io.cdap.cdap.proto.security.Authorizable) HttpMethod(io.cdap.common.http.HttpMethod) PreviewStatus(io.cdap.cdap.app.preview.PreviewStatus) ArtifactSelectorConfig(io.cdap.cdap.etl.proto.ArtifactSelectorConfig) Files(java.nio.file.Files) ConnectionCreationRequest(io.cdap.cdap.etl.proto.connection.ConnectionCreationRequest) BufferedWriter(java.io.BufferedWriter) ETLBatchConfig(io.cdap.cdap.etl.proto.v2.ETLBatchConfig) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) Test(org.junit.Test) IOException(java.io.IOException) Schema(io.cdap.cdap.api.data.schema.Schema) SpecGenerationRequest(io.cdap.cdap.etl.proto.connection.SpecGenerationRequest) File(java.io.File) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) URLEncoder(java.net.URLEncoder) SampleRequest(io.cdap.cdap.etl.api.connector.SampleRequest) ETLStage(io.cdap.cdap.etl.proto.v2.ETLStage) ConnectionId(io.cdap.cdap.etl.proto.connection.ConnectionId) WorkflowManager(io.cdap.cdap.test.WorkflowManager) ConnectorDetail(io.cdap.cdap.etl.proto.connection.ConnectorDetail) AppRequest(io.cdap.cdap.proto.artifact.AppRequest) Assert(org.junit.Assert) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) HttpRequest(io.cdap.common.http.HttpRequest) MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse)

Example 4 with SearchResponse

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

the class DatasetMetadataStorageTest method testCrossNamespacePagination.

// this test is specific to teh DatasetMetadataStorage, because of the specific way it tests pagination:
// it requests offsets that are not a multiple of the page size, which is not supported in all implementations.
@Test
public void testCrossNamespacePagination() throws IOException {
    MetadataStorage mds = getMetadataStorage();
    NamespaceId ns1Id = new NamespaceId("ns1");
    NamespaceId ns2Id = new NamespaceId("ns2");
    MetadataEntity ns1app1 = ns1Id.app("a1").toMetadataEntity();
    MetadataEntity ns1app2 = ns1Id.app("a2").toMetadataEntity();
    MetadataEntity ns1app3 = ns1Id.app("a3").toMetadataEntity();
    MetadataEntity ns2app1 = ns2Id.app("a1").toMetadataEntity();
    MetadataEntity ns2app2 = ns2Id.app("a2").toMetadataEntity();
    mds.batch(ImmutableList.of(new Update(ns1app1, new Metadata(USER, tags("v1"))), new Update(ns1app2, new Metadata(USER, tags("v1"))), new Update(ns1app3, new Metadata(USER, tags("v1"))), new Update(ns2app1, new Metadata(USER, tags("v1"))), new Update(ns2app2, new Metadata(USER, tags("v1")))), MutationOptions.DEFAULT);
    MetadataRecord record11 = new MetadataRecord(ns1app1, new Metadata(USER, tags("v1")));
    MetadataRecord record12 = new MetadataRecord(ns1app2, new Metadata(USER, tags("v1")));
    MetadataRecord record13 = new MetadataRecord(ns1app3, new Metadata(USER, tags("v1")));
    MetadataRecord record21 = new MetadataRecord(ns2app1, new Metadata(USER, tags("v1")));
    MetadataRecord record22 = new MetadataRecord(ns2app2, new Metadata(USER, tags("v1")));
    SearchResponse response = assertResults(mds, SearchRequest.of("*").setLimit(Integer.MAX_VALUE).setCursorRequested(true).build(), record11, record12, record13, record21, record22);
    // iterate over results to find the order in which they are returned
    Iterator<MetadataRecord> resultIter = response.getResults().iterator();
    MetadataRecord[] results = { resultIter.next(), resultIter.next(), resultIter.next(), resultIter.next(), resultIter.next() };
    // get 4 results (guaranteed to have at least one from each namespace), offset 1
    assertResults(mds, SearchRequest.of("*").setCursorRequested(true).setOffset(1).setLimit(4).build(), results[1], results[2], results[3], results[4]);
    // get the first four
    assertResults(mds, SearchRequest.of("*").setCursorRequested(true).setOffset(0).setLimit(4).build(), results[0], results[1], results[2], results[3]);
    // get middle 3
    assertResults(mds, SearchRequest.of("*").setCursorRequested(true).setOffset(1).setLimit(3).build(), results[1], results[2], results[3], results[3]);
    // clean up
    mds.batch(ImmutableList.of(new Drop(ns1app1), new Drop(ns1app2), new Drop(ns1app3), new Drop(ns2app1), new Drop(ns2app2)), MutationOptions.DEFAULT);
}
Also used : MetadataEntity(io.cdap.cdap.api.metadata.MetadataEntity) MetadataStorage(io.cdap.cdap.spi.metadata.MetadataStorage) Metadata(io.cdap.cdap.spi.metadata.Metadata) NamespaceId(io.cdap.cdap.proto.id.NamespaceId) Update(io.cdap.cdap.spi.metadata.MetadataMutation.Update) MetadataRecord(io.cdap.cdap.spi.metadata.MetadataRecord) SearchResponse(io.cdap.cdap.spi.metadata.SearchResponse) Drop(io.cdap.cdap.spi.metadata.MetadataMutation.Drop) MetadataStorageTest(io.cdap.cdap.spi.metadata.MetadataStorageTest) Test(org.junit.Test)

Example 5 with SearchResponse

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

the class MetadataHttpHandler method searchMetadata.

@GET
@Path("/metadata/search")
public void searchMetadata(HttpRequest request, HttpResponder responder, @Nullable @QueryParam("namespaces") List<String> namespaces, @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, namespaces, 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)

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