Files
sdk/api_websearch.go

1268 lines
52 KiB
Go

/*
Hanzo Cloud API
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
API version: v1
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package hanzoai
import (
"bytes"
"context"
"io"
"net/http"
"net/url"
"strings"
)
// WebsearchAPIService WebsearchAPI service
type WebsearchAPIService service
type WebsearchAPIDeleteSearchEngineKeyRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
name string
}
func (r WebsearchAPIDeleteSearchEngineKeyRequest) Execute() (*WebsearchSearchEngineKeyed, *http.Response, error) {
return r.ApiService.DeleteSearchEngineKeyExecute(r)
}
/*
DeleteSearchEngineKey Removes an engine's API key from KMS.
Removes an engine's API key from KMS.
Searches stop using the key at once. Removing a key that is not held answers
the same as removing one that is. 409 when the saved setting would be left with
no engine that can answer — enable bing or ddg first.
SuperAdmin only. 404 for an engine that does not exist, 400 for one that takes
no key, 503 when the settings store or KMS cannot answer.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param name Name is the engine, from the path.
@return WebsearchAPIDeleteSearchEngineKeyRequest
*/
func (a *WebsearchAPIService) DeleteSearchEngineKey(ctx context.Context, name string) WebsearchAPIDeleteSearchEngineKeyRequest {
return WebsearchAPIDeleteSearchEngineKeyRequest{
ApiService: a,
ctx: ctx,
name: name,
}
}
// Execute executes the request
//
// @return WebsearchSearchEngineKeyed
func (a *WebsearchAPIService) DeleteSearchEngineKeyExecute(r WebsearchAPIDeleteSearchEngineKeyRequest) (*WebsearchSearchEngineKeyed, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebsearchSearchEngineKeyed
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.DeleteSearchEngineKey")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/engines/{name}/key"
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
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 ProblemDetails
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
}
type WebsearchAPIDeleteWebsearchSearchRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIDeleteWebsearchSearchRequest) Execute() (*http.Response, error) {
return r.ApiService.DeleteWebsearchSearchExecute(r)
}
/*
DeleteWebsearchSearch Web meta-search, in the SearXNG JSON envelope.
Answers {query, number_of_results, results:[{url, title, content, engine}]} — the exact /search?format=json contract a SearXNG client decodes, so an agent tool configured against SearXNG reaches this with no change. `q` is the query and `language` narrows it; both are read from the QUERY STRING.
Served in-process by a Go meta-search over the engines the platform enables (GET /v1/websearch/engines). The enabled engines run concurrently and their hits are merged, deduplicated by normalised URL (host and path, trailing slash and fragment dropped, query kept — distinct queries are distinct results) and capped at 30. Hits several engines agree on rank first.
TWO WAYS IN, one-way equivalent, and no third: a validated principal — the same gate the whole data plane uses — passes straight through, and a caller without one must present the shared service key as X-API-Key, compared in constant time. A deployment with no key configured answers 503 rather than opening the surface to everyone, and a missing or wrong key is 401. It is never an open proxy. There is no tenant scoping beyond that gate, and there is nothing to scope: the results are public web pages, identical for every caller.
It fails SOFT on the engines and closed only on the gate. An engine that errors or is served a bot-challenge page contributes zero results and never fails the request, so an empty `results` is a real answer — nothing was found — and not an outage. The array is always present, never null.
The one thing to get right: every method answers identically. This is one handler registered for all of them, and it reads only the query string, so a body sent on the write verbs is ignored rather than refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIDeleteWebsearchSearchRequest
*/
func (a *WebsearchAPIService) DeleteWebsearchSearch(ctx context.Context) WebsearchAPIDeleteWebsearchSearchRequest {
return WebsearchAPIDeleteWebsearchSearchRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) DeleteWebsearchSearchExecute(r WebsearchAPIDeleteWebsearchSearchRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.DeleteWebsearchSearch")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/search"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPIGetWebsearchSearchRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIGetWebsearchSearchRequest) Execute() (*http.Response, error) {
return r.ApiService.GetWebsearchSearchExecute(r)
}
/*
GetWebsearchSearch Web meta-search, in the SearXNG JSON envelope.
Answers {query, number_of_results, results:[{url, title, content, engine}]} — the exact /search?format=json contract a SearXNG client decodes, so an agent tool configured against SearXNG reaches this with no change. `q` is the query and `language` narrows it; both are read from the QUERY STRING.
Served in-process by a Go meta-search over the engines the platform enables (GET /v1/websearch/engines). The enabled engines run concurrently and their hits are merged, deduplicated by normalised URL (host and path, trailing slash and fragment dropped, query kept — distinct queries are distinct results) and capped at 30. Hits several engines agree on rank first.
TWO WAYS IN, one-way equivalent, and no third: a validated principal — the same gate the whole data plane uses — passes straight through, and a caller without one must present the shared service key as X-API-Key, compared in constant time. A deployment with no key configured answers 503 rather than opening the surface to everyone, and a missing or wrong key is 401. It is never an open proxy. There is no tenant scoping beyond that gate, and there is nothing to scope: the results are public web pages, identical for every caller.
It fails SOFT on the engines and closed only on the gate. An engine that errors or is served a bot-challenge page contributes zero results and never fails the request, so an empty `results` is a real answer — nothing was found — and not an outage. The array is always present, never null.
The one thing to get right: every method answers identically. This is one handler registered for all of them, and it reads only the query string, so a body sent on the write verbs is ignored rather than refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIGetWebsearchSearchRequest
*/
func (a *WebsearchAPIService) GetWebsearchSearch(ctx context.Context) WebsearchAPIGetWebsearchSearchRequest {
return WebsearchAPIGetWebsearchSearchRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) GetWebsearchSearchExecute(r WebsearchAPIGetWebsearchSearchRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.GetWebsearchSearch")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/search"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPIListSearchEnginesRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIListSearchEnginesRequest) Execute() (*WebsearchSearchEngines, *http.Response, error) {
return r.ApiService.ListSearchEnginesExecute(r)
}
/*
ListSearchEngines Lists every engine web search can run and how the platform runs it.
Lists every engine web search can run and how the platform runs it.
For each engine: whether it is enabled and its place in the run order, whether
it takes an API key and whether it needs one, whether the platform holds that
key (`keyed` — the key itself is never returned), whether it answers from this
cluster as things stand (`available`), the option values it is asked with and
the options it supports with their bounds. Enabled engines come first, in the
order they run.
`saved` is false when no setting is stored, and the engines shown enabled are
then the default: Mojeek alone when its key is held, otherwise bing, ddg and
Mojeek — Mojeek's keyless page does not answer from this cluster on its own.
SuperAdmin only. 503 when the settings store or KMS cannot answer: a board
that guessed would show an operator a configuration nobody saved.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIListSearchEnginesRequest
*/
func (a *WebsearchAPIService) ListSearchEngines(ctx context.Context) WebsearchAPIListSearchEnginesRequest {
return WebsearchAPIListSearchEnginesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return WebsearchSearchEngines
func (a *WebsearchAPIService) ListSearchEnginesExecute(r WebsearchAPIListSearchEnginesRequest) (*WebsearchSearchEngines, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebsearchSearchEngines
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.ListSearchEngines")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/engines"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
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 ProblemDetails
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
}
type WebsearchAPIPatchWebsearchSearchRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIPatchWebsearchSearchRequest) Execute() (*http.Response, error) {
return r.ApiService.PatchWebsearchSearchExecute(r)
}
/*
PatchWebsearchSearch Web meta-search, in the SearXNG JSON envelope.
Answers {query, number_of_results, results:[{url, title, content, engine}]} — the exact /search?format=json contract a SearXNG client decodes, so an agent tool configured against SearXNG reaches this with no change. `q` is the query and `language` narrows it; both are read from the QUERY STRING.
Served in-process by a Go meta-search over the engines the platform enables (GET /v1/websearch/engines). The enabled engines run concurrently and their hits are merged, deduplicated by normalised URL (host and path, trailing slash and fragment dropped, query kept — distinct queries are distinct results) and capped at 30. Hits several engines agree on rank first.
TWO WAYS IN, one-way equivalent, and no third: a validated principal — the same gate the whole data plane uses — passes straight through, and a caller without one must present the shared service key as X-API-Key, compared in constant time. A deployment with no key configured answers 503 rather than opening the surface to everyone, and a missing or wrong key is 401. It is never an open proxy. There is no tenant scoping beyond that gate, and there is nothing to scope: the results are public web pages, identical for every caller.
It fails SOFT on the engines and closed only on the gate. An engine that errors or is served a bot-challenge page contributes zero results and never fails the request, so an empty `results` is a real answer — nothing was found — and not an outage. The array is always present, never null.
The one thing to get right: every method answers identically. This is one handler registered for all of them, and it reads only the query string, so a body sent on the write verbs is ignored rather than refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIPatchWebsearchSearchRequest
*/
func (a *WebsearchAPIService) PatchWebsearchSearch(ctx context.Context) WebsearchAPIPatchWebsearchSearchRequest {
return WebsearchAPIPatchWebsearchSearchRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) PatchWebsearchSearchExecute(r WebsearchAPIPatchWebsearchSearchRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.PatchWebsearchSearch")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/search"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPIPostWebsearchScrapeRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIPostWebsearchScrapeRequest) Execute() (*http.Response, error) {
return r.ApiService.PostWebsearchScrapeExecute(r)
}
/*
PostWebsearchScrape Fetch one page and get its extracted markdown, in the firecrawl envelope.
Takes {url} and answers {success, data:{markdown, metadata}} — the exact contract a firecrawl client decodes. The fetch, extraction and optional browser render run in-process; there is no crawler pod to be down.
The shared service key is required as an Authorization Bearer, compared in constant time: unset on the deployment is 503, missing or wrong is 401. Unlike search, a validated principal does NOT substitute for it — this is the service-to-service endpoint.
A page is archived under the caller's own org and project, taken from the verified principal when there is one, so a scrape lands in the same corpus /v1/crawl fills and a URL already read under that scope is answered from the archive without touching the network. A service caller carrying no principal shares the unscoped prefix.
The URL is caller-supplied and fetched from INSIDE the cluster, which makes this a request-forgery primitive by construction: in-namespace service DNS and a cloud metadata endpoint that hands credentials to anyone who asks are both a resolution away. Only http and https are accepted, and every address actually dialled must be public unicast — loopback, link-local, private and multicast are refused. The check lives in the DIALER rather than on the hostname, because resolving a name to validate it and then letting the transport resolve it again is a gap DNS rebinding walks straight through; redirects re-enter the same dialer, so a public URL that bounces to the metadata address is refused at the hop that matters.
The one thing to get right: FAILURE IS 200. A missing or unparseable url, a body over the 1 MiB read cap, and a fetch that could not be completed all answer HTTP 200 with success:false and a reason — a firecrawl client reads data.success, not the status line. Only the two auth refusals use a status code, so a caller that branches on HTTP status alone will read every failed scrape as a success.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIPostWebsearchScrapeRequest
*/
func (a *WebsearchAPIService) PostWebsearchScrape(ctx context.Context) WebsearchAPIPostWebsearchScrapeRequest {
return WebsearchAPIPostWebsearchScrapeRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) PostWebsearchScrapeExecute(r WebsearchAPIPostWebsearchScrapeRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.PostWebsearchScrape")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/scrape"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPIPostWebsearchSearchRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIPostWebsearchSearchRequest) Execute() (*http.Response, error) {
return r.ApiService.PostWebsearchSearchExecute(r)
}
/*
PostWebsearchSearch Web meta-search, in the SearXNG JSON envelope.
Answers {query, number_of_results, results:[{url, title, content, engine}]} — the exact /search?format=json contract a SearXNG client decodes, so an agent tool configured against SearXNG reaches this with no change. `q` is the query and `language` narrows it; both are read from the QUERY STRING.
Served in-process by a Go meta-search over the engines the platform enables (GET /v1/websearch/engines). The enabled engines run concurrently and their hits are merged, deduplicated by normalised URL (host and path, trailing slash and fragment dropped, query kept — distinct queries are distinct results) and capped at 30. Hits several engines agree on rank first.
TWO WAYS IN, one-way equivalent, and no third: a validated principal — the same gate the whole data plane uses — passes straight through, and a caller without one must present the shared service key as X-API-Key, compared in constant time. A deployment with no key configured answers 503 rather than opening the surface to everyone, and a missing or wrong key is 401. It is never an open proxy. There is no tenant scoping beyond that gate, and there is nothing to scope: the results are public web pages, identical for every caller.
It fails SOFT on the engines and closed only on the gate. An engine that errors or is served a bot-challenge page contributes zero results and never fails the request, so an empty `results` is a real answer — nothing was found — and not an outage. The array is always present, never null.
The one thing to get right: every method answers identically. This is one handler registered for all of them, and it reads only the query string, so a body sent on the write verbs is ignored rather than refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIPostWebsearchSearchRequest
*/
func (a *WebsearchAPIService) PostWebsearchSearch(ctx context.Context) WebsearchAPIPostWebsearchSearchRequest {
return WebsearchAPIPostWebsearchSearchRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) PostWebsearchSearchExecute(r WebsearchAPIPostWebsearchSearchRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.PostWebsearchSearch")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/search"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPIPutWebsearchSearchRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
}
func (r WebsearchAPIPutWebsearchSearchRequest) Execute() (*http.Response, error) {
return r.ApiService.PutWebsearchSearchExecute(r)
}
/*
PutWebsearchSearch Web meta-search, in the SearXNG JSON envelope.
Answers {query, number_of_results, results:[{url, title, content, engine}]} — the exact /search?format=json contract a SearXNG client decodes, so an agent tool configured against SearXNG reaches this with no change. `q` is the query and `language` narrows it; both are read from the QUERY STRING.
Served in-process by a Go meta-search over the engines the platform enables (GET /v1/websearch/engines). The enabled engines run concurrently and their hits are merged, deduplicated by normalised URL (host and path, trailing slash and fragment dropped, query kept — distinct queries are distinct results) and capped at 30. Hits several engines agree on rank first.
TWO WAYS IN, one-way equivalent, and no third: a validated principal — the same gate the whole data plane uses — passes straight through, and a caller without one must present the shared service key as X-API-Key, compared in constant time. A deployment with no key configured answers 503 rather than opening the surface to everyone, and a missing or wrong key is 401. It is never an open proxy. There is no tenant scoping beyond that gate, and there is nothing to scope: the results are public web pages, identical for every caller.
It fails SOFT on the engines and closed only on the gate. An engine that errors or is served a bot-challenge page contributes zero results and never fails the request, so an empty `results` is a real answer — nothing was found — and not an outage. The array is always present, never null.
The one thing to get right: every method answers identically. This is one handler registered for all of them, and it reads only the query string, so a body sent on the write verbs is ignored rather than refused.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPIPutWebsearchSearchRequest
*/
func (a *WebsearchAPIService) PutWebsearchSearch(ctx context.Context) WebsearchAPIPutWebsearchSearchRequest {
return WebsearchAPIPutWebsearchSearchRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
func (a *WebsearchAPIService) PutWebsearchSearchExecute(r WebsearchAPIPutWebsearchSearchRequest) (*http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.PutWebsearchSearch")
if err != nil {
return nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/search"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// to determine the Content-Type header
localVarHTTPContentTypes := []string{}
// set Content-Type header
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
if localVarHTTPContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
}
// to determine the Accept header
localVarHTTPHeaderAccepts := []string{}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
if err != nil {
return nil, err
}
localVarHTTPResponse, err := a.client.callAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarHTTPResponse, err
}
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
localVarHTTPResponse.Body.Close()
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
if err != nil {
return localVarHTTPResponse, err
}
if localVarHTTPResponse.StatusCode >= 300 {
newErr := &GenericOpenAPIError{
body: localVarBody,
error: localVarHTTPResponse.Status,
}
return localVarHTTPResponse, newErr
}
return localVarHTTPResponse, nil
}
type WebsearchAPISearchWebRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
websearchWebSearchQuery *WebsearchWebSearchQuery
}
func (r WebsearchAPISearchWebRequest) WebsearchWebSearchQuery(websearchWebSearchQuery WebsearchWebSearchQuery) WebsearchAPISearchWebRequest {
r.websearchWebSearchQuery = &websearchWebSearchQuery
return r
}
func (r WebsearchAPISearchWebRequest) Execute() (*WebsearchWebSearchResults, *http.Response, error) {
return r.ApiService.SearchWebExecute(r)
}
/*
SearchWeb Search the live web
Searches the live web and answers with ranked results.
This is the fleet's path to what is happening RIGHT NOW — today's weather, an
outage, a release that postdates any model's training. `q` is the query and
`language` narrows it to a locale. The answer is `{query, number_of_results,
results:[{url, title, content, engine}]}`, where `content` is the ENGINE's
snippet and not the page: read a page with POST /v1/crawl.
It is served in-process by a Go meta-search over the engines the platform
enables (GET /v1/websearch/engines): Mojeek's API by default when the platform
holds its key, otherwise the keyless engines that answer from this cluster. The
enabled engines run concurrently and their hits are merged, deduplicated by
normalised URL (host and path, trailing slash and fragment dropped, query kept,
so distinct queries stay distinct results) and capped at 30. Hits that several
engines agree on rank first; ties keep a stable order.
It fails SOFT on the engines. One that errors, times out or is served a
bot-challenge page contributes zero results and never fails the call, so an
empty `results` is a real answer — nothing was found — and not an outage. The
array is always present, never null.
Two refusals in the order they have to be asked, both in the PREAMBLE. A typed
op is also an MCP tool, a call-plane operation, a graph field and a CLI
command, and every one of those invokes it with no route and therefore no
middleware — so what admits a caller here is asked where every caller reaches
it rather than in a middleware only one of them passes through.
A VALIDATED PRINCIPAL IS REQUIRED, and there is no tenant beyond that: the
results are public web pages, identical for every caller, so nothing here is
scoped and nothing here can leak across orgs.
THEN THE ANTI-FORGERY TOKEN, immediately before the money, because that is
what it is about. This search is the SAME bought meta-search the compat
endpoint runs — the engines cost, and account.Shared/meter.go bills the
caller's ledger for the answer — so a page the caller never visited must not
be able to spend for them by sending their browser here with a cookie they
already hold. Nothing leaks; the answer is unreadable cross-origin. What
moves is money.
It is account's control, the one every operation in this estate asks, and it
is a no-op the moment a caller PRESENTS a credential (Bearer, gateway, API
key) — which is every service and console caller here — so it costs a CLI, an
agent and an API client nothing. Only the ambient-cookie path is asked for the
echoed token. The raw /v1/websearch/search route asks the same control on its
group (see Mount), so the two addresses of one search are admitted alike.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPISearchWebRequest
*/
func (a *WebsearchAPIService) SearchWeb(ctx context.Context) WebsearchAPISearchWebRequest {
return WebsearchAPISearchWebRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return WebsearchWebSearchResults
func (a *WebsearchAPIService) SearchWebExecute(r WebsearchAPISearchWebRequest) (*WebsearchWebSearchResults, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebsearchWebSearchResults
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.SearchWeb")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.websearchWebSearchQuery == nil {
return localVarReturnValue, nil, reportError("websearchWebSearchQuery is required and must be specified")
}
// 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", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.websearchWebSearchQuery
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 ProblemDetails
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
}
type WebsearchAPISetSearchEngineKeyRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
name string
websearchSearchEngineKey *WebsearchSearchEngineKey
}
func (r WebsearchAPISetSearchEngineKeyRequest) WebsearchSearchEngineKey(websearchSearchEngineKey WebsearchSearchEngineKey) WebsearchAPISetSearchEngineKeyRequest {
r.websearchSearchEngineKey = &websearchSearchEngineKey
return r
}
func (r WebsearchAPISetSearchEngineKeyRequest) Execute() (*WebsearchSearchEngineKeyed, *http.Response, error) {
return r.ApiService.SetSearchEngineKeyExecute(r)
}
/*
SetSearchEngineKey Seals an engine's API key in KMS, replacing any key held.
Seals an engine's API key in KMS, replacing any key held.
The key is the platform's: it lives in KMS under the platform org admin at
/websearch/<ENGINE>_KEY (env prod), every search reads it from there at the
moment it runs, and no
operation returns, logs or echoes it — the answer says only that a key is now
held. Only an engine that takes a key accepts one (mojeek, brave).
SuperAdmin only. 404 for an engine that does not exist, 400 for one that takes
no key or a key that is empty, longer than 4096 bytes or holds whitespace or
control characters, 503 when KMS cannot take it.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param name Name is the engine, from the path.
@return WebsearchAPISetSearchEngineKeyRequest
*/
func (a *WebsearchAPIService) SetSearchEngineKey(ctx context.Context, name string) WebsearchAPISetSearchEngineKeyRequest {
return WebsearchAPISetSearchEngineKeyRequest{
ApiService: a,
ctx: ctx,
name: name,
}
}
// Execute executes the request
//
// @return WebsearchSearchEngineKeyed
func (a *WebsearchAPIService) SetSearchEngineKeyExecute(r WebsearchAPISetSearchEngineKeyRequest) (*WebsearchSearchEngineKeyed, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebsearchSearchEngineKeyed
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.SetSearchEngineKey")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/engines/{name}/key"
localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.websearchSearchEngineKey == nil {
return localVarReturnValue, nil, reportError("websearchSearchEngineKey is required and must be specified")
}
// 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", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.websearchSearchEngineKey
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 ProblemDetails
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
}
type WebsearchAPISetSearchEnginesRequest struct {
ctx context.Context
ApiService *WebsearchAPIService
websearchSearchEnginesSet *WebsearchSearchEnginesSet
}
func (r WebsearchAPISetSearchEnginesRequest) WebsearchSearchEnginesSet(websearchSearchEnginesSet WebsearchSearchEnginesSet) WebsearchAPISetSearchEnginesRequest {
r.websearchSearchEnginesSet = &websearchSearchEnginesSet
return r
}
func (r WebsearchAPISetSearchEnginesRequest) Execute() (*WebsearchSearchEngines, *http.Response, error) {
return r.ApiService.SetSearchEnginesExecute(r)
}
/*
SetSearchEngines Replaces the platform's web search engine setting and answers the result.
Replaces the platform's web search engine setting and answers the result.
`enabled` lists the engines searches run, in order — at least one, each a
registered engine named once, and at least one that is available (needs no key
here, or its key is held). `options` gives each engine's values by name; an
engine or a field left out takes its default, because the setting replaces the
stored one whole. A count must lie within the engine's bounds, a language is a
tag like `en` or `en-US`, a region a two-letter country code, and an option the
engine does not support is refused.
SuperAdmin only. 400 names every problem with the setting at once; 503 when
the settings store or KMS cannot answer. The answer is the engine list as it
now stands, so the caller sees the effect without a second read.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return WebsearchAPISetSearchEnginesRequest
*/
func (a *WebsearchAPIService) SetSearchEngines(ctx context.Context) WebsearchAPISetSearchEnginesRequest {
return WebsearchAPISetSearchEnginesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return WebsearchSearchEngines
func (a *WebsearchAPIService) SetSearchEnginesExecute(r WebsearchAPISetSearchEnginesRequest) (*WebsearchSearchEngines, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *WebsearchSearchEngines
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "WebsearchAPIService.SetSearchEngines")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/websearch/engines"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.websearchSearchEnginesSet == nil {
return localVarReturnValue, nil, reportError("websearchSearchEnginesSet is required and must be specified")
}
// 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", "application/problem+json"}
// set Accept header
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
if localVarHTTPHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
}
// body params
localVarPostBody = r.websearchSearchEnginesSet
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 ProblemDetails
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
}