Files
sdk/api_index.go

2109 lines
74 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"
)
// IndexAPIService IndexAPI service
type IndexAPIService service
type IndexAPIDeleteIndexIndexesByUidRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
}
func (r IndexAPIDeleteIndexIndexesByUidRequest) Execute() (*IndexIndexEnqueued, *http.Response, error) {
return r.ApiService.DeleteIndexIndexesByUidExecute(r)
}
/*
DeleteIndexIndexesByUid Deletes an index and everything in it.
Deletes an index and everything in it.
Drops the index and every document in it from the caller's own org, and
answers the dialect's EnqueuedTask. This is the only way to retire an index;
without it a mistaken uid is permanent. Deleting an index that is not there
succeeds, so a cleanup pass is safe to re-run.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of
later work: the documents are already gone when this answers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIDeleteIndexIndexesByUidRequest
*/
func (a *IndexAPIService) DeleteIndexIndexesByUid(ctx context.Context, uid string) IndexAPIDeleteIndexIndexesByUidRequest {
return IndexAPIDeleteIndexIndexesByUidRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexEnqueued
func (a *IndexAPIService) DeleteIndexIndexesByUidExecute(r IndexAPIDeleteIndexIndexesByUidRequest) (*IndexIndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.DeleteIndexIndexesByUid")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -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 IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
id string
}
func (r IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest) Execute() (*IndexIndexEnqueued, *http.Response, error) {
return r.ApiService.DeleteIndexIndexesByUidDocumentsByIdExecute(r)
}
/*
DeleteIndexIndexesByUidDocumentsById Deletes one document by its primary key.
Deletes one document by its primary key.
Removes the document from the caller's own org and answers the dialect's
EnqueuedTask. Deleting a key that is not there succeeds, so a client
reconciling its own corpus can delete without checking first.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of
later work: the document is already gone when this answers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@param id
@return IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest
*/
func (a *IndexAPIService) DeleteIndexIndexesByUidDocumentsById(ctx context.Context, uid string, id string) IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest {
return IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest{
ApiService: a,
ctx: ctx,
uid: uid,
id: id,
}
}
// Execute executes the request
//
// @return IndexIndexEnqueued
func (a *IndexAPIService) DeleteIndexIndexesByUidDocumentsByIdExecute(r IndexAPIDeleteIndexIndexesByUidDocumentsByIdRequest) (*IndexIndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodDelete
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.DeleteIndexIndexesByUidDocumentsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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 IndexAPIGetIndexHealthRequest struct {
ctx context.Context
ApiService *IndexAPIService
}
func (r IndexAPIGetIndexHealthRequest) Execute() (*IndexIndexHealth, *http.Response, error) {
return r.ApiService.GetIndexHealthExecute(r)
}
/*
GetIndexHealth Reports whether the search plane can serve.
Reports whether the search plane can serve.
Answers the dialect's `{"status":"available"}` when the index store is
readable. It FAILS CLOSED — an unreadable store answers 503 with
`{"status":"unavailable"}` rather than an empty result set, because a
Meilisearch client probes this before it will use a server at all and a
cheerful 200 over a broken volume turns "search is down" into "nothing
matched". It requires no principal and reads no tenant data.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return IndexAPIGetIndexHealthRequest
*/
func (a *IndexAPIService) GetIndexHealth(ctx context.Context) IndexAPIGetIndexHealthRequest {
return IndexAPIGetIndexHealthRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return IndexIndexHealth
func (a *IndexAPIService) GetIndexHealthExecute(r IndexAPIGetIndexHealthRequest) (*IndexIndexHealth, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexHealth
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexHealth")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/health"
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,
}
if localVarHTTPResponse.StatusCode == 503 {
var v IndexIndexHealth
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
}
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 IndexAPIGetIndexIndexesRequest struct {
ctx context.Context
ApiService *IndexAPIService
}
func (r IndexAPIGetIndexIndexesRequest) Execute() (*IndexIndexList, *http.Response, error) {
return r.ApiService.GetIndexIndexesExecute(r)
}
/*
GetIndexIndexes Lists the indexes your org holds.
Lists the indexes your org holds.
Answers every index in the caller's own org with its primary key and
timestamps. Without it an index whose uid a caller has forgotten is
unreachable — there is no other way to enumerate what an org holds. The page
is the whole set: an org's index count is small by construction, so `limit`
and `total` both report it.
The tenant is the org minted from the VALIDATED bearer's owner claim, never a
client-supplied header, and two orgs may both hold an index named "messages"
without either seeing the other. Without a validated principal the answer is
403 carrying the dialect's `invalid_api_key` body.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return IndexAPIGetIndexIndexesRequest
*/
func (a *IndexAPIService) GetIndexIndexes(ctx context.Context) IndexAPIGetIndexIndexesRequest {
return IndexAPIGetIndexIndexesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return IndexIndexList
func (a *IndexAPIService) GetIndexIndexesExecute(r IndexAPIGetIndexIndexesRequest) (*IndexIndexList, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexList
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexIndexes")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes"
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 IndexAPIGetIndexIndexesByUidRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
}
func (r IndexAPIGetIndexIndexesByUidRequest) Execute() (*IndexIndexView, *http.Response, error) {
return r.ApiService.GetIndexIndexesByUidExecute(r)
}
/*
GetIndexIndexesByUid Reads one index's definition.
Reads one index's definition.
Answers the index's uid, primary key and timestamps. An index this org does
not hold answers 404 carrying the dialect's `index_not_found` — the code a
Meilisearch client reads as permission to create it, which is why this is a
refusal rather than an empty object.
The uid is scoped to the caller's own org, so another tenant's index is
indistinguishable from one that never existed: this surface is not an
existence oracle.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIGetIndexIndexesByUidRequest
*/
func (a *IndexAPIService) GetIndexIndexesByUid(ctx context.Context, uid string) IndexAPIGetIndexIndexesByUidRequest {
return IndexAPIGetIndexIndexesByUidRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexView
func (a *IndexAPIService) GetIndexIndexesByUidExecute(r IndexAPIGetIndexIndexesByUidRequest) (*IndexIndexView, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexView
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexIndexesByUid")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -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 IndexAPIGetIndexIndexesByUidDocumentsRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
limit *string
offset *string
}
func (r IndexAPIGetIndexIndexesByUidDocumentsRequest) Limit(limit string) IndexAPIGetIndexIndexesByUidDocumentsRequest {
r.limit = &limit
return r
}
func (r IndexAPIGetIndexIndexesByUidDocumentsRequest) Offset(offset string) IndexAPIGetIndexIndexesByUidDocumentsRequest {
r.offset = &offset
return r
}
func (r IndexAPIGetIndexIndexesByUidDocumentsRequest) Execute() (*IndexIndexDocuments, *http.Response, error) {
return r.ApiService.GetIndexIndexesByUidDocumentsExecute(r)
}
/*
GetIndexIndexesByUidDocuments Pages through the documents in an index.
Pages through the documents in an index.
Answers the org's stored documents in insertion order, whole, with the page's
bounds and the index's total. It is the enumeration surface — search ranks by
relevance and cannot walk a corpus — so a caller reconciling what it has
written reads it here.
An index this org does not hold answers 404 carrying the dialect's
`index_not_found`.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIGetIndexIndexesByUidDocumentsRequest
*/
func (a *IndexAPIService) GetIndexIndexesByUidDocuments(ctx context.Context, uid string) IndexAPIGetIndexIndexesByUidDocumentsRequest {
return IndexAPIGetIndexIndexesByUidDocumentsRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexDocuments
func (a *IndexAPIService) GetIndexIndexesByUidDocumentsExecute(r IndexAPIGetIndexIndexesByUidDocumentsRequest) (*IndexIndexDocuments, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexDocuments
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexIndexesByUidDocuments")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.limit != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "limit", r.limit, "form", "")
}
if r.offset != nil {
parameterAddToHeaderOrQuery(localVarQueryParams, "offset", r.offset, "form", "")
}
// 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 IndexAPIGetIndexIndexesByUidDocumentsByIdRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
id string
}
func (r IndexAPIGetIndexIndexesByUidDocumentsByIdRequest) Execute() (interface{}, *http.Response, error) {
return r.ApiService.GetIndexIndexesByUidDocumentsByIdExecute(r)
}
/*
GetIndexIndexesByUidDocumentsById Reads one document by its primary key.
Reads one document by its primary key.
Answers the stored document exactly as it was written — this surface keeps
documents whole rather than projecting them, so what comes back is what went
in. A primary key this index does not hold answers 404 carrying the dialect's
`document_not_found`; an index this org does not hold answers
`index_not_found`, and the two are different facts a client acts on
differently.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@param id
@return IndexAPIGetIndexIndexesByUidDocumentsByIdRequest
*/
func (a *IndexAPIService) GetIndexIndexesByUidDocumentsById(ctx context.Context, uid string, id string) IndexAPIGetIndexIndexesByUidDocumentsByIdRequest {
return IndexAPIGetIndexIndexesByUidDocumentsByIdRequest{
ApiService: a,
ctx: ctx,
uid: uid,
id: id,
}
}
// Execute executes the request
//
// @return interface{}
func (a *IndexAPIService) GetIndexIndexesByUidDocumentsByIdExecute(r IndexAPIGetIndexIndexesByUidDocumentsByIdRequest) (interface{}, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue interface{}
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexIndexesByUidDocumentsById")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents/{id}"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", url.PathEscape(parameterValueToString(r.id, "id")), -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 IndexAPIGetIndexIndexesByUidSettingsRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
}
func (r IndexAPIGetIndexIndexesByUidSettingsRequest) Execute() (*IndexIndexSettings, *http.Response, error) {
return r.ApiService.GetIndexIndexesByUidSettingsExecute(r)
}
/*
GetIndexIndexesByUidSettings Reads an index's filterable attributes.
Reads an index's filterable attributes.
Answers the settings subset this surface implements: the attributes a search
`filter` may constrain. An index this org does not hold answers 404 carrying
the dialect's `index_not_found`.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIGetIndexIndexesByUidSettingsRequest
*/
func (a *IndexAPIService) GetIndexIndexesByUidSettings(ctx context.Context, uid string) IndexAPIGetIndexIndexesByUidSettingsRequest {
return IndexAPIGetIndexIndexesByUidSettingsRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexSettings
func (a *IndexAPIService) GetIndexIndexesByUidSettingsExecute(r IndexAPIGetIndexIndexesByUidSettingsRequest) (*IndexIndexSettings, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexSettings
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexIndexesByUidSettings")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/settings"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -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 IndexAPIGetIndexStatsRequest struct {
ctx context.Context
ApiService *IndexAPIService
}
func (r IndexAPIGetIndexStatsRequest) Execute() (*IndexIndexStats, *http.Response, error) {
return r.ApiService.GetIndexStatsExecute(r)
}
/*
GetIndexStats Counts the documents in each of your indexes.
Counts the documents in each of your indexes.
Reports every index the caller's own org holds with its document count, plus
the org's total. `isIndexing` is always false because writes here are applied
before their response — there is never a background pass to wait on.
The tenant is the org minted from the VALIDATED bearer's owner claim, never a
client-supplied header, so this counts the caller's own documents and no
other tenant's. Without a validated principal the answer is 403 carrying the
dialect's `invalid_api_key` body.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return IndexAPIGetIndexStatsRequest
*/
func (a *IndexAPIService) GetIndexStats(ctx context.Context) IndexAPIGetIndexStatsRequest {
return IndexAPIGetIndexStatsRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return IndexIndexStats
func (a *IndexAPIService) GetIndexStatsExecute(r IndexAPIGetIndexStatsRequest) (*IndexIndexStats, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexStats
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexStats")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/stats"
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 IndexAPIGetIndexTasksByUidRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid int64
}
func (r IndexAPIGetIndexTasksByUidRequest) Execute() (*IndexIndexTask, *http.Response, error) {
return r.ApiService.GetIndexTasksByUidExecute(r)
}
/*
GetIndexTasksByUid Checks a write task, which has already finished.
Checks a write task, which has already finished.
Always reports `succeeded`. Writes here are applied to SQLite before their
EnqueuedTask is returned, so a client polling waitForTask resolves on its
first call rather than waiting for a queue that was never there. The three
timestamps are the same instant for the same reason.
It requires a validated principal but reads no tenant data: the task id it
echoes was minted by this process and names nothing about any org.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIGetIndexTasksByUidRequest
*/
func (a *IndexAPIService) GetIndexTasksByUid(ctx context.Context, uid int64) IndexAPIGetIndexTasksByUidRequest {
return IndexAPIGetIndexTasksByUidRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexTask
func (a *IndexAPIService) GetIndexTasksByUidExecute(r IndexAPIGetIndexTasksByUidRequest) (*IndexIndexTask, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexTask
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexTasksByUid")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/tasks/{uid}"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -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 IndexAPIGetIndexVersionRequest struct {
ctx context.Context
ApiService *IndexAPIService
}
func (r IndexAPIGetIndexVersionRequest) Execute() (*IndexIndexVersion, *http.Response, error) {
return r.ApiService.GetIndexVersionExecute(r)
}
/*
GetIndexVersion Identifies the search implementation answering.
Identifies the search implementation answering.
Reports the dialect's version shape with `commitSha` naming this
implementation rather than a Meilisearch build, so a client that logs the
version records which server answered instead of implying a release of
software this is not. It requires no principal and reads no tenant data.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return IndexAPIGetIndexVersionRequest
*/
func (a *IndexAPIService) GetIndexVersion(ctx context.Context) IndexAPIGetIndexVersionRequest {
return IndexAPIGetIndexVersionRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return IndexIndexVersion
func (a *IndexAPIService) GetIndexVersionExecute(r IndexAPIGetIndexVersionRequest) (*IndexIndexVersion, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodGet
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexVersion
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.GetIndexVersion")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/version"
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 IndexAPIPatchIndexIndexesByUidSettingsRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
indexIndexFilter *IndexIndexFilter
}
func (r IndexAPIPatchIndexIndexesByUidSettingsRequest) IndexIndexFilter(indexIndexFilter IndexIndexFilter) IndexAPIPatchIndexIndexesByUidSettingsRequest {
r.indexIndexFilter = &indexIndexFilter
return r
}
func (r IndexAPIPatchIndexIndexesByUidSettingsRequest) Execute() (*IndexIndexEnqueued, *http.Response, error) {
return r.ApiService.PatchIndexIndexesByUidSettingsExecute(r)
}
/*
PatchIndexIndexesByUidSettings Sets which attributes an index can be filtered on.
Sets which attributes an index can be filtered on.
Replaces the whole filterable set. An attribute not listed here cannot be
used in a search `filter`, so this is what makes a per-user or per-tag
narrowing possible at all.
It CREATES the index when it is missing rather than answering 404, because a
Meilisearch client configures settings on an index it has just asked for and
a refusal there leaves the client with no index at all.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of
later work: the setting is already applied when this answers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIPatchIndexIndexesByUidSettingsRequest
*/
func (a *IndexAPIService) PatchIndexIndexesByUidSettings(ctx context.Context, uid string) IndexAPIPatchIndexIndexesByUidSettingsRequest {
return IndexAPIPatchIndexIndexesByUidSettingsRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexEnqueued
func (a *IndexAPIService) PatchIndexIndexesByUidSettingsExecute(r IndexAPIPatchIndexIndexesByUidSettingsRequest) (*IndexIndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPatch
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PatchIndexIndexesByUidSettings")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/settings"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.indexIndexFilter == nil {
return localVarReturnValue, nil, reportError("indexIndexFilter 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.indexIndexFilter
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 IndexAPIPostIndexIndexesRequest struct {
ctx context.Context
ApiService *IndexAPIService
indexIndexNew *IndexIndexNew
}
func (r IndexAPIPostIndexIndexesRequest) IndexIndexNew(indexIndexNew IndexIndexNew) IndexAPIPostIndexIndexesRequest {
r.indexIndexNew = &indexIndexNew
return r
}
func (r IndexAPIPostIndexIndexesRequest) Execute() (*IndexIndexEnqueued, *http.Response, error) {
return r.ApiService.PostIndexIndexesExecute(r)
}
/*
PostIndexIndexes Creates an index.
Creates an index.
Registers a named index in the caller's own org and answers the dialect's
EnqueuedTask. It is idempotent: creating an index that already exists returns
the same receipt and changes nothing, which is what lets a client create on
startup without checking first.
`primaryKey` is optional — the first write establishes one when it is omitted.
An index is a ROW here rather than a table, so an unusual uid is stored
verbatim instead of being sanitised into a schema name.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of
later work: the write is already applied when this answers. A client that
polls waitForTask resolves immediately.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@return IndexAPIPostIndexIndexesRequest
*/
func (a *IndexAPIService) PostIndexIndexes(ctx context.Context) IndexAPIPostIndexIndexesRequest {
return IndexAPIPostIndexIndexesRequest{
ApiService: a,
ctx: ctx,
}
}
// Execute executes the request
//
// @return IndexIndexEnqueued
func (a *IndexAPIService) PostIndexIndexesExecute(r IndexAPIPostIndexIndexesRequest) (*IndexIndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PostIndexIndexes")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes"
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.indexIndexNew == nil {
return localVarReturnValue, nil, reportError("indexIndexNew 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.indexIndexNew
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 IndexAPIPostIndexIndexesByUidDocumentsRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
requestBody *[]interface{}
}
func (r IndexAPIPostIndexIndexesByUidDocumentsRequest) RequestBody(requestBody []interface{}) IndexAPIPostIndexIndexesByUidDocumentsRequest {
r.requestBody = &requestBody
return r
}
func (r IndexAPIPostIndexIndexesByUidDocumentsRequest) Execute() (*IndexEnqueued, *http.Response, error) {
return r.ApiService.PostIndexIndexesByUidDocumentsExecute(r)
}
/*
PostIndexIndexesByUidDocuments Add or replace documents in an index
Writes documents into the caller's own index, keyed by the index's primary key: a document whose key is already present is REPLACED whole. The body is the dialect's own — an array of documents, or a single document — and each is stored verbatim, so a read gives back exactly what was written.
The index is CREATED when it is missing rather than refused, because a Meilisearch client writes before it configures.
The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header, so two orgs may both hold an index named "messages" and neither can see the other's documents. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the documents are searchable when this answers, and a client that polls waitForTask resolves immediately.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIPostIndexIndexesByUidDocumentsRequest
*/
func (a *IndexAPIService) PostIndexIndexesByUidDocuments(ctx context.Context, uid string) IndexAPIPostIndexIndexesByUidDocumentsRequest {
return IndexAPIPostIndexIndexesByUidDocumentsRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexEnqueued
func (a *IndexAPIService) PostIndexIndexesByUidDocumentsExecute(r IndexAPIPostIndexIndexesByUidDocumentsRequest) (*IndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PostIndexIndexesByUidDocuments")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// 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.requestBody
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,
}
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 IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
requestBody *[]interface{}
}
func (r IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest) RequestBody(requestBody []interface{}) IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest {
r.requestBody = &requestBody
return r
}
func (r IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest) Execute() (*IndexEnqueued, *http.Response, error) {
return r.ApiService.PostIndexIndexesByUidDocumentsDeleteBatchExecute(r)
}
/*
PostIndexIndexesByUidDocumentsDeleteBatch Delete many documents by primary key in one call
Removes every named document from the caller's own index. The body is the dialect's own: a bare array of primary keys, which may be strings or numbers. A key that is not there is not an error, so a client reconciling its own corpus can send one list rather than checking each key first.
The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the documents are already gone when this answers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest
*/
func (a *IndexAPIService) PostIndexIndexesByUidDocumentsDeleteBatch(ctx context.Context, uid string) IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest {
return IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexEnqueued
func (a *IndexAPIService) PostIndexIndexesByUidDocumentsDeleteBatchExecute(r IndexAPIPostIndexIndexesByUidDocumentsDeleteBatchRequest) (*IndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PostIndexIndexesByUidDocumentsDeleteBatch")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents/delete-batch"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// 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.requestBody
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,
}
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 IndexAPIPostIndexIndexesByUidSearchRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
indexIndexQuery *IndexIndexQuery
}
func (r IndexAPIPostIndexIndexesByUidSearchRequest) IndexIndexQuery(indexIndexQuery IndexIndexQuery) IndexAPIPostIndexIndexesByUidSearchRequest {
r.indexIndexQuery = &indexIndexQuery
return r
}
func (r IndexAPIPostIndexIndexesByUidSearchRequest) Execute() (*IndexIndexHits, *http.Response, error) {
return r.ApiService.PostIndexIndexesByUidSearchExecute(r)
}
/*
PostIndexIndexesByUidSearch Searches an index, forgiving typos.
Searches an index, forgiving typos.
Ranks the org's documents in one index against `q` and answers the matching
documents whole, most relevant first. A prefix matches, so a partial word
finds the documents containing it, and `filter` narrows the result to
documents whose filterable attributes match — which is how a caller scopes
results to one end user within its own org.
`estimatedTotalHits` is the dialect's name for the count; every hit is
materialised here, so for this page it is exact. An index this org does not
hold answers 404 carrying the dialect's `index_not_found`.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIPostIndexIndexesByUidSearchRequest
*/
func (a *IndexAPIService) PostIndexIndexesByUidSearch(ctx context.Context, uid string) IndexAPIPostIndexIndexesByUidSearchRequest {
return IndexAPIPostIndexIndexesByUidSearchRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexIndexHits
func (a *IndexAPIService) PostIndexIndexesByUidSearchExecute(r IndexAPIPostIndexIndexesByUidSearchRequest) (*IndexIndexHits, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPost
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexIndexHits
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PostIndexIndexesByUidSearch")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/search"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
if r.indexIndexQuery == nil {
return localVarReturnValue, nil, reportError("indexIndexQuery 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.indexIndexQuery
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 IndexAPIPutIndexIndexesByUidDocumentsRequest struct {
ctx context.Context
ApiService *IndexAPIService
uid string
requestBody *[]interface{}
}
func (r IndexAPIPutIndexIndexesByUidDocumentsRequest) RequestBody(requestBody []interface{}) IndexAPIPutIndexIndexesByUidDocumentsRequest {
r.requestBody = &requestBody
return r
}
func (r IndexAPIPutIndexIndexesByUidDocumentsRequest) Execute() (*IndexEnqueued, *http.Response, error) {
return r.ApiService.PutIndexIndexesByUidDocumentsExecute(r)
}
/*
PutIndexIndexesByUidDocuments Add or update documents in an index
The dialect's update spelling of the write above, and the same act: an upsert keyed by the index's primary key. The JS client's addDocuments and updateDocuments both reduce to this for whole documents, so both spellings are served and both behave identically.
The tenant is the org minted from the VALIDATED bearer's owner claim, never a client-supplied header. Without a validated principal the answer is 403 carrying the dialect's `invalid_api_key` body.
The 202 and its `enqueued` task are DIALECT COMPATIBILITY, not a promise of later work: the write is already applied when this answers.
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
@param uid
@return IndexAPIPutIndexIndexesByUidDocumentsRequest
*/
func (a *IndexAPIService) PutIndexIndexesByUidDocuments(ctx context.Context, uid string) IndexAPIPutIndexIndexesByUidDocumentsRequest {
return IndexAPIPutIndexIndexesByUidDocumentsRequest{
ApiService: a,
ctx: ctx,
uid: uid,
}
}
// Execute executes the request
//
// @return IndexEnqueued
func (a *IndexAPIService) PutIndexIndexesByUidDocumentsExecute(r IndexAPIPutIndexIndexesByUidDocumentsRequest) (*IndexEnqueued, *http.Response, error) {
var (
localVarHTTPMethod = http.MethodPut
localVarPostBody interface{}
formFiles []formFile
localVarReturnValue *IndexEnqueued
)
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "IndexAPIService.PutIndexIndexesByUidDocuments")
if err != nil {
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
}
localVarPath := localBasePath + "/v1/index/indexes/{uid}/documents"
localVarPath = strings.Replace(localVarPath, "{"+"uid"+"}", url.PathEscape(parameterValueToString(r.uid, "uid")), -1)
localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}
// 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.requestBody
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,
}
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
}