Create or Update Item.
client.AISearch.Namespaces.Instances.Items.NewOrUpdate(ctx, name, id, params) (*NamespaceInstanceItemNewOrUpdateResponse, error)
PUT/accounts/{account_id}/ai-search/namespaces/{name}/instances/{id}/items
Creates or updates an indexed item in an AI Search instance.
Security
API Token
The preferred authorization scheme for interacting with the Cloudflare API. Create a token.
Example:
API Email + API Key
The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.
Example:
The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.
Example:
Parameters
Create or Update Item.
package main
import (
"context"
"fmt"
"github.com/stainless-sdks/cloudflare-go"
"github.com/stainless-sdks/cloudflare-go/ai_search"
"github.com/stainless-sdks/cloudflare-go/option"
)
func main() {
client := cloudflare.NewClient(
option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"),
)
response, err := client.AISearch.Namespaces.Instances.Items.NewOrUpdate(
context.TODO(),
"my-namespace",
"my-ai-search",
ai_search.NamespaceInstanceItemNewOrUpdateParams{
AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"),
Key: cloudflare.F("key"),
NextAction: cloudflare.F(ai_search.NamespaceInstanceItemNewOrUpdateParamsNextActionIndex),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.ID)
}
{
"result": {
"id": "id",
"checksum": "checksum",
"chunks_count": 0,
"created_at": "2019-12-27T18:11:19.117Z",
"file_size": 0,
"key": "key",
"last_seen_at": "2019-12-27T18:11:19.117Z",
"namespace": "namespace",
"next_action": "INDEX",
"source_id": "source_id",
"status": "queued",
"error": "error"
},
"success": true
}Returns Examples
{
"result": {
"id": "id",
"checksum": "checksum",
"chunks_count": 0,
"created_at": "2019-12-27T18:11:19.117Z",
"file_size": 0,
"key": "key",
"last_seen_at": "2019-12-27T18:11:19.117Z",
"namespace": "namespace",
"next_action": "INDEX",
"source_id": "source_id",
"status": "queued",
"error": "error"
},
"success": true
}