Search in sources :

Example 16 with SearchResponse

use of com.google.cloud.retail.v2.SearchResponse in project SonosOneDriveServer by bertique.

the class SonosService method search.

@Override
public SearchResponse search(Search parameters) throws CustomFault {
    logger.debug("search");
    GraphAuth auth = getGraphAuth();
    String path = String.format("/me/drive/root/search(q='%s')", parameters.getTerm());
    String skipToken = null;
    if (parameters.getIndex() > 0) {
        skipToken = getSkipToken(path, parameters.getIndex(), auth);
    }
    String json = graphApiGetRequest(path, parameters.getCount(), skipToken, auth);
    SearchResponse response = new SearchResponse();
    MediaList ml = new MediaList();
    ml = parseMediaListResponse(auth.getHouseholdId(), json);
    // Remove 1 since personal vault is not included in response
    ml.setTotal(ml.getTotal());
    ml.setIndex(parameters.getIndex());
    response.setSearchResult(ml);
    return response;
}
Also used : MediaList(com.sonos.services._1.MediaList) GraphAuth(me.michaeldick.sonosonedrive.model.GraphAuth) SearchResponse(com.sonos.services._1.SearchResponse)

Aggregations

SearchResponse (com.google.cloud.retail.v2.SearchResponse)14 Test (org.junit.Test)8 SearchRequest (com.google.cloud.retail.v2.SearchRequest)7 SearchServiceClient (com.google.cloud.retail.v2.SearchServiceClient)7 BoostSpec (com.google.cloud.retail.v2.SearchRequest.BoostSpec)1 ConditionBoostSpec (com.google.cloud.retail.v2.SearchRequest.BoostSpec.ConditionBoostSpec)1 FacetSpec (com.google.cloud.retail.v2.SearchRequest.FacetSpec)1 FacetKey (com.google.cloud.retail.v2.SearchRequest.FacetSpec.FacetKey)1 QueryExpansionSpec (com.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec)1 Condition (com.google.cloud.retail.v2.SearchRequest.QueryExpansionSpec.Condition)1 SearchPagedResponse (com.google.cloud.retail.v2.SearchServiceClient.SearchPagedResponse)1 AbstractMessage (com.google.protobuf.AbstractMessage)1 MediaList (com.sonos.services._1.MediaList)1 SearchResponse (com.sonos.services._1.SearchResponse)1 ArrayList (java.util.ArrayList)1 GraphAuth (me.michaeldick.sonosonedrive.model.GraphAuth)1