/* Libre Graph API Libre Graph is a free API for cloud collaboration inspired by the MS Graph API. API version: v1.0.8 */ // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. package libregraph import ( "bytes" "context" "io" "net/http" "net/url" ) // SearchApiService SearchApi service type SearchApiService service type ApiSearchQueryRequest struct { ctx context.Context ApiService *SearchApiService searchQueryRequest *SearchQueryRequest expand *[]string } func (r ApiSearchQueryRequest) SearchQueryRequest(searchQueryRequest SearchQueryRequest) ApiSearchQueryRequest { r.searchQueryRequest = &searchQueryRequest return r } // Relationships to expand inline on each hit's driveItem. Only `thumbnails` is supported, attaching a preview thumbnail set for thumbnailable mime types. Libregraph extension: MS Graph search has no $expand and returns no thumbnails on search hits. func (r ApiSearchQueryRequest) Expand(expand []string) ApiSearchQueryRequest { r.expand = &expand return r } func (r ApiSearchQueryRequest) Execute() (*SearchQuery200Response, *http.Response, error) { return r.ApiService.SearchQueryExecute(r) } /* SearchQuery Search for resources Run a specified search query. Search results are provided in the response. The search endpoint allows clients to search for resources across all accessible spaces and retrieve aggregated metadata (facets) about the result set. Aggregations can be used to group results by properties such as file type, author, or any indexed metadata field. This is useful for building faceted search UIs or computing statistics about the result set. The query string uses KQL (Keyword Query Language) syntax for filtering. Results are sorted by relevance unless the request specifies `sortProperties`. Modeled on the MS Graph search query endpoint (https://learn.microsoft.com/en-us/graph/api/search-query). Request and response follow the MS Graph resource types; Libregraph additions carry the `@libre.graph.` prefix. @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). @return ApiSearchQueryRequest */ func (a *SearchApiService) SearchQuery(ctx context.Context) ApiSearchQueryRequest { return ApiSearchQueryRequest{ ApiService: a, ctx: ctx, } } // Execute executes the request // @return SearchQuery200Response func (a *SearchApiService) SearchQueryExecute(r ApiSearchQueryRequest) (*SearchQuery200Response, *http.Response, error) { var ( localVarHTTPMethod = http.MethodPost localVarPostBody interface{} formFiles []formFile localVarReturnValue *SearchQuery200Response ) localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "SearchApiService.SearchQuery") if err != nil { return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} } localVarPath := localBasePath + "/v1beta1/search/query" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} localVarFormParams := url.Values{} if r.searchQueryRequest == nil { return localVarReturnValue, nil, reportError("searchQueryRequest is required and must be specified") } if r.expand != nil { parameterAddToHeaderOrQuery(localVarQueryParams, "$expand", r.expand, "form", "csv") } // to determine the Content-Type header localVarHTTPContentTypes := []string{"application/json"} // set Content-Type header localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) if localVarHTTPContentType != "" { localVarHeaderParams["Content-Type"] = localVarHTTPContentType } // to determine the Accept header localVarHTTPHeaderAccepts := []string{"application/json"} // set Accept header localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) if localVarHTTPHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept } // body params localVarPostBody = r.searchQueryRequest req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) if err != nil { return localVarReturnValue, nil, err } localVarHTTPResponse, err := a.client.callAPI(req) if err != nil || localVarHTTPResponse == nil { return localVarReturnValue, localVarHTTPResponse, err } localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) localVarHTTPResponse.Body.Close() localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) if err != nil { return localVarReturnValue, localVarHTTPResponse, err } if localVarHTTPResponse.StatusCode >= 300 { newErr := &GenericOpenAPIError{ body: localVarBody, error: localVarHTTPResponse.Status, } var v OdataError err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { newErr.error = err.Error() return localVarReturnValue, localVarHTTPResponse, newErr } newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) newErr.model = v return localVarReturnValue, localVarHTTPResponse, newErr } err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) if err != nil { newErr := &GenericOpenAPIError{ body: localVarBody, error: err.Error(), } return localVarReturnValue, localVarHTTPResponse, newErr } return localVarReturnValue, localVarHTTPResponse, nil }