diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4c4a46efe09..6a15549e4bd 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.6.0" + ".": "7.7.0" } diff --git a/.stats.yml b/.stats.yml index c8158b4380a..a8ba69fad81 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1 @@ -configured_endpoints: 2412 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare/cloudflare-874436f83bd9c383144c69da47c4b767bb9c6f4f2bb4945af58cf3b6015f0f62.yml -openapi_spec_hash: beaf9a654991bf65d642e05c03460e4c -config_hash: 2f529580a17438fc62cd0b47db41b6f1 +configured_endpoints: 2448 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4027185bd..a553c0f49e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,63 @@ # Changelog +## 7.7.0 (2026-07-08) + +Full Changelog: [v7.6.0...v7.7.0](https://github.com/cloudflare/cloudflare-go/compare/v7.6.0...v7.7.0) + +### Breaking Changes + +See the [v7.7.0 Migration Guide](./docs/migration-guides/v7.7.0-migration-guide.md) for before/after code examples and actions needed for each change. + +* **ssl:** `Recommendations.Get` method and `RecommendationGetResponse` / `RecommendationGetParams` types removed. +* **ai_gateway, workflows, zero_trust/dlpemailaccountmapping:** merged-union parent fields with same-name-different-type collisions changed from a variant-struct type to `interface{}`. Affected fields: + * `ai_gateway.AIGateway{New,Update,List,Delete,Get}ResponseSpendLimitsRulesMetadata.Mode` (5 structs) + * `workflows.VersionGraphResponseGraphWorkflowPayload.Type` + * `zero_trust.DLPEmailAccountMapping{New,Get}ResponseAuthRequirements.Type` (2 structs) + + These fields were unreadable in the previous type (marshaling panicked with `reflect: call of reflect.Value.SetString on struct Value`). The new `interface{}` type matches the codegen pattern used by sibling merged fields on the same structs (e.g. `Values`, `Fields`, `AllowedMicrosoftOrganizations`); callers should switch on the parent union via `AsUnion()` for a strongly-typed variant. + +* **zero_trust:** `Devices.DEXTests.{New,Update,List,Get}` response type renamed from `DeviceDEXTest{New,Update,List,Get}Response` to the shared `SchemaHTTP`; field structure unchanged. Nested types renamed accordingly (e.g. `DeviceDEXTestNewResponseData` → `SchemaData`, `DeviceDEXTestNewResponseTargetPolicy` → `SchemaHTTPTargetPolicy`). Callers using `:=` inference and field access continue to compile; callers referencing the removed type names must update to `SchemaHTTP`. +* **zero_trust:** `Devices.IPProfiles.List` pagination changed from `pagination.SinglePage[IPProfile]` to `pagination.V4PagePaginationArray[IPProfile]`. `.Result` field access and `ListAutoPaging()` iteration continue to work; callers referencing the pagination type by name must update. + +### Features + +* **NEW SERVICE: `email_auth`** — DMARC reports edit/get and SPF inspect + * `client.EmailAuth.DMARCReports.Edit` + * `client.EmailAuth.DMARCReports.Get` + * `client.EmailAuth.SPF.Inspect.Get` +* **NEW SERVICE: `moq`** — Media over QUIC relay management + * `client.MoQ.Relays.{New,Update,List,Delete,Get}` + * `client.MoQ.Relays.Tokens.Rotate` +* **zero_trust:** publish CASB APIs (`client.ZeroTrust.Casb.*`) + * `Applications.{List,Get}` + `Applications.SetupFlows.List` + * `Integrations.{New,Update,List,Delete,Get,Pause,Resume}` +* **logs:** add `LogExplorer` sub-resource + * `LogExplorer.Query.Sql` + * `LogExplorer.Datasets.{New,Update,List,Get}` + * `LogExplorer.Datasets.Available.List` +* **browser_rendering:** add `AccessibilityTree.New` method +* **email_routing:** add `EmailRouting.Unlock` and `EmailRouting.Addresses.Edit` methods +* **email_routing:** add `AccountRules.List` method (`GET /accounts/{account_id}/email/routing/rules`) returning `AccountRule` with new `Zone` field; `Rules.List` gains optional `AccountID` param (mutually exclusive with `ZoneID`) so callers can list rules by account or zone +* **email_security:** add bulk investigation APIs + * `Investigate.Bulk.{New,List,Delete,Get}` + * `Investigate.Bulk.Cancel.New` + * `Investigate.Bulk.Messages.List` +* **accounts:** add `Logs.Audit.History` and `Logs.Audit.ProductCategories` methods +* **organizations:** add `Logs.Audit.History` method + +### Bug Fixes + +* **ai_gateway, workflows, zero_trust/dlpemailaccountmapping:** fix panics on union-merged parent field decoding by switching same-name-different-type merged fields from a variant-struct type to `interface{}` ([3de4191](https://github.com/cloudflare/cloudflare-go/commit/3de4191de)) +* **browser_rendering:** `AccessibilityTreeNewParamsBodyObject` now uses `URL` (matching the generated test fixture) instead of `HTML` ([0f44441](https://github.com/cloudflare/cloudflare-go/commit/0f4444190)) +* **dns:** restore `Shadow*` query params on `RecordListParams` and `IncludeShadowMetadata` on `Record{New,Update,List,Batch,Edit,Get}Params` after a codegen regression dropped them ([f9b3f27](https://github.com/cloudflare/cloudflare-go/commit/f9b3f274a)) + +### Chores + +* **api:** update composite API spec (20+ codegen sync commits) +* **ci:** bump CI job timeouts to 30 minutes ([6cad6cb](https://github.com/cloudflare/cloudflare-go/commit/6cad6cb57)) +* **ci:** unblock test job by installing nodejs/npm for prism mock server ([3de4191](https://github.com/cloudflare/cloudflare-go/commit/3de4191de)) +* apply accumulated custom code (CI jobs, GitLab config) ([eb2bf2b](https://github.com/cloudflare/cloudflare-go/commit/eb2bf2b10)) + ## 7.6.0 (2026-06-16) Full Changelog: [v7.5.0...v7.6.0](https://github.com/cloudflare/cloudflare-go/compare/v7.5.0...v7.6.0) @@ -35,10 +93,6 @@ Full Changelog: [v7.5.0...v7.6.0](https://github.com/cloudflare/cloudflare-go/co ## 7.5.0 (2026-06-10) -Full Changelog: [v7.5.0...v7.5.0](https://github.com/cloudflare/cloudflare-go/compare/v7.5.0...v7.5.0) - -## 7.5.0 (2026-06-10) - Full Changelog: [v7.4.0...v7.5.0](https://github.com/cloudflare/cloudflare-go/compare/v7.4.0...v7.5.0) ### Features diff --git a/README.md b/README.md index e6f99ea79d9..921734bb0cc 100644 --- a/README.md +++ b/README.md @@ -7,37 +7,20 @@ from applications written in Go. It is generated with [Stainless](https://www.stainless.com/). -## MCP Server - -Use the Cloudflare MCP Server to enable AI assistants to interact with this API, allowing them to explore endpoints, make test requests, and use documentation to help integrate this SDK into your application. - -[![Add to Cursor](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=cloudflare-mcp&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsImNsb3VkZmxhcmUtbWNwIl0sImVudiI6eyJDTE9VREZMQVJFX0FQSV9UT0tFTiI6IlNuM2xaSlRCWDZra2c3T2RjQlVBeE9POTYzR0VJeUdRcW5GVE9GWVkiLCJDTE9VREZMQVJFX0FQSV9LRVkiOiIxNDRjOWRlZmFjMDQ5NjljN2JmYWQ4ZWZhYThlYTE5NCIsIkNMT1VERkxBUkVfRU1BSUwiOiJ1c2VyQGV4YW1wbGUuY29tIiwiQ0xPVURGTEFSRV9BUElfVVNFUl9TRVJWSUNFX0tFWSI6InYxLjAtMTQ0YzlkZWZhYzA0OTY5YzdiZmFkOGVmLTYzMWE0MWQwMDNhMzJkMjVmZTg3ODA4MWVmMzY1YzQ5NTAzZjdmYWRhNjAwZGE5MzVlMjg1MWExYzczMjYwODRiODVjYmY2NDI5YzRiODU5ZGU4NDc1NzMxZGM5MmE5YzMyOTYzMWU2ZDU5ZTZjNzNkYTdiMTk4NDk3MTcyYjRjZWZlMDcxZDkwZDBmNWQyNzE5In19) -[![Install in VS Code](https://img.shields.io/badge/_-Add_to_VS_Code-blue?style=for-the-badge&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGZpbGw9Im5vbmUiIHZpZXdCb3g9IjAgMCA0MCA0MCI+PHBhdGggZmlsbD0iI0VFRSIgZmlsbC1ydWxlPSJldmVub2RkIiBkPSJNMzAuMjM1IDM5Ljg4NGEyLjQ5MSAyLjQ5MSAwIDAgMS0xLjc4MS0uNzNMMTIuNyAyNC43OGwtMy40NiAyLjYyNC0zLjQwNiAyLjU4MmExLjY2NSAxLjY2NSAwIDAgMS0xLjA4Mi4zMzggMS42NjQgMS42NjQgMCAwIDEtMS4wNDYtLjQzMWwtMi4yLTJhMS42NjYgMS42NjYgMCAwIDEgMC0yLjQ2M0w3LjQ1OCAyMCA0LjY3IDE3LjQ1MyAxLjUwNyAxNC41N2ExLjY2NSAxLjY2NSAwIDAgMSAwLTIuNDYzbDIuMi0yYTEuNjY1IDEuNjY1IDAgMCAxIDIuMTMtLjA5N2w2Ljg2MyA1LjIwOUwyOC40NTIuODQ0YTIuNDg4IDIuNDg4IDAgMCAxIDEuODQxLS43MjljLjM1MS4wMDkuNjk5LjA5MSAxLjAxOS4yNDVsOC4yMzYgMy45NjFhMi41IDIuNSAwIDAgMSAxLjQxNSAyLjI1M3YuMDk5LS4wNDVWMzMuMzd2LS4wNDUuMDk1YTIuNTAxIDIuNTAxIDAgMCAxLTEuNDE2IDIuMjU3bC04LjIzNSAzLjk2MWEyLjQ5MiAyLjQ5MiAwIDAgMS0xLjA3Ny4yNDZabS43MTYtMjguOTQ3LTExLjk0OCA5LjA2MiAxMS45NTIgOS4wNjUtLjAwNC0xOC4xMjdaIi8+PC9zdmc+)](https://vscode.stainless.com/mcp/%7B%22name%22%3A%22cloudflare-mcp%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22cloudflare-mcp%22%5D%2C%22env%22%3A%7B%22CLOUDFLARE_API_TOKEN%22%3A%22Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY%22%2C%22CLOUDFLARE_API_KEY%22%3A%22144c9defac04969c7bfad8efaa8ea194%22%2C%22CLOUDFLARE_EMAIL%22%3A%22user%40example.com%22%2C%22CLOUDFLARE_API_USER_SERVICE_KEY%22%3A%22v1.0-144c9defac04969c7bfad8ef-631a41d003a32d25fe878081ef365c49503f7fada600da935e2851a1c7326084b85cbf6429c4b859de8475731dc92a9c329631e6d59e6c73da7b198497172b4cefe071d90d0f5d2719%22%7D%7D) - -> Note: You may need to set environment variables in your MCP client. - ## Installation - - ```go import ( "github.com/cloudflare/cloudflare-go/v7" // imported as cloudflare ) ``` - - Or to pin the version: - - ```sh -go get -u 'github.com/cloudflare/cloudflare-go/v7@v7.6.0' +go get -u 'github.com/cloudflare/cloudflare-go/v7@v7.7.0' ``` - - ## Requirements This library requires Go 1.22+. diff --git a/accounts/api.md b/accounts/api.md index c502ff354bd..b5a18bc97bf 100644 --- a/accounts/api.md +++ b/accounts/api.md @@ -119,7 +119,11 @@ Methods: Response Types: - accounts.LogAuditListResponse +- accounts.LogAuditHistoryResponse +- accounts.LogAuditProductCategoriesResponse Methods: - client.Accounts.Logs.Audit.List(ctx context.Context, params accounts.LogAuditListParams) (\*pagination.CursorPaginationAfter[accounts.LogAuditListResponse], error) +- client.Accounts.Logs.Audit.History(ctx context.Context, id string, params accounts.LogAuditHistoryParams) (\*[]accounts.LogAuditHistoryResponse, error) +- client.Accounts.Logs.Audit.ProductCategories(ctx context.Context, query accounts.LogAuditProductCategoriesParams) (\*pagination.SinglePage[accounts.LogAuditProductCategoriesResponse], error) diff --git a/accounts/logaudit.go b/accounts/logaudit.go index 9943fa71206..c326cb29994 100644 --- a/accounts/logaudit.go +++ b/accounts/logaudit.go @@ -65,6 +65,72 @@ func (r *LogAuditService) ListAutoPaging(ctx context.Context, params LogAuditLis return pagination.NewCursorPaginationAfterAutoPager(r.List(ctx, params, opts...)) } +// Returns the chronological change history for the resource identified by the +// given audit log entry. +// +// The endpoint first locates the source audit log entry by `id` (using +// `action_time` to narrow the lookup window), derives identifying filters from +// that entry, and then returns matching audit logs within the `since`/`before` +// window. +// +// The `result_info.history_status` field indicates the quality of the resource +// identification used: +// +// - `exact`: Resource was identified by the resource URI. +// - `approximate`: Resource was identified without the resource URI. +// - `unavailable`: The source audit log entry did not contain enough information +// to identify the resource; an empty result is returned. +func (r *LogAuditService) History(ctx context.Context, id string, params LogAuditHistoryParams, opts ...option.RequestOption) (res *[]LogAuditHistoryResponse, err error) { + var env LogAuditHistoryResponseEnvelope + opts = slices.Concat(r.Options, opts) + if params.AccountID.Value == "" { + err = errors.New("missing required account_id parameter") + return nil, err + } + if id == "" { + err = errors.New("missing required id parameter") + return nil, err + } + path := fmt.Sprintf("accounts/%s/logs/audit/%s/history", params.AccountID, id) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, params, &env, opts...) + if err != nil { + return nil, err + } + res = &env.Result + return res, nil +} + +// Lists the available audit log product categories and the resource products each +// one expands to. Use these values with the product_category filter on the account +// audit logs endpoint. +func (r *LogAuditService) ProductCategories(ctx context.Context, query LogAuditProductCategoriesParams, opts ...option.RequestOption) (res *pagination.SinglePage[LogAuditProductCategoriesResponse], err error) { + var raw *http.Response + opts = slices.Concat(r.Options, opts) + opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) + if query.AccountID.Value == "" { + err = errors.New("missing required account_id parameter") + return nil, err + } + path := fmt.Sprintf("accounts/%s/logs/audit/product_categories", query.AccountID) + cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) + if err != nil { + return nil, err + } + err = cfg.Execute() + if err != nil { + return nil, err + } + res.SetPageConfig(cfg, raw) + return res, nil +} + +// Lists the available audit log product categories and the resource products each +// one expands to. Use these values with the product_category filter on the account +// audit logs endpoint. +func (r *LogAuditService) ProductCategoriesAutoPaging(ctx context.Context, query LogAuditProductCategoriesParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[LogAuditProductCategoriesResponse] { + return pagination.NewSinglePageAutoPager(r.ProductCategories(ctx, query, opts...)) +} + type LogAuditListResponse struct { // A unique identifier for the audit log entry. ID string `json:"id"` @@ -337,6 +403,333 @@ func (r logAuditListResponseZoneJSON) RawJSON() string { return r.raw } +type LogAuditHistoryResponse struct { + // A unique identifier for the audit log entry. + ID string `json:"id"` + // Contains account related information. + Account LogAuditHistoryResponseAccount `json:"account"` + // Provides information about the action performed. + Action LogAuditHistoryResponseAction `json:"action"` + // Provides details about the actor who performed the action. + Actor LogAuditHistoryResponseActor `json:"actor"` + // Provides raw information about the request and response. + Raw LogAuditHistoryResponseRaw `json:"raw"` + // Provides details about the affected resource. + Resource LogAuditHistoryResponseResource `json:"resource"` + // Provides details about the zone affected by the action. + Zone LogAuditHistoryResponseZone `json:"zone"` + JSON logAuditHistoryResponseJSON `json:"-"` +} + +// logAuditHistoryResponseJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponse] +type logAuditHistoryResponseJSON struct { + ID apijson.Field + Account apijson.Field + Action apijson.Field + Actor apijson.Field + Raw apijson.Field + Resource apijson.Field + Zone apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseJSON) RawJSON() string { + return r.raw +} + +// Contains account related information. +type LogAuditHistoryResponseAccount struct { + // A unique identifier for the account. + ID string `json:"id"` + // A string that identifies the account name. + Name string `json:"name"` + JSON logAuditHistoryResponseAccountJSON `json:"-"` +} + +// logAuditHistoryResponseAccountJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseAccount] +type logAuditHistoryResponseAccountJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseAccount) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseAccountJSON) RawJSON() string { + return r.raw +} + +// Provides information about the action performed. +type LogAuditHistoryResponseAction struct { + // A short description of the action performed. + Description string `json:"description"` + // The result of the action, indicating success or failure. + Result string `json:"result"` + // A timestamp indicating when the action was logged. + Time time.Time `json:"time" format:"date-time"` + // A short string that describes the action that was performed. + Type string `json:"type"` + JSON logAuditHistoryResponseActionJSON `json:"-"` +} + +// logAuditHistoryResponseActionJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseAction] +type logAuditHistoryResponseActionJSON struct { + Description apijson.Field + Result apijson.Field + Time apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseAction) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseActionJSON) RawJSON() string { + return r.raw +} + +// Provides details about the actor who performed the action. +type LogAuditHistoryResponseActor struct { + // The ID of the actor who performed the action. If a user performed the action, + // this will be their User ID. + ID string `json:"id"` + Context LogAuditHistoryResponseActorContext `json:"context"` + // The email of the actor who performed the action. + Email string `json:"email" format:"email"` + // The IP address of the request that performed the action. + IPAddress string `json:"ip_address"` + // The API token ID when the actor context is an api_token or oauth. + TokenID string `json:"token_id"` + // The API token name when the actor context is an api_token or oauth. + TokenName string `json:"token_name"` + // The type of actor. + Type LogAuditHistoryResponseActorType `json:"type"` + JSON logAuditHistoryResponseActorJSON `json:"-"` +} + +// logAuditHistoryResponseActorJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseActor] +type logAuditHistoryResponseActorJSON struct { + ID apijson.Field + Context apijson.Field + Email apijson.Field + IPAddress apijson.Field + TokenID apijson.Field + TokenName apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseActor) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseActorJSON) RawJSON() string { + return r.raw +} + +type LogAuditHistoryResponseActorContext string + +const ( + LogAuditHistoryResponseActorContextAPIKey LogAuditHistoryResponseActorContext = "api_key" + LogAuditHistoryResponseActorContextAPIToken LogAuditHistoryResponseActorContext = "api_token" + LogAuditHistoryResponseActorContextDash LogAuditHistoryResponseActorContext = "dash" + LogAuditHistoryResponseActorContextOAuth LogAuditHistoryResponseActorContext = "oauth" + LogAuditHistoryResponseActorContextOriginCAKey LogAuditHistoryResponseActorContext = "origin_ca_key" +) + +func (r LogAuditHistoryResponseActorContext) IsKnown() bool { + switch r { + case LogAuditHistoryResponseActorContextAPIKey, LogAuditHistoryResponseActorContextAPIToken, LogAuditHistoryResponseActorContextDash, LogAuditHistoryResponseActorContextOAuth, LogAuditHistoryResponseActorContextOriginCAKey: + return true + } + return false +} + +// The type of actor. +type LogAuditHistoryResponseActorType string + +const ( + LogAuditHistoryResponseActorTypeAccount LogAuditHistoryResponseActorType = "account" + LogAuditHistoryResponseActorTypeCloudflareAdmin LogAuditHistoryResponseActorType = "cloudflare_admin" + LogAuditHistoryResponseActorTypeSystem LogAuditHistoryResponseActorType = "system" + LogAuditHistoryResponseActorTypeUser LogAuditHistoryResponseActorType = "user" +) + +func (r LogAuditHistoryResponseActorType) IsKnown() bool { + switch r { + case LogAuditHistoryResponseActorTypeAccount, LogAuditHistoryResponseActorTypeCloudflareAdmin, LogAuditHistoryResponseActorTypeSystem, LogAuditHistoryResponseActorTypeUser: + return true + } + return false +} + +// Provides raw information about the request and response. +type LogAuditHistoryResponseRaw struct { + // The Cloudflare Ray ID for the request. + CfRayID string `json:"cf_ray_id"` + // The HTTP method of the request. + Method string `json:"method"` + // The HTTP response status code returned by the API. + StatusCode int64 `json:"status_code"` + // The URI of the request. + URI string `json:"uri"` + // The client's user agent string sent with the request. + UserAgent string `json:"user_agent"` + JSON logAuditHistoryResponseRawJSON `json:"-"` +} + +// logAuditHistoryResponseRawJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseRaw] +type logAuditHistoryResponseRawJSON struct { + CfRayID apijson.Field + Method apijson.Field + StatusCode apijson.Field + URI apijson.Field + UserAgent apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseRaw) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseRawJSON) RawJSON() string { + return r.raw +} + +// Provides details about the affected resource. +type LogAuditHistoryResponseResource struct { + // The unique identifier for the affected resource. + ID string `json:"id"` + // The Cloudflare product associated with the resource. + Product string `json:"product"` + Request interface{} `json:"request"` + Response interface{} `json:"response"` + // The scope of the resource. + Scope interface{} `json:"scope"` + // The type of the resource. + Type string `json:"type"` + JSON logAuditHistoryResponseResourceJSON `json:"-"` +} + +// logAuditHistoryResponseResourceJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseResource] +type logAuditHistoryResponseResourceJSON struct { + ID apijson.Field + Product apijson.Field + Request apijson.Field + Response apijson.Field + Scope apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseResource) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseResourceJSON) RawJSON() string { + return r.raw +} + +// Provides details about the zone affected by the action. +type LogAuditHistoryResponseZone struct { + // A string that identifies the zone id. + ID string `json:"id"` + // A string that identifies the zone name. + Name string `json:"name"` + JSON logAuditHistoryResponseZoneJSON `json:"-"` +} + +// logAuditHistoryResponseZoneJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseZone] +type logAuditHistoryResponseZoneJSON struct { + ID apijson.Field + Name apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseZone) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseZoneJSON) RawJSON() string { + return r.raw +} + +// A predefined product category and the resource products it expands to. +type LogAuditProductCategoriesResponse struct { + // A human-readable label for the product category. + Label string `json:"label"` + // The resource products that the product category expands to. + Products []LogAuditProductCategoriesResponseProduct `json:"products"` + // The product category identifier used with the product_category filter. + Value string `json:"value"` + JSON logAuditProductCategoriesResponseJSON `json:"-"` +} + +// logAuditProductCategoriesResponseJSON contains the JSON metadata for the struct +// [LogAuditProductCategoriesResponse] +type logAuditProductCategoriesResponseJSON struct { + Label apijson.Field + Products apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditProductCategoriesResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditProductCategoriesResponseJSON) RawJSON() string { + return r.raw +} + +// A resource product within a product category. +type LogAuditProductCategoriesResponseProduct struct { + // A human-readable label for the product. + Label string `json:"label"` + // The resource_product value that the product category expands to. + Value string `json:"value"` + JSON logAuditProductCategoriesResponseProductJSON `json:"-"` +} + +// logAuditProductCategoriesResponseProductJSON contains the JSON metadata for the +// struct [LogAuditProductCategoriesResponseProduct] +type logAuditProductCategoriesResponseProductJSON struct { + Label apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditProductCategoriesResponseProduct) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditProductCategoriesResponseProductJSON) RawJSON() string { + return r.raw +} + type LogAuditListParams struct { // The unique id that identifies the account. AccountID param.Field[string] `path:"account_id" api:"required"` @@ -370,7 +763,13 @@ type LogAuditListParams struct { Direction param.Field[LogAuditListParamsDirection] `query:"direction"` // The number limits the objects to return. The cursor attribute may be used to // iterate over the next batch of objects if there are more than the limit. - Limit param.Field[float64] `query:"limit"` + Limit param.Field[float64] `query:"limit"` + // Filters audit logs by one or more predefined product categories. Each product + // category expands into a curated set of resource_product values and is unioned + // with any explicit resource_product filter. Matched case-insensitively; unknown + // product categories return 400. Repeatable. Use the audit log product categories + // endpoint to discover the available values. + ProductCategory param.Field[[]string] `query:"product_category"` RawCfRayID param.Field[LogAuditListParamsRawCfRayID] `query:"raw_cf_ray_id"` RawMethod param.Field[LogAuditListParamsRawMethod] `query:"raw_method"` RawStatusCode param.Field[LogAuditListParamsRawStatusCode] `query:"raw_status_code"` @@ -807,3 +1206,182 @@ func (r LogAuditListParamsZoneName) URLQuery() (v url.Values) { NestedFormat: apiquery.NestedQueryFormatDots, }) } + +type LogAuditHistoryParams struct { + // The unique ID that identifies the account. + AccountID param.Field[string] `path:"account_id" api:"required"` + // RFC3339 timestamp of the source audit log entry's action time. Used to narrow + // the source-entry lookup window. Provide the `action.time` value from the audit + // log identified by `id`. + ActionTime param.Field[time.Time] `query:"action_time" api:"required" format:"date-time"` + // Limits the returned results to logs older than the specified date. This can be a + // date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + // conforms to RFC3339. + Before param.Field[time.Time] `query:"before" api:"required" format:"date"` + // Limits the returned results to logs newer than the specified date. This can be a + // date string 2019-04-30 (interpreted in UTC) or an absolute timestamp that + // conforms to RFC3339. + Since param.Field[time.Time] `query:"since" api:"required" format:"date"` + // The cursor is an opaque token used to paginate through large sets of records. It + // indicates the position from which to continue when requesting the next set of + // records. A valid cursor value can be obtained from the cursor object in the + // result_info structure of a previous response. + Cursor param.Field[string] `query:"cursor"` + // Sets sorting order. + Direction param.Field[LogAuditHistoryParamsDirection] `query:"direction"` + // The number limits the objects to return. The cursor attribute may be used to + // iterate over the next batch of objects if there are more than the limit. + Limit param.Field[float64] `query:"limit"` +} + +// URLQuery serializes [LogAuditHistoryParams]'s query parameters as `url.Values`. +func (r LogAuditHistoryParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatDots, + }) +} + +// Sets sorting order. +type LogAuditHistoryParamsDirection string + +const ( + LogAuditHistoryParamsDirectionDesc LogAuditHistoryParamsDirection = "desc" + LogAuditHistoryParamsDirectionAsc LogAuditHistoryParamsDirection = "asc" +) + +func (r LogAuditHistoryParamsDirection) IsKnown() bool { + switch r { + case LogAuditHistoryParamsDirectionDesc, LogAuditHistoryParamsDirectionAsc: + return true + } + return false +} + +type LogAuditHistoryResponseEnvelope struct { + Errors []LogAuditHistoryResponseEnvelopeErrors `json:"errors" api:"required"` + Result []LogAuditHistoryResponse `json:"result" api:"required"` + // Provides information about the result of the request, including count, cursor, + // and identification quality. + ResultInfo LogAuditHistoryResponseEnvelopeResultInfo `json:"result_info" api:"required"` + // Indicates whether the API call was successful + Success LogAuditHistoryResponseEnvelopeSuccess `json:"success" api:"required"` + JSON logAuditHistoryResponseEnvelopeJSON `json:"-"` +} + +// logAuditHistoryResponseEnvelopeJSON contains the JSON metadata for the struct +// [LogAuditHistoryResponseEnvelope] +type logAuditHistoryResponseEnvelopeJSON struct { + Errors apijson.Field + Result apijson.Field + ResultInfo apijson.Field + Success apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseEnvelope) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseEnvelopeJSON) RawJSON() string { + return r.raw +} + +type LogAuditHistoryResponseEnvelopeErrors struct { + Message string `json:"message" api:"required"` + JSON logAuditHistoryResponseEnvelopeErrorsJSON `json:"-"` +} + +// logAuditHistoryResponseEnvelopeErrorsJSON contains the JSON metadata for the +// struct [LogAuditHistoryResponseEnvelopeErrors] +type logAuditHistoryResponseEnvelopeErrorsJSON struct { + Message apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseEnvelopeErrors) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseEnvelopeErrorsJSON) RawJSON() string { + return r.raw +} + +// Provides information about the result of the request, including count, cursor, +// and identification quality. +type LogAuditHistoryResponseEnvelopeResultInfo struct { + // The number of records returned in the response. + Count int64 `json:"count" api:"required"` + // Indicates the quality of the resource identification used to derive the history. + // + // - `exact`: Resource was identified by the resource URI. + // - `approximate`: Resource was identified without the resource URI. + // - `unavailable`: The source audit log entry did not contain enough information + // to identify the resource; result is empty. + HistoryStatus LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus `json:"history_status" api:"required"` + // The cursor token used for pagination. + Cursor string `json:"cursor"` + JSON logAuditHistoryResponseEnvelopeResultInfoJSON `json:"-"` +} + +// logAuditHistoryResponseEnvelopeResultInfoJSON contains the JSON metadata for the +// struct [LogAuditHistoryResponseEnvelopeResultInfo] +type logAuditHistoryResponseEnvelopeResultInfoJSON struct { + Count apijson.Field + HistoryStatus apijson.Field + Cursor apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LogAuditHistoryResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r logAuditHistoryResponseEnvelopeResultInfoJSON) RawJSON() string { + return r.raw +} + +// Indicates the quality of the resource identification used to derive the history. +// +// - `exact`: Resource was identified by the resource URI. +// - `approximate`: Resource was identified without the resource URI. +// - `unavailable`: The source audit log entry did not contain enough information +// to identify the resource; result is empty. +type LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus string + +const ( + LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusExact LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus = "exact" + LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusApproximate LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus = "approximate" + LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusUnavailable LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus = "unavailable" +) + +func (r LogAuditHistoryResponseEnvelopeResultInfoHistoryStatus) IsKnown() bool { + switch r { + case LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusExact, LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusApproximate, LogAuditHistoryResponseEnvelopeResultInfoHistoryStatusUnavailable: + return true + } + return false +} + +// Indicates whether the API call was successful +type LogAuditHistoryResponseEnvelopeSuccess bool + +const ( + LogAuditHistoryResponseEnvelopeSuccessTrue LogAuditHistoryResponseEnvelopeSuccess = true +) + +func (r LogAuditHistoryResponseEnvelopeSuccess) IsKnown() bool { + switch r { + case LogAuditHistoryResponseEnvelopeSuccessTrue: + return true + } + return false +} + +type LogAuditProductCategoriesParams struct { + // The unique id that identifies the account. + AccountID param.Field[string] `path:"account_id" api:"required"` +} diff --git a/accounts/logaudit_test.go b/accounts/logaudit_test.go index ecab02a7515..fde8e156a85 100644 --- a/accounts/logaudit_test.go +++ b/accounts/logaudit_test.go @@ -70,9 +70,10 @@ func TestLogAuditListWithOptionalParams(t *testing.T) { AuditLogID: cloudflare.F(accounts.LogAuditListParamsAuditLogID{ Not: cloudflare.F([]string{"f174be97-19b1-40d6-954d-70cd5fbd52db"}), }), - Cursor: cloudflare.F("Q1buH-__DQqqig7SVYXT-SsMOTGY2Z3Y80W-fGgva7yaDdmPKveucH5ddOcHsJRhNb-xUK8agZQqkJSMAENGO8NU6g=="), - Direction: cloudflare.F(accounts.LogAuditListParamsDirectionDesc), - Limit: cloudflare.F(25.000000), + Cursor: cloudflare.F("Q1buH-__DQqqig7SVYXT-SsMOTGY2Z3Y80W-fGgva7yaDdmPKveucH5ddOcHsJRhNb-xUK8agZQqkJSMAENGO8NU6g=="), + Direction: cloudflare.F(accounts.LogAuditListParamsDirectionDesc), + Limit: cloudflare.F(25.000000), + ProductCategory: cloudflare.F([]string{"zerotrust"}), RawCfRayID: cloudflare.F(accounts.LogAuditListParamsRawCfRayID{ Not: cloudflare.F([]string{"8e8dd2156ef28414"}), }), @@ -112,3 +113,65 @@ func TestLogAuditListWithOptionalParams(t *testing.T) { t.Fatalf("err should be nil: %s", err.Error()) } } + +func TestLogAuditHistoryWithOptionalParams(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + _, err := client.Accounts.Logs.Audit.History( + context.TODO(), + "f174be97-19b1-40d6-954d-70cd5fbd52db", + accounts.LogAuditHistoryParams{ + AccountID: cloudflare.F("a67e14daa5f8dceeb91fe5449ba496ef"), + ActionTime: cloudflare.F(time.Now()), + Before: cloudflare.F(time.Now()), + Since: cloudflare.F(time.Now()), + Cursor: cloudflare.F("Q1buH-__DQqqig7SVYXT-SsMOTGY2Z3Y80W-fGgva7yaDdmPKveucH5ddOcHsJRhNb-xUK8agZQqkJSMAENGO8NU6g=="), + Direction: cloudflare.F(accounts.LogAuditHistoryParamsDirectionDesc), + Limit: cloudflare.F(25.000000), + }, + ) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} + +func TestLogAuditProductCategories(t *testing.T) { + baseURL := "http://localhost:4010" + if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { + baseURL = envURL + } + if !testutil.CheckTestServer(t, baseURL) { + return + } + client := cloudflare.NewClient( + option.WithBaseURL(baseURL), + option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), + option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), + option.WithAPIEmail("user@example.com"), + ) + _, err := client.Accounts.Logs.Audit.ProductCategories(context.TODO(), accounts.LogAuditProductCategoriesParams{ + AccountID: cloudflare.F("a67e14daa5f8dceeb91fe5449ba496ef"), + }) + if err != nil { + var apierr *cloudflare.Error + if errors.As(err, &apierr) { + t.Log(string(apierr.DumpRequest(true))) + } + t.Fatalf("err should be nil: %s", err.Error()) + } +} diff --git a/accounts/tokenpermissiongroup.go b/accounts/tokenpermissiongroup.go index a497e4ca3e0..db9e0382b9a 100644 --- a/accounts/tokenpermissiongroup.go +++ b/accounts/tokenpermissiongroup.go @@ -84,6 +84,8 @@ func (r *TokenPermissionGroupService) Get(ctx context.Context, params TokenPermi type TokenPermissionGroupListResponse struct { // Public ID. ID string `json:"id"` + // Product category that this permission group belongs to. + Category TokenPermissionGroupListResponseCategory `json:"category"` // Permission Group Name Name string `json:"name"` // Resources to which the Permission Group is scoped @@ -95,6 +97,7 @@ type TokenPermissionGroupListResponse struct { // [TokenPermissionGroupListResponse] type tokenPermissionGroupListResponseJSON struct { ID apijson.Field + Category apijson.Field Name apijson.Field Scopes apijson.Field raw string @@ -109,6 +112,33 @@ func (r tokenPermissionGroupListResponseJSON) RawJSON() string { return r.raw } +// Product category that this permission group belongs to. +type TokenPermissionGroupListResponseCategory string + +const ( + TokenPermissionGroupListResponseCategoryDeveloperPlatform TokenPermissionGroupListResponseCategory = "developer_platform" + TokenPermissionGroupListResponseCategoryAIAndMachineLearning TokenPermissionGroupListResponseCategory = "ai_and_machine_learning" + TokenPermissionGroupListResponseCategoryDNSAndZones TokenPermissionGroupListResponseCategory = "dns_and_zones" + TokenPermissionGroupListResponseCategoryAppSecurity TokenPermissionGroupListResponseCategory = "app_security" + TokenPermissionGroupListResponseCategoryRulesAndConfiguration TokenPermissionGroupListResponseCategory = "rules_and_configuration" + TokenPermissionGroupListResponseCategoryCloudflareOneAndZeroTrust TokenPermissionGroupListResponseCategory = "cloudflare_one_and_zero_trust" + TokenPermissionGroupListResponseCategoryAnalyticsAndLogs TokenPermissionGroupListResponseCategory = "analytics_and_logs" + TokenPermissionGroupListResponseCategoryNetworkServices TokenPermissionGroupListResponseCategory = "network_services" + TokenPermissionGroupListResponseCategoryMedia TokenPermissionGroupListResponseCategory = "media" + TokenPermissionGroupListResponseCategoryEmailAndMessaging TokenPermissionGroupListResponseCategory = "email_and_messaging" + TokenPermissionGroupListResponseCategoryCacheAndPerformance TokenPermissionGroupListResponseCategory = "cache_and_performance" + TokenPermissionGroupListResponseCategoryAccountAndBilling TokenPermissionGroupListResponseCategory = "account_and_billing" + TokenPermissionGroupListResponseCategoryOther TokenPermissionGroupListResponseCategory = "other" +) + +func (r TokenPermissionGroupListResponseCategory) IsKnown() bool { + switch r { + case TokenPermissionGroupListResponseCategoryDeveloperPlatform, TokenPermissionGroupListResponseCategoryAIAndMachineLearning, TokenPermissionGroupListResponseCategoryDNSAndZones, TokenPermissionGroupListResponseCategoryAppSecurity, TokenPermissionGroupListResponseCategoryRulesAndConfiguration, TokenPermissionGroupListResponseCategoryCloudflareOneAndZeroTrust, TokenPermissionGroupListResponseCategoryAnalyticsAndLogs, TokenPermissionGroupListResponseCategoryNetworkServices, TokenPermissionGroupListResponseCategoryMedia, TokenPermissionGroupListResponseCategoryEmailAndMessaging, TokenPermissionGroupListResponseCategoryCacheAndPerformance, TokenPermissionGroupListResponseCategoryAccountAndBilling, TokenPermissionGroupListResponseCategoryOther: + return true + } + return false +} + type TokenPermissionGroupListResponseScope string const ( @@ -129,6 +159,8 @@ func (r TokenPermissionGroupListResponseScope) IsKnown() bool { type TokenPermissionGroupGetResponse struct { // Public ID. ID string `json:"id"` + // Product category that this permission group belongs to. + Category TokenPermissionGroupGetResponseCategory `json:"category"` // Permission Group Name Name string `json:"name"` // Resources to which the Permission Group is scoped @@ -140,6 +172,7 @@ type TokenPermissionGroupGetResponse struct { // [TokenPermissionGroupGetResponse] type tokenPermissionGroupGetResponseJSON struct { ID apijson.Field + Category apijson.Field Name apijson.Field Scopes apijson.Field raw string @@ -154,6 +187,33 @@ func (r tokenPermissionGroupGetResponseJSON) RawJSON() string { return r.raw } +// Product category that this permission group belongs to. +type TokenPermissionGroupGetResponseCategory string + +const ( + TokenPermissionGroupGetResponseCategoryDeveloperPlatform TokenPermissionGroupGetResponseCategory = "developer_platform" + TokenPermissionGroupGetResponseCategoryAIAndMachineLearning TokenPermissionGroupGetResponseCategory = "ai_and_machine_learning" + TokenPermissionGroupGetResponseCategoryDNSAndZones TokenPermissionGroupGetResponseCategory = "dns_and_zones" + TokenPermissionGroupGetResponseCategoryAppSecurity TokenPermissionGroupGetResponseCategory = "app_security" + TokenPermissionGroupGetResponseCategoryRulesAndConfiguration TokenPermissionGroupGetResponseCategory = "rules_and_configuration" + TokenPermissionGroupGetResponseCategoryCloudflareOneAndZeroTrust TokenPermissionGroupGetResponseCategory = "cloudflare_one_and_zero_trust" + TokenPermissionGroupGetResponseCategoryAnalyticsAndLogs TokenPermissionGroupGetResponseCategory = "analytics_and_logs" + TokenPermissionGroupGetResponseCategoryNetworkServices TokenPermissionGroupGetResponseCategory = "network_services" + TokenPermissionGroupGetResponseCategoryMedia TokenPermissionGroupGetResponseCategory = "media" + TokenPermissionGroupGetResponseCategoryEmailAndMessaging TokenPermissionGroupGetResponseCategory = "email_and_messaging" + TokenPermissionGroupGetResponseCategoryCacheAndPerformance TokenPermissionGroupGetResponseCategory = "cache_and_performance" + TokenPermissionGroupGetResponseCategoryAccountAndBilling TokenPermissionGroupGetResponseCategory = "account_and_billing" + TokenPermissionGroupGetResponseCategoryOther TokenPermissionGroupGetResponseCategory = "other" +) + +func (r TokenPermissionGroupGetResponseCategory) IsKnown() bool { + switch r { + case TokenPermissionGroupGetResponseCategoryDeveloperPlatform, TokenPermissionGroupGetResponseCategoryAIAndMachineLearning, TokenPermissionGroupGetResponseCategoryDNSAndZones, TokenPermissionGroupGetResponseCategoryAppSecurity, TokenPermissionGroupGetResponseCategoryRulesAndConfiguration, TokenPermissionGroupGetResponseCategoryCloudflareOneAndZeroTrust, TokenPermissionGroupGetResponseCategoryAnalyticsAndLogs, TokenPermissionGroupGetResponseCategoryNetworkServices, TokenPermissionGroupGetResponseCategoryMedia, TokenPermissionGroupGetResponseCategoryEmailAndMessaging, TokenPermissionGroupGetResponseCategoryCacheAndPerformance, TokenPermissionGroupGetResponseCategoryAccountAndBilling, TokenPermissionGroupGetResponseCategoryOther: + return true + } + return false +} + type TokenPermissionGroupGetResponseScope string const ( diff --git a/ai_gateway/aigateway.go b/ai_gateway/aigateway.go index 5454a4efdba..7797b10aa3e 100644 --- a/ai_gateway/aigateway.go +++ b/ai_gateway/aigateway.go @@ -1065,7 +1065,10 @@ func (r AIGatewayNewResponseSpendLimitsRulesLimitType) IsKnown() bool { } type AIGatewayNewResponseSpendLimitsRulesMetadata struct { - Mode AIGatewayNewResponseSpendLimitsRulesMetadataMode `json:"mode" api:"required"` + // This field can have the runtime type of + // [AIGatewayNewResponseSpendLimitsRulesMetadataModeMode], + // [AIGatewayNewResponseSpendLimitsRulesMetadataObjectMode]. + Mode interface{} `json:"mode" api:"required"` // This field can have the runtime type of [[]string]. Values interface{} `json:"values"` JSON aiGatewayNewResponseSpendLimitsRulesMetadataJSON `json:"-"` @@ -2253,7 +2256,10 @@ func (r AIGatewayUpdateResponseSpendLimitsRulesLimitType) IsKnown() bool { } type AIGatewayUpdateResponseSpendLimitsRulesMetadata struct { - Mode AIGatewayUpdateResponseSpendLimitsRulesMetadataMode `json:"mode" api:"required"` + // This field can have the runtime type of + // [AIGatewayUpdateResponseSpendLimitsRulesMetadataModeMode], + // [AIGatewayUpdateResponseSpendLimitsRulesMetadataObjectMode]. + Mode interface{} `json:"mode" api:"required"` // This field can have the runtime type of [[]string]. Values interface{} `json:"values"` JSON aiGatewayUpdateResponseSpendLimitsRulesMetadataJSON `json:"-"` @@ -3441,7 +3447,10 @@ func (r AIGatewayListResponseSpendLimitsRulesLimitType) IsKnown() bool { } type AIGatewayListResponseSpendLimitsRulesMetadata struct { - Mode AIGatewayListResponseSpendLimitsRulesMetadataMode `json:"mode" api:"required"` + // This field can have the runtime type of + // [AIGatewayListResponseSpendLimitsRulesMetadataModeMode], + // [AIGatewayListResponseSpendLimitsRulesMetadataObjectMode]. + Mode interface{} `json:"mode" api:"required"` // This field can have the runtime type of [[]string]. Values interface{} `json:"values"` JSON aiGatewayListResponseSpendLimitsRulesMetadataJSON `json:"-"` @@ -4629,7 +4638,10 @@ func (r AIGatewayDeleteResponseSpendLimitsRulesLimitType) IsKnown() bool { } type AIGatewayDeleteResponseSpendLimitsRulesMetadata struct { - Mode AIGatewayDeleteResponseSpendLimitsRulesMetadataMode `json:"mode" api:"required"` + // This field can have the runtime type of + // [AIGatewayDeleteResponseSpendLimitsRulesMetadataModeMode], + // [AIGatewayDeleteResponseSpendLimitsRulesMetadataObjectMode]. + Mode interface{} `json:"mode" api:"required"` // This field can have the runtime type of [[]string]. Values interface{} `json:"values"` JSON aiGatewayDeleteResponseSpendLimitsRulesMetadataJSON `json:"-"` @@ -5816,7 +5828,10 @@ func (r AIGatewayGetResponseSpendLimitsRulesLimitType) IsKnown() bool { } type AIGatewayGetResponseSpendLimitsRulesMetadata struct { - Mode AIGatewayGetResponseSpendLimitsRulesMetadataMode `json:"mode" api:"required"` + // This field can have the runtime type of + // [AIGatewayGetResponseSpendLimitsRulesMetadataModeMode], + // [AIGatewayGetResponseSpendLimitsRulesMetadataObjectMode]. + Mode interface{} `json:"mode" api:"required"` // This field can have the runtime type of [[]string]. Values interface{} `json:"values"` JSON aiGatewayGetResponseSpendLimitsRulesMetadataJSON `json:"-"` diff --git a/ai_gateway/billingspendinglimit.go b/ai_gateway/billingspendinglimit.go index 892356e3ebb..444ee4ccf50 100644 --- a/ai_gateway/billingspendinglimit.go +++ b/ai_gateway/billingspendinglimit.go @@ -34,7 +34,12 @@ func NewBillingSpendingLimitService(opts ...option.RequestOption) (r *BillingSpe return } -// Configure a spending limit with amount, strategy, and duration. +// Deprecated: spending limits can no longer be created, enabled, or modified and +// this endpoint always responds 403. Use the new AI Gateway spend limits instead: +// https://developers.cloudflare.com/ai-gateway/features/spend-limits/. Existing +// limits can be removed via DELETE /spending-limit. +// +// Deprecated: deprecated func (r *BillingSpendingLimitService) New(ctx context.Context, params BillingSpendingLimitNewParams, opts ...option.RequestOption) (res *BillingSpendingLimitNewResponse, err error) { var env BillingSpendingLimitNewResponseEnvelope opts = slices.Concat(r.Options, opts) diff --git a/ai_search/instance.go b/ai_search/instance.go index 8583ff50f59..6b39d78b25c 100644 --- a/ai_search/instance.go +++ b/ai_search/instance.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "reflect" "slices" "time" @@ -17,7 +18,8 @@ import ( "github.com/cloudflare/cloudflare-go/v7/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v7/option" "github.com/cloudflare/cloudflare-go/v7/packages/pagination" - "github.com/cloudflare/cloudflare-go/v7/r2" + "github.com/cloudflare/cloudflare-go/v7/shared" + "github.com/tidwall/gjson" ) // InstanceService contains methods and other services that help with interacting @@ -446,6 +448,7 @@ type InstanceNewResponseEmbeddingModel string const ( InstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b InstanceNewResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceNewResponseEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceNewResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceNewResponseEmbeddingModelCfBaaiBgeM3 InstanceNewResponseEmbeddingModel = "@cf/baai/bge-m3" InstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceNewResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m InstanceNewResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -458,7 +461,7 @@ const ( func (r InstanceNewResponseEmbeddingModel) IsKnown() bool { switch r { - case InstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceNewResponseEmbeddingModelCfBaaiBgeM3, InstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceNewResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceNewResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceNewResponseEmbeddingModelEmpty: + case InstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceNewResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceNewResponseEmbeddingModelCfBaaiBgeM3, InstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceNewResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceNewResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceNewResponseEmbeddingModelEmpty: return true } return false @@ -576,11 +579,16 @@ func (r instanceNewResponseMetadataJSON) RawJSON() string { type InstanceNewResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint InstanceNewResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp InstanceNewResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit InstanceNewResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint InstanceNewResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON instanceNewResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp InstanceNewResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit InstanceNewResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint InstanceNewResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON instanceNewResponsePublicEndpointParamsJSON `json:"-"` } // instanceNewResponsePublicEndpointParamsJSON contains the JSON metadata for the @@ -588,6 +596,7 @@ type InstanceNewResponsePublicEndpointParams struct { type instanceNewResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -909,7 +918,6 @@ func (r instanceNewResponseSourceParamsJSON) RawJSON() string { type InstanceNewResponseSourceParamsWebCrawler struct { ParseOptions InstanceNewResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType InstanceNewResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions InstanceNewResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON instanceNewResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -918,7 +926,6 @@ type InstanceNewResponseSourceParamsWebCrawler struct { type instanceNewResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1002,43 +1009,17 @@ type InstanceNewResponseSourceParamsWebCrawlerParseType string const ( InstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap InstanceNewResponseSourceParamsWebCrawlerParseType = "sitemap" - InstanceNewResponseSourceParamsWebCrawlerParseTypeFeedRss InstanceNewResponseSourceParamsWebCrawlerParseType = "feed-rss" InstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl InstanceNewResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceNewResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceNewResponseSourceParamsWebCrawlerParseTypeFeedRss, InstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl: + case InstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceNewResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON instanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// instanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON contains the JSON -// metadata for the struct [InstanceNewResponseSourceParamsWebCrawlerStoreOptions] -type instanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InstanceNewResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r instanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceNewResponseSyncInterval float64 @@ -1315,6 +1296,7 @@ type InstanceUpdateResponseEmbeddingModel string const ( InstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b InstanceUpdateResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceUpdateResponseEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceUpdateResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceUpdateResponseEmbeddingModelCfBaaiBgeM3 InstanceUpdateResponseEmbeddingModel = "@cf/baai/bge-m3" InstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceUpdateResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m InstanceUpdateResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -1327,7 +1309,7 @@ const ( func (r InstanceUpdateResponseEmbeddingModel) IsKnown() bool { switch r { - case InstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceUpdateResponseEmbeddingModelCfBaaiBgeM3, InstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceUpdateResponseEmbeddingModelEmpty: + case InstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceUpdateResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceUpdateResponseEmbeddingModelCfBaaiBgeM3, InstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceUpdateResponseEmbeddingModelEmpty: return true } return false @@ -1445,11 +1427,16 @@ func (r instanceUpdateResponseMetadataJSON) RawJSON() string { type InstanceUpdateResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint InstanceUpdateResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp InstanceUpdateResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit InstanceUpdateResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint InstanceUpdateResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON instanceUpdateResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp InstanceUpdateResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit InstanceUpdateResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint InstanceUpdateResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON instanceUpdateResponsePublicEndpointParamsJSON `json:"-"` } // instanceUpdateResponsePublicEndpointParamsJSON contains the JSON metadata for @@ -1457,6 +1444,7 @@ type InstanceUpdateResponsePublicEndpointParams struct { type instanceUpdateResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -1779,7 +1767,6 @@ func (r instanceUpdateResponseSourceParamsJSON) RawJSON() string { type InstanceUpdateResponseSourceParamsWebCrawler struct { ParseOptions InstanceUpdateResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType InstanceUpdateResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions InstanceUpdateResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON instanceUpdateResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -1788,7 +1775,6 @@ type InstanceUpdateResponseSourceParamsWebCrawler struct { type instanceUpdateResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1873,44 +1859,17 @@ type InstanceUpdateResponseSourceParamsWebCrawlerParseType string const ( InstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap InstanceUpdateResponseSourceParamsWebCrawlerParseType = "sitemap" - InstanceUpdateResponseSourceParamsWebCrawlerParseTypeFeedRss InstanceUpdateResponseSourceParamsWebCrawlerParseType = "feed-rss" InstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl InstanceUpdateResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceUpdateResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceUpdateResponseSourceParamsWebCrawlerParseTypeFeedRss, InstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl: + case InstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceUpdateResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON instanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// instanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON contains the JSON -// metadata for the struct -// [InstanceUpdateResponseSourceParamsWebCrawlerStoreOptions] -type instanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InstanceUpdateResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r instanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceUpdateResponseSyncInterval float64 @@ -2187,6 +2146,7 @@ type InstanceListResponseEmbeddingModel string const ( InstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b InstanceListResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceListResponseEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceListResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceListResponseEmbeddingModelCfBaaiBgeM3 InstanceListResponseEmbeddingModel = "@cf/baai/bge-m3" InstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceListResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m InstanceListResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -2199,7 +2159,7 @@ const ( func (r InstanceListResponseEmbeddingModel) IsKnown() bool { switch r { - case InstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceListResponseEmbeddingModelCfBaaiBgeM3, InstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceListResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceListResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceListResponseEmbeddingModelEmpty: + case InstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceListResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceListResponseEmbeddingModelCfBaaiBgeM3, InstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceListResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceListResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceListResponseEmbeddingModelEmpty: return true } return false @@ -2317,11 +2277,16 @@ func (r instanceListResponseMetadataJSON) RawJSON() string { type InstanceListResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint InstanceListResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp InstanceListResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit InstanceListResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint InstanceListResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON instanceListResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp InstanceListResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit InstanceListResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint InstanceListResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON instanceListResponsePublicEndpointParamsJSON `json:"-"` } // instanceListResponsePublicEndpointParamsJSON contains the JSON metadata for the @@ -2329,6 +2294,7 @@ type InstanceListResponsePublicEndpointParams struct { type instanceListResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -2650,7 +2616,6 @@ func (r instanceListResponseSourceParamsJSON) RawJSON() string { type InstanceListResponseSourceParamsWebCrawler struct { ParseOptions InstanceListResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType InstanceListResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions InstanceListResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON instanceListResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -2659,7 +2624,6 @@ type InstanceListResponseSourceParamsWebCrawler struct { type instanceListResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -2743,43 +2707,17 @@ type InstanceListResponseSourceParamsWebCrawlerParseType string const ( InstanceListResponseSourceParamsWebCrawlerParseTypeSitemap InstanceListResponseSourceParamsWebCrawlerParseType = "sitemap" - InstanceListResponseSourceParamsWebCrawlerParseTypeFeedRss InstanceListResponseSourceParamsWebCrawlerParseType = "feed-rss" InstanceListResponseSourceParamsWebCrawlerParseTypeCrawl InstanceListResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceListResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceListResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceListResponseSourceParamsWebCrawlerParseTypeFeedRss, InstanceListResponseSourceParamsWebCrawlerParseTypeCrawl: + case InstanceListResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceListResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceListResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON instanceListResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// instanceListResponseSourceParamsWebCrawlerStoreOptionsJSON contains the JSON -// metadata for the struct [InstanceListResponseSourceParamsWebCrawlerStoreOptions] -type instanceListResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InstanceListResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r instanceListResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceListResponseSyncInterval float64 @@ -3056,6 +2994,7 @@ type InstanceDeleteResponseEmbeddingModel string const ( InstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b InstanceDeleteResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceDeleteResponseEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceDeleteResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceDeleteResponseEmbeddingModelCfBaaiBgeM3 InstanceDeleteResponseEmbeddingModel = "@cf/baai/bge-m3" InstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceDeleteResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m InstanceDeleteResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -3068,7 +3007,7 @@ const ( func (r InstanceDeleteResponseEmbeddingModel) IsKnown() bool { switch r { - case InstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceDeleteResponseEmbeddingModelCfBaaiBgeM3, InstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceDeleteResponseEmbeddingModelEmpty: + case InstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceDeleteResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceDeleteResponseEmbeddingModelCfBaaiBgeM3, InstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceDeleteResponseEmbeddingModelEmpty: return true } return false @@ -3186,11 +3125,16 @@ func (r instanceDeleteResponseMetadataJSON) RawJSON() string { type InstanceDeleteResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint InstanceDeleteResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp InstanceDeleteResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit InstanceDeleteResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint InstanceDeleteResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON instanceDeleteResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp InstanceDeleteResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit InstanceDeleteResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint InstanceDeleteResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON instanceDeleteResponsePublicEndpointParamsJSON `json:"-"` } // instanceDeleteResponsePublicEndpointParamsJSON contains the JSON metadata for @@ -3198,6 +3142,7 @@ type InstanceDeleteResponsePublicEndpointParams struct { type instanceDeleteResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -3520,7 +3465,6 @@ func (r instanceDeleteResponseSourceParamsJSON) RawJSON() string { type InstanceDeleteResponseSourceParamsWebCrawler struct { ParseOptions InstanceDeleteResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType InstanceDeleteResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions InstanceDeleteResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON instanceDeleteResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -3529,7 +3473,6 @@ type InstanceDeleteResponseSourceParamsWebCrawler struct { type instanceDeleteResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -3614,44 +3557,17 @@ type InstanceDeleteResponseSourceParamsWebCrawlerParseType string const ( InstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap InstanceDeleteResponseSourceParamsWebCrawlerParseType = "sitemap" - InstanceDeleteResponseSourceParamsWebCrawlerParseTypeFeedRss InstanceDeleteResponseSourceParamsWebCrawlerParseType = "feed-rss" InstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl InstanceDeleteResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceDeleteResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceDeleteResponseSourceParamsWebCrawlerParseTypeFeedRss, InstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl: + case InstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceDeleteResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON instanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// instanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON contains the JSON -// metadata for the struct -// [InstanceDeleteResponseSourceParamsWebCrawlerStoreOptions] -type instanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InstanceDeleteResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r instanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceDeleteResponseSyncInterval float64 @@ -3744,10 +3660,10 @@ func (r instanceChatCompletionsResponseChoiceJSON) RawJSON() string { } type InstanceChatCompletionsResponseChoicesMessage struct { - Content string `json:"content" api:"required,nullable"` - Role InstanceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-" api:"extrafields"` - JSON instanceChatCompletionsResponseChoicesMessageJSON `json:"-"` + Content InstanceChatCompletionsResponseChoicesMessageContentUnion `json:"content" api:"required,nullable"` + Role InstanceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-" api:"extrafields"` + JSON instanceChatCompletionsResponseChoicesMessageJSON `json:"-"` } // instanceChatCompletionsResponseChoicesMessageJSON contains the JSON metadata for @@ -3767,6 +3683,155 @@ func (r instanceChatCompletionsResponseChoicesMessageJSON) RawJSON() string { return r.raw } +// Union satisfied by [shared.UnionString] or +// [InstanceChatCompletionsResponseChoicesMessageContentArray]. +type InstanceChatCompletionsResponseChoicesMessageContentUnion interface { + ImplementsInstanceChatCompletionsResponseChoicesMessageContentUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*InstanceChatCompletionsResponseChoicesMessageContentUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(InstanceChatCompletionsResponseChoicesMessageContentArray{}), + }, + ) +} + +type InstanceChatCompletionsResponseChoicesMessageContentArray []InstanceChatCompletionsResponseChoicesMessageContentArrayItem + +func (r InstanceChatCompletionsResponseChoicesMessageContentArray) ImplementsInstanceChatCompletionsResponseChoicesMessageContentUnion() { +} + +type InstanceChatCompletionsResponseChoicesMessageContentArrayItem struct { + Type InstanceChatCompletionsResponseChoicesMessageContentArrayType `json:"type" api:"required"` + // This field can have the runtime type of + // [InstanceChatCompletionsResponseChoicesMessageContentArrayObjectImageURL]. + ImageURL interface{} `json:"image_url"` + Text string `json:"text"` + JSON instanceChatCompletionsResponseChoicesMessageContentArrayItemJSON `json:"-"` + union InstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem +} + +// instanceChatCompletionsResponseChoicesMessageContentArrayItemJSON contains the +// JSON metadata for the struct +// [InstanceChatCompletionsResponseChoicesMessageContentArrayItem] +type instanceChatCompletionsResponseChoicesMessageContentArrayItemJSON struct { + Type apijson.Field + ImageURL apijson.Field + Text apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r instanceChatCompletionsResponseChoicesMessageContentArrayItemJSON) RawJSON() string { + return r.raw +} + +func (r *InstanceChatCompletionsResponseChoicesMessageContentArrayItem) UnmarshalJSON(data []byte) (err error) { + *r = InstanceChatCompletionsResponseChoicesMessageContentArrayItem{} + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +// AsUnion returns a +// [InstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem] interface +// which you can cast to the specific types for more type safety. +// +// Possible runtime types of the union are +// [InstanceChatCompletionsResponseChoicesMessageContentArrayObject], +// [InstanceChatCompletionsResponseChoicesMessageContentArrayObject]. +func (r InstanceChatCompletionsResponseChoicesMessageContentArrayItem) AsUnion() InstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem { + return r.union +} + +// Union satisfied by +// [InstanceChatCompletionsResponseChoicesMessageContentArrayObject] or +// [InstanceChatCompletionsResponseChoicesMessageContentArrayObject]. +type InstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem interface { + implementsInstanceChatCompletionsResponseChoicesMessageContentArrayItem() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*InstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(InstanceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(InstanceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + ) +} + +type InstanceChatCompletionsResponseChoicesMessageContentArrayObject struct { + Text string `json:"text" api:"required"` + Type InstanceChatCompletionsResponseChoicesMessageContentArrayObjectType `json:"type" api:"required"` + JSON instanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON `json:"-"` +} + +// instanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON contains the +// JSON metadata for the struct +// [InstanceChatCompletionsResponseChoicesMessageContentArrayObject] +type instanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON struct { + Text apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *InstanceChatCompletionsResponseChoicesMessageContentArrayObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r instanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON) RawJSON() string { + return r.raw +} + +func (r InstanceChatCompletionsResponseChoicesMessageContentArrayObject) implementsInstanceChatCompletionsResponseChoicesMessageContentArrayItem() { +} + +type InstanceChatCompletionsResponseChoicesMessageContentArrayObjectType string + +const ( + InstanceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText InstanceChatCompletionsResponseChoicesMessageContentArrayObjectType = "text" +) + +func (r InstanceChatCompletionsResponseChoicesMessageContentArrayObjectType) IsKnown() bool { + switch r { + case InstanceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText: + return true + } + return false +} + +type InstanceChatCompletionsResponseChoicesMessageContentArrayType string + +const ( + InstanceChatCompletionsResponseChoicesMessageContentArrayTypeText InstanceChatCompletionsResponseChoicesMessageContentArrayType = "text" + InstanceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL InstanceChatCompletionsResponseChoicesMessageContentArrayType = "image_url" +) + +func (r InstanceChatCompletionsResponseChoicesMessageContentArrayType) IsKnown() bool { + switch r { + case InstanceChatCompletionsResponseChoicesMessageContentArrayTypeText, InstanceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL: + return true + } + return false +} + type InstanceChatCompletionsResponseChoicesMessageRole string const ( @@ -4125,6 +4190,7 @@ type InstanceReadResponseEmbeddingModel string const ( InstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b InstanceReadResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceReadResponseEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceReadResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceReadResponseEmbeddingModelCfBaaiBgeM3 InstanceReadResponseEmbeddingModel = "@cf/baai/bge-m3" InstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceReadResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m InstanceReadResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -4137,7 +4203,7 @@ const ( func (r InstanceReadResponseEmbeddingModel) IsKnown() bool { switch r { - case InstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceReadResponseEmbeddingModelCfBaaiBgeM3, InstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceReadResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceReadResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceReadResponseEmbeddingModelEmpty: + case InstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceReadResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceReadResponseEmbeddingModelCfBaaiBgeM3, InstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceReadResponseEmbeddingModelOpenAITextEmbedding3Small, InstanceReadResponseEmbeddingModelOpenAITextEmbedding3Large, InstanceReadResponseEmbeddingModelEmpty: return true } return false @@ -4255,11 +4321,16 @@ func (r instanceReadResponseMetadataJSON) RawJSON() string { type InstanceReadResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint InstanceReadResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp InstanceReadResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit InstanceReadResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint InstanceReadResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON instanceReadResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp InstanceReadResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit InstanceReadResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint InstanceReadResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON instanceReadResponsePublicEndpointParamsJSON `json:"-"` } // instanceReadResponsePublicEndpointParamsJSON contains the JSON metadata for the @@ -4267,6 +4338,7 @@ type InstanceReadResponsePublicEndpointParams struct { type instanceReadResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -4588,7 +4660,6 @@ func (r instanceReadResponseSourceParamsJSON) RawJSON() string { type InstanceReadResponseSourceParamsWebCrawler struct { ParseOptions InstanceReadResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType InstanceReadResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions InstanceReadResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON instanceReadResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -4597,7 +4668,6 @@ type InstanceReadResponseSourceParamsWebCrawler struct { type instanceReadResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -4681,43 +4751,17 @@ type InstanceReadResponseSourceParamsWebCrawlerParseType string const ( InstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap InstanceReadResponseSourceParamsWebCrawlerParseType = "sitemap" - InstanceReadResponseSourceParamsWebCrawlerParseTypeFeedRss InstanceReadResponseSourceParamsWebCrawlerParseType = "feed-rss" InstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl InstanceReadResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceReadResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceReadResponseSourceParamsWebCrawlerParseTypeFeedRss, InstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl: + case InstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap, InstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceReadResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON instanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// instanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON contains the JSON -// metadata for the struct [InstanceReadResponseSourceParamsWebCrawlerStoreOptions] -type instanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InstanceReadResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r instanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceReadResponseSyncInterval float64 @@ -4757,15 +4801,17 @@ func (r InstanceReadResponseType) IsKnown() bool { } type InstanceSearchResponse struct { - Chunks []InstanceSearchResponseChunk `json:"chunks" api:"required"` - SearchQuery string `json:"search_query" api:"required"` - JSON instanceSearchResponseJSON `json:"-"` + Chunks []InstanceSearchResponseChunk `json:"chunks" api:"required"` + QueryKind InstanceSearchResponseQueryKind `json:"query_kind" api:"required"` + SearchQuery string `json:"search_query"` + JSON instanceSearchResponseJSON `json:"-"` } // instanceSearchResponseJSON contains the JSON metadata for the struct // [InstanceSearchResponse] type instanceSearchResponseJSON struct { Chunks apijson.Field + QueryKind apijson.Field SearchQuery apijson.Field raw string ExtraFields map[string]apijson.Field @@ -4881,6 +4927,22 @@ func (r InstanceSearchResponseChunksScoringDetailsFusionMethod) IsKnown() bool { return false } +type InstanceSearchResponseQueryKind string + +const ( + InstanceSearchResponseQueryKindText InstanceSearchResponseQueryKind = "text" + InstanceSearchResponseQueryKindImage InstanceSearchResponseQueryKind = "image" + InstanceSearchResponseQueryKindMultimodal InstanceSearchResponseQueryKind = "multimodal" +) + +func (r InstanceSearchResponseQueryKind) IsKnown() bool { + switch r { + case InstanceSearchResponseQueryKindText, InstanceSearchResponseQueryKindImage, InstanceSearchResponseQueryKindMultimodal: + return true + } + return false +} + type InstanceStatsResponse struct { Completed int64 `json:"completed"` // True when status counts are unavailable (e.g. legacy stats query exceeded D1 @@ -5163,6 +5225,7 @@ type InstanceNewParamsEmbeddingModel string const ( InstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b InstanceNewParamsEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceNewParamsEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceNewParamsEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceNewParamsEmbeddingModelCfBaaiBgeM3 InstanceNewParamsEmbeddingModel = "@cf/baai/bge-m3" InstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceNewParamsEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m InstanceNewParamsEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -5175,7 +5238,7 @@ const ( func (r InstanceNewParamsEmbeddingModel) IsKnown() bool { switch r { - case InstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceNewParamsEmbeddingModelCfBaaiBgeM3, InstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceNewParamsEmbeddingModelOpenAITextEmbedding3Small, InstanceNewParamsEmbeddingModelOpenAITextEmbedding3Large, InstanceNewParamsEmbeddingModelEmpty: + case InstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceNewParamsEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceNewParamsEmbeddingModelCfBaaiBgeM3, InstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceNewParamsEmbeddingModelOpenAITextEmbedding3Small, InstanceNewParamsEmbeddingModelOpenAITextEmbedding3Large, InstanceNewParamsEmbeddingModelEmpty: return true } return false @@ -5252,10 +5315,15 @@ func (r InstanceNewParamsMetadata) MarshalJSON() (data []byte, err error) { type InstanceNewParamsPublicEndpointParams struct { AuthorizedHosts param.Field[[]string] `json:"authorized_hosts"` ChatCompletionsEndpoint param.Field[InstanceNewParamsPublicEndpointParamsChatCompletionsEndpoint] `json:"chat_completions_endpoint"` - Enabled param.Field[bool] `json:"enabled"` - Mcp param.Field[InstanceNewParamsPublicEndpointParamsMcp] `json:"mcp"` - RateLimit param.Field[InstanceNewParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` - SearchEndpoint param.Field[InstanceNewParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains param.Field[[]string] `json:"custom_domains"` + Enabled param.Field[bool] `json:"enabled"` + Mcp param.Field[InstanceNewParamsPublicEndpointParamsMcp] `json:"mcp"` + RateLimit param.Field[InstanceNewParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` + SearchEndpoint param.Field[InstanceNewParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` } func (r InstanceNewParamsPublicEndpointParams) MarshalJSON() (data []byte, err error) { @@ -5466,7 +5534,6 @@ func (r InstanceNewParamsSourceParams) MarshalJSON() (data []byte, err error) { type InstanceNewParamsSourceParamsWebCrawler struct { ParseOptions param.Field[InstanceNewParamsSourceParamsWebCrawlerParseOptions] `json:"parse_options"` ParseType param.Field[InstanceNewParamsSourceParamsWebCrawlerParseType] `json:"parse_type"` - StoreOptions param.Field[InstanceNewParamsSourceParamsWebCrawlerStoreOptions] `json:"store_options"` } func (r InstanceNewParamsSourceParamsWebCrawler) MarshalJSON() (data []byte, err error) { @@ -5512,28 +5579,17 @@ type InstanceNewParamsSourceParamsWebCrawlerParseType string const ( InstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap InstanceNewParamsSourceParamsWebCrawlerParseType = "sitemap" - InstanceNewParamsSourceParamsWebCrawlerParseTypeFeedRss InstanceNewParamsSourceParamsWebCrawlerParseType = "feed-rss" InstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl InstanceNewParamsSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceNewParamsSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap, InstanceNewParamsSourceParamsWebCrawlerParseTypeFeedRss, InstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl: + case InstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap, InstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceNewParamsSourceParamsWebCrawlerStoreOptions struct { - StorageID param.Field[string] `json:"storage_id" api:"required"` - R2Jurisdiction param.Field[string] `json:"r2_jurisdiction"` - StorageType param.Field[r2.Provider] `json:"storage_type"` -} - -func (r InstanceNewParamsSourceParamsWebCrawlerStoreOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type InstanceNewParamsSyncInterval float64 @@ -5625,6 +5681,7 @@ type InstanceUpdateParams struct { RewriteModel param.Field[InstanceUpdateParamsRewriteModel] `json:"rewrite_model"` RewriteQuery param.Field[bool] `json:"rewrite_query"` ScoreThreshold param.Field[float64] `json:"score_threshold"` + Source param.Field[string] `json:"source"` SourceParams param.Field[InstanceUpdateParamsSourceParams] `json:"source_params"` Summarization param.Field[bool] `json:"summarization"` SummarizationModel param.Field[InstanceUpdateParamsSummarizationModel] `json:"summarization_model"` @@ -5757,6 +5814,7 @@ type InstanceUpdateParamsEmbeddingModel string const ( InstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b InstanceUpdateParamsEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + InstanceUpdateParamsEmbeddingModelCfQwenQwen3VlEmbedding2b InstanceUpdateParamsEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" InstanceUpdateParamsEmbeddingModelCfBaaiBgeM3 InstanceUpdateParamsEmbeddingModel = "@cf/baai/bge-m3" InstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5 InstanceUpdateParamsEmbeddingModel = "@cf/baai/bge-large-en-v1.5" InstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m InstanceUpdateParamsEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -5769,7 +5827,7 @@ const ( func (r InstanceUpdateParamsEmbeddingModel) IsKnown() bool { switch r { - case InstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceUpdateParamsEmbeddingModelCfBaaiBgeM3, InstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Small, InstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Large, InstanceUpdateParamsEmbeddingModelEmpty: + case InstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b, InstanceUpdateParamsEmbeddingModelCfQwenQwen3VlEmbedding2b, InstanceUpdateParamsEmbeddingModelCfBaaiBgeM3, InstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, InstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m, InstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, InstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, InstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Small, InstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Large, InstanceUpdateParamsEmbeddingModelEmpty: return true } return false @@ -5846,10 +5904,15 @@ func (r InstanceUpdateParamsMetadata) MarshalJSON() (data []byte, err error) { type InstanceUpdateParamsPublicEndpointParams struct { AuthorizedHosts param.Field[[]string] `json:"authorized_hosts"` ChatCompletionsEndpoint param.Field[InstanceUpdateParamsPublicEndpointParamsChatCompletionsEndpoint] `json:"chat_completions_endpoint"` - Enabled param.Field[bool] `json:"enabled"` - Mcp param.Field[InstanceUpdateParamsPublicEndpointParamsMcp] `json:"mcp"` - RateLimit param.Field[InstanceUpdateParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` - SearchEndpoint param.Field[InstanceUpdateParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains param.Field[[]string] `json:"custom_domains"` + Enabled param.Field[bool] `json:"enabled"` + Mcp param.Field[InstanceUpdateParamsPublicEndpointParamsMcp] `json:"mcp"` + RateLimit param.Field[InstanceUpdateParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` + SearchEndpoint param.Field[InstanceUpdateParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` } func (r InstanceUpdateParamsPublicEndpointParams) MarshalJSON() (data []byte, err error) { @@ -6060,7 +6123,6 @@ func (r InstanceUpdateParamsSourceParams) MarshalJSON() (data []byte, err error) type InstanceUpdateParamsSourceParamsWebCrawler struct { ParseOptions param.Field[InstanceUpdateParamsSourceParamsWebCrawlerParseOptions] `json:"parse_options"` ParseType param.Field[InstanceUpdateParamsSourceParamsWebCrawlerParseType] `json:"parse_type"` - StoreOptions param.Field[InstanceUpdateParamsSourceParamsWebCrawlerStoreOptions] `json:"store_options"` } func (r InstanceUpdateParamsSourceParamsWebCrawler) MarshalJSON() (data []byte, err error) { @@ -6106,28 +6168,17 @@ type InstanceUpdateParamsSourceParamsWebCrawlerParseType string const ( InstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap InstanceUpdateParamsSourceParamsWebCrawlerParseType = "sitemap" - InstanceUpdateParamsSourceParamsWebCrawlerParseTypeFeedRss InstanceUpdateParamsSourceParamsWebCrawlerParseType = "feed-rss" InstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl InstanceUpdateParamsSourceParamsWebCrawlerParseType = "crawl" ) func (r InstanceUpdateParamsSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case InstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap, InstanceUpdateParamsSourceParamsWebCrawlerParseTypeFeedRss, InstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl: + case InstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap, InstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type InstanceUpdateParamsSourceParamsWebCrawlerStoreOptions struct { - StorageID param.Field[string] `json:"storage_id" api:"required"` - R2Jurisdiction param.Field[string] `json:"r2_jurisdiction"` - StorageType param.Field[r2.Provider] `json:"storage_type"` -} - -func (r InstanceUpdateParamsSourceParamsWebCrawlerStoreOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type InstanceUpdateParamsSummarizationModel string const ( @@ -6312,15 +6363,88 @@ func (r InstanceChatCompletionsParams) MarshalJSON() (data []byte, err error) { } type InstanceChatCompletionsParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[InstanceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[InstanceChatCompletionsParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[InstanceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r InstanceChatCompletionsParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.InstanceChatCompletionsParamsMessagesContentArray]. +type InstanceChatCompletionsParamsMessagesContentUnion interface { + ImplementsInstanceChatCompletionsParamsMessagesContentUnion() +} + +type InstanceChatCompletionsParamsMessagesContentArray []InstanceChatCompletionsParamsMessagesContentArrayItemUnion + +func (r InstanceChatCompletionsParamsMessagesContentArray) ImplementsInstanceChatCompletionsParamsMessagesContentUnion() { +} + +type InstanceChatCompletionsParamsMessagesContentArrayItem struct { + Type param.Field[InstanceChatCompletionsParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r InstanceChatCompletionsParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r InstanceChatCompletionsParamsMessagesContentArrayItem) implementsInstanceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by +// [ai_search.InstanceChatCompletionsParamsMessagesContentArrayObject], +// [ai_search.InstanceChatCompletionsParamsMessagesContentArrayObject], +// [InstanceChatCompletionsParamsMessagesContentArrayItem]. +type InstanceChatCompletionsParamsMessagesContentArrayItemUnion interface { + implementsInstanceChatCompletionsParamsMessagesContentArrayItemUnion() +} + +type InstanceChatCompletionsParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[InstanceChatCompletionsParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r InstanceChatCompletionsParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r InstanceChatCompletionsParamsMessagesContentArrayObject) implementsInstanceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +type InstanceChatCompletionsParamsMessagesContentArrayObjectType string + +const ( + InstanceChatCompletionsParamsMessagesContentArrayObjectTypeText InstanceChatCompletionsParamsMessagesContentArrayObjectType = "text" +) + +func (r InstanceChatCompletionsParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case InstanceChatCompletionsParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type InstanceChatCompletionsParamsMessagesContentArrayType string + +const ( + InstanceChatCompletionsParamsMessagesContentArrayTypeText InstanceChatCompletionsParamsMessagesContentArrayType = "text" + InstanceChatCompletionsParamsMessagesContentArrayTypeImageURL InstanceChatCompletionsParamsMessagesContentArrayType = "image_url" +) + +func (r InstanceChatCompletionsParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case InstanceChatCompletionsParamsMessagesContentArrayTypeText, InstanceChatCompletionsParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type InstanceChatCompletionsParamsMessagesRole string const ( @@ -6639,7 +6763,12 @@ func (r instanceReadResponseEnvelopeJSON) RawJSON() string { type InstanceSearchParams struct { AccountID param.Field[string] `path:"account_id" api:"required"` AISearchOptions param.Field[InstanceSearchParamsAISearchOptions] `json:"ai_search_options"` - Messages param.Field[[]InstanceSearchParamsMessage] `json:"messages"` + // OpenAI-compatible message array. For multimodal queries, set the last user + // message's `content` to an array of typed parts: + // `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image + // inputs require the RAG's embedding_model to declare 'image' in + // supported_modalities. + Messages param.Field[[]InstanceSearchParamsMessage] `json:"messages"` // A simple text query string. Alternative to 'messages' — provide either this or // 'messages', not both. Query param.Field[string] `json:"query"` @@ -6877,15 +7006,87 @@ func (r InstanceSearchParamsAISearchOptionsRetrievalRetrievalType) IsKnown() boo } type InstanceSearchParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[InstanceSearchParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[InstanceSearchParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[InstanceSearchParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r InstanceSearchParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.InstanceSearchParamsMessagesContentArray]. +type InstanceSearchParamsMessagesContentUnion interface { + ImplementsInstanceSearchParamsMessagesContentUnion() +} + +type InstanceSearchParamsMessagesContentArray []InstanceSearchParamsMessagesContentArrayItemUnion + +func (r InstanceSearchParamsMessagesContentArray) ImplementsInstanceSearchParamsMessagesContentUnion() { +} + +type InstanceSearchParamsMessagesContentArrayItem struct { + Type param.Field[InstanceSearchParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r InstanceSearchParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r InstanceSearchParamsMessagesContentArrayItem) implementsInstanceSearchParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by [ai_search.InstanceSearchParamsMessagesContentArrayObject], +// [ai_search.InstanceSearchParamsMessagesContentArrayObject], +// [InstanceSearchParamsMessagesContentArrayItem]. +type InstanceSearchParamsMessagesContentArrayItemUnion interface { + implementsInstanceSearchParamsMessagesContentArrayItemUnion() +} + +type InstanceSearchParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[InstanceSearchParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r InstanceSearchParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r InstanceSearchParamsMessagesContentArrayObject) implementsInstanceSearchParamsMessagesContentArrayItemUnion() { +} + +type InstanceSearchParamsMessagesContentArrayObjectType string + +const ( + InstanceSearchParamsMessagesContentArrayObjectTypeText InstanceSearchParamsMessagesContentArrayObjectType = "text" +) + +func (r InstanceSearchParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case InstanceSearchParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type InstanceSearchParamsMessagesContentArrayType string + +const ( + InstanceSearchParamsMessagesContentArrayTypeText InstanceSearchParamsMessagesContentArrayType = "text" + InstanceSearchParamsMessagesContentArrayTypeImageURL InstanceSearchParamsMessagesContentArrayType = "image_url" +) + +func (r InstanceSearchParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case InstanceSearchParamsMessagesContentArrayTypeText, InstanceSearchParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type InstanceSearchParamsMessagesRole string const ( diff --git a/ai_search/instance_test.go b/ai_search/instance_test.go index 334ffbb6390..fa93dbd5016 100644 --- a/ai_search/instance_test.go +++ b/ai_search/instance_test.go @@ -12,7 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v7/ai_search" "github.com/cloudflare/cloudflare-go/v7/internal/testutil" "github.com/cloudflare/cloudflare-go/v7/option" - "github.com/cloudflare/cloudflare-go/v7/r2" + "github.com/cloudflare/cloudflare-go/v7/shared" ) func TestInstanceNewWithOptionalParams(t *testing.T) { @@ -64,7 +64,8 @@ func TestInstanceNewWithOptionalParams(t *testing.T) { ChatCompletionsEndpoint: cloudflare.F(ai_search.InstanceNewParamsPublicEndpointParamsChatCompletionsEndpoint{ Disabled: cloudflare.F(true), }), - Enabled: cloudflare.F(true), + CustomDomains: cloudflare.F([]string{"search.example.com"}), + Enabled: cloudflare.F(true), Mcp: cloudflare.F(ai_search.InstanceNewParamsPublicEndpointParamsMcp{ Description: cloudflare.F("description"), Disabled: cloudflare.F(true), @@ -113,11 +114,6 @@ func TestInstanceNewWithOptionalParams(t *testing.T) { UseBrowserRendering: cloudflare.F(true), }), ParseType: cloudflare.F(ai_search.InstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap), - StoreOptions: cloudflare.F(ai_search.InstanceNewParamsSourceParamsWebCrawlerStoreOptions{ - StorageID: cloudflare.F("storage_id"), - R2Jurisdiction: cloudflare.F("r2_jurisdiction"), - StorageType: cloudflare.F(r2.ProviderR2), - }), }), }), SyncInterval: cloudflare.F(ai_search.InstanceNewParamsSyncInterval900), @@ -184,7 +180,8 @@ func TestInstanceUpdateWithOptionalParams(t *testing.T) { ChatCompletionsEndpoint: cloudflare.F(ai_search.InstanceUpdateParamsPublicEndpointParamsChatCompletionsEndpoint{ Disabled: cloudflare.F(true), }), - Enabled: cloudflare.F(true), + CustomDomains: cloudflare.F([]string{"search.example.com"}), + Enabled: cloudflare.F(true), Mcp: cloudflare.F(ai_search.InstanceUpdateParamsPublicEndpointParamsMcp{ Description: cloudflare.F("description"), Disabled: cloudflare.F(true), @@ -210,6 +207,7 @@ func TestInstanceUpdateWithOptionalParams(t *testing.T) { RewriteModel: cloudflare.F(ai_search.InstanceUpdateParamsRewriteModelCfMetaLlama3_3_70bInstructFp8Fast), RewriteQuery: cloudflare.F(true), ScoreThreshold: cloudflare.F(0.000000), + Source: cloudflare.F("source"), SourceParams: cloudflare.F(ai_search.InstanceUpdateParamsSourceParams{ ExcludeItems: cloudflare.F([]string{"/admin/**", "/private/**", "**\\temp\\**"}), IncludeItems: cloudflare.F([]string{"/blog/**", "/docs/**/*.html", "**\\blog\\**.html"}), @@ -232,11 +230,6 @@ func TestInstanceUpdateWithOptionalParams(t *testing.T) { UseBrowserRendering: cloudflare.F(true), }), ParseType: cloudflare.F(ai_search.InstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap), - StoreOptions: cloudflare.F(ai_search.InstanceUpdateParamsSourceParamsWebCrawlerStoreOptions{ - StorageID: cloudflare.F("storage_id"), - R2Jurisdiction: cloudflare.F("r2_jurisdiction"), - StorageType: cloudflare.F(r2.ProviderR2), - }), }), }), Summarization: cloudflare.F(true), @@ -339,7 +332,7 @@ func TestInstanceChatCompletionsWithOptionalParams(t *testing.T) { ai_search.InstanceChatCompletionsParams{ AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"), Messages: cloudflare.F([]ai_search.InstanceChatCompletionsParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.InstanceChatCompletionsParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.InstanceChatCompletionsParamsMessagesRoleSystem), }}), AISearchOptions: cloudflare.F(ai_search.InstanceChatCompletionsParamsAISearchOptions{ @@ -469,7 +462,7 @@ func TestInstanceSearchWithOptionalParams(t *testing.T) { }), }), Messages: cloudflare.F([]ai_search.InstanceSearchParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.InstanceSearchParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.InstanceSearchParamsMessagesRoleSystem), }}), Query: cloudflare.F("x"), diff --git a/ai_search/namespace.go b/ai_search/namespace.go index 6da135435b7..37df8c09e0d 100644 --- a/ai_search/namespace.go +++ b/ai_search/namespace.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "reflect" "slices" "time" @@ -17,6 +18,8 @@ import ( "github.com/cloudflare/cloudflare-go/v7/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v7/option" "github.com/cloudflare/cloudflare-go/v7/packages/pagination" + "github.com/cloudflare/cloudflare-go/v7/shared" + "github.com/tidwall/gjson" ) // NamespaceService contains methods and other services that help with interacting @@ -164,7 +167,8 @@ func (r *NamespaceService) Read(ctx context.Context, name string, query Namespac return res, nil } -// Multi-Instance Search +// Performs a semantic search query against multiple AI Search instances in +// parallel, merging the retrieved results into a single ranked response. func (r *NamespaceService) Search(ctx context.Context, name string, params NamespaceSearchParams, opts ...option.RequestOption) (res *NamespaceSearchResponse, err error) { var env NamespaceSearchResponseEnvelope opts = slices.Concat(r.Options, opts) @@ -321,10 +325,10 @@ func (r namespaceChatCompletionsResponseChoiceJSON) RawJSON() string { } type NamespaceChatCompletionsResponseChoicesMessage struct { - Content string `json:"content" api:"required,nullable"` - Role NamespaceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-" api:"extrafields"` - JSON namespaceChatCompletionsResponseChoicesMessageJSON `json:"-"` + Content NamespaceChatCompletionsResponseChoicesMessageContentUnion `json:"content" api:"required,nullable"` + Role NamespaceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-" api:"extrafields"` + JSON namespaceChatCompletionsResponseChoicesMessageJSON `json:"-"` } // namespaceChatCompletionsResponseChoicesMessageJSON contains the JSON metadata @@ -344,6 +348,155 @@ func (r namespaceChatCompletionsResponseChoicesMessageJSON) RawJSON() string { return r.raw } +// Union satisfied by [shared.UnionString] or +// [NamespaceChatCompletionsResponseChoicesMessageContentArray]. +type NamespaceChatCompletionsResponseChoicesMessageContentUnion interface { + ImplementsNamespaceChatCompletionsResponseChoicesMessageContentUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceChatCompletionsResponseChoicesMessageContentUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceChatCompletionsResponseChoicesMessageContentArray{}), + }, + ) +} + +type NamespaceChatCompletionsResponseChoicesMessageContentArray []NamespaceChatCompletionsResponseChoicesMessageContentArrayItem + +func (r NamespaceChatCompletionsResponseChoicesMessageContentArray) ImplementsNamespaceChatCompletionsResponseChoicesMessageContentUnion() { +} + +type NamespaceChatCompletionsResponseChoicesMessageContentArrayItem struct { + Type NamespaceChatCompletionsResponseChoicesMessageContentArrayType `json:"type" api:"required"` + // This field can have the runtime type of + // [NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectImageURL]. + ImageURL interface{} `json:"image_url"` + Text string `json:"text"` + JSON namespaceChatCompletionsResponseChoicesMessageContentArrayItemJSON `json:"-"` + union NamespaceChatCompletionsResponseChoicesMessageContentArrayUnionItem +} + +// namespaceChatCompletionsResponseChoicesMessageContentArrayItemJSON contains the +// JSON metadata for the struct +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayItem] +type namespaceChatCompletionsResponseChoicesMessageContentArrayItemJSON struct { + Type apijson.Field + ImageURL apijson.Field + Text apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r namespaceChatCompletionsResponseChoicesMessageContentArrayItemJSON) RawJSON() string { + return r.raw +} + +func (r *NamespaceChatCompletionsResponseChoicesMessageContentArrayItem) UnmarshalJSON(data []byte) (err error) { + *r = NamespaceChatCompletionsResponseChoicesMessageContentArrayItem{} + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +// AsUnion returns a +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayUnionItem] interface +// which you can cast to the specific types for more type safety. +// +// Possible runtime types of the union are +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayObject], +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayObject]. +func (r NamespaceChatCompletionsResponseChoicesMessageContentArrayItem) AsUnion() NamespaceChatCompletionsResponseChoicesMessageContentArrayUnionItem { + return r.union +} + +// Union satisfied by +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayObject] or +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayObject]. +type NamespaceChatCompletionsResponseChoicesMessageContentArrayUnionItem interface { + implementsNamespaceChatCompletionsResponseChoicesMessageContentArrayItem() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceChatCompletionsResponseChoicesMessageContentArrayUnionItem)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + ) +} + +type NamespaceChatCompletionsResponseChoicesMessageContentArrayObject struct { + Text string `json:"text" api:"required"` + Type NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectType `json:"type" api:"required"` + JSON namespaceChatCompletionsResponseChoicesMessageContentArrayObjectJSON `json:"-"` +} + +// namespaceChatCompletionsResponseChoicesMessageContentArrayObjectJSON contains +// the JSON metadata for the struct +// [NamespaceChatCompletionsResponseChoicesMessageContentArrayObject] +type namespaceChatCompletionsResponseChoicesMessageContentArrayObjectJSON struct { + Text apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceChatCompletionsResponseChoicesMessageContentArrayObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceChatCompletionsResponseChoicesMessageContentArrayObjectJSON) RawJSON() string { + return r.raw +} + +func (r NamespaceChatCompletionsResponseChoicesMessageContentArrayObject) implementsNamespaceChatCompletionsResponseChoicesMessageContentArrayItem() { +} + +type NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectType string + +const ( + NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectType = "text" +) + +func (r NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceChatCompletionsResponseChoicesMessageContentArrayType string + +const ( + NamespaceChatCompletionsResponseChoicesMessageContentArrayTypeText NamespaceChatCompletionsResponseChoicesMessageContentArrayType = "text" + NamespaceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL NamespaceChatCompletionsResponseChoicesMessageContentArrayType = "image_url" +) + +func (r NamespaceChatCompletionsResponseChoicesMessageContentArrayType) IsKnown() bool { + switch r { + case NamespaceChatCompletionsResponseChoicesMessageContentArrayTypeText, NamespaceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceChatCompletionsResponseChoicesMessageRole string const ( @@ -516,18 +669,20 @@ func (r namespaceReadResponseJSON) RawJSON() string { } type NamespaceSearchResponse struct { - Chunks []NamespaceSearchResponseChunk `json:"chunks" api:"required"` - SearchQuery string `json:"search_query" api:"required"` - Errors []NamespaceSearchResponseError `json:"errors"` - JSON namespaceSearchResponseJSON `json:"-"` + Chunks []NamespaceSearchResponseChunk `json:"chunks" api:"required"` + QueryKind NamespaceSearchResponseQueryKind `json:"query_kind" api:"required"` + Errors []NamespaceSearchResponseError `json:"errors"` + SearchQuery string `json:"search_query"` + JSON namespaceSearchResponseJSON `json:"-"` } // namespaceSearchResponseJSON contains the JSON metadata for the struct // [NamespaceSearchResponse] type namespaceSearchResponseJSON struct { Chunks apijson.Field - SearchQuery apijson.Field + QueryKind apijson.Field Errors apijson.Field + SearchQuery apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -644,6 +799,22 @@ func (r NamespaceSearchResponseChunksScoringDetailsFusionMethod) IsKnown() bool return false } +type NamespaceSearchResponseQueryKind string + +const ( + NamespaceSearchResponseQueryKindText NamespaceSearchResponseQueryKind = "text" + NamespaceSearchResponseQueryKindImage NamespaceSearchResponseQueryKind = "image" + NamespaceSearchResponseQueryKindMultimodal NamespaceSearchResponseQueryKind = "multimodal" +) + +func (r NamespaceSearchResponseQueryKind) IsKnown() bool { + switch r { + case NamespaceSearchResponseQueryKindText, NamespaceSearchResponseQueryKindImage, NamespaceSearchResponseQueryKindMultimodal: + return true + } + return false +} + type NamespaceSearchResponseError struct { InstanceID string `json:"instance_id" api:"required"` Message string `json:"message" api:"required"` @@ -1063,15 +1234,88 @@ func (r NamespaceChatCompletionsParamsAISearchOptionsRetrievalRetrievalType) IsK } type NamespaceChatCompletionsParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[NamespaceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[NamespaceChatCompletionsParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[NamespaceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r NamespaceChatCompletionsParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.NamespaceChatCompletionsParamsMessagesContentArray]. +type NamespaceChatCompletionsParamsMessagesContentUnion interface { + ImplementsNamespaceChatCompletionsParamsMessagesContentUnion() +} + +type NamespaceChatCompletionsParamsMessagesContentArray []NamespaceChatCompletionsParamsMessagesContentArrayItemUnion + +func (r NamespaceChatCompletionsParamsMessagesContentArray) ImplementsNamespaceChatCompletionsParamsMessagesContentUnion() { +} + +type NamespaceChatCompletionsParamsMessagesContentArrayItem struct { + Type param.Field[NamespaceChatCompletionsParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r NamespaceChatCompletionsParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceChatCompletionsParamsMessagesContentArrayItem) implementsNamespaceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by +// [ai_search.NamespaceChatCompletionsParamsMessagesContentArrayObject], +// [ai_search.NamespaceChatCompletionsParamsMessagesContentArrayObject], +// [NamespaceChatCompletionsParamsMessagesContentArrayItem]. +type NamespaceChatCompletionsParamsMessagesContentArrayItemUnion interface { + implementsNamespaceChatCompletionsParamsMessagesContentArrayItemUnion() +} + +type NamespaceChatCompletionsParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[NamespaceChatCompletionsParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r NamespaceChatCompletionsParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceChatCompletionsParamsMessagesContentArrayObject) implementsNamespaceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +type NamespaceChatCompletionsParamsMessagesContentArrayObjectType string + +const ( + NamespaceChatCompletionsParamsMessagesContentArrayObjectTypeText NamespaceChatCompletionsParamsMessagesContentArrayObjectType = "text" +) + +func (r NamespaceChatCompletionsParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceChatCompletionsParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceChatCompletionsParamsMessagesContentArrayType string + +const ( + NamespaceChatCompletionsParamsMessagesContentArrayTypeText NamespaceChatCompletionsParamsMessagesContentArrayType = "text" + NamespaceChatCompletionsParamsMessagesContentArrayTypeImageURL NamespaceChatCompletionsParamsMessagesContentArrayType = "image_url" +) + +func (r NamespaceChatCompletionsParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case NamespaceChatCompletionsParamsMessagesContentArrayTypeText, NamespaceChatCompletionsParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceChatCompletionsParamsMessagesRole string const ( @@ -1177,7 +1421,12 @@ func (r NamespaceReadResponseEnvelopeSuccess) IsKnown() bool { type NamespaceSearchParams struct { AccountID param.Field[string] `path:"account_id" api:"required"` AISearchOptions param.Field[NamespaceSearchParamsAISearchOptions] `json:"ai_search_options" api:"required"` - Messages param.Field[[]NamespaceSearchParamsMessage] `json:"messages"` + // OpenAI-compatible message array. For multimodal queries, set the last user + // message's `content` to an array of typed parts: + // `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image + // inputs require the RAG's embedding_model to declare 'image' in + // supported_modalities. + Messages param.Field[[]NamespaceSearchParamsMessage] `json:"messages"` // A simple text query string. Alternative to 'messages' — provide either this or // 'messages', not both. Query param.Field[string] `json:"query"` @@ -1416,15 +1665,87 @@ func (r NamespaceSearchParamsAISearchOptionsRetrievalRetrievalType) IsKnown() bo } type NamespaceSearchParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[NamespaceSearchParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[NamespaceSearchParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[NamespaceSearchParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r NamespaceSearchParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.NamespaceSearchParamsMessagesContentArray]. +type NamespaceSearchParamsMessagesContentUnion interface { + ImplementsNamespaceSearchParamsMessagesContentUnion() +} + +type NamespaceSearchParamsMessagesContentArray []NamespaceSearchParamsMessagesContentArrayItemUnion + +func (r NamespaceSearchParamsMessagesContentArray) ImplementsNamespaceSearchParamsMessagesContentUnion() { +} + +type NamespaceSearchParamsMessagesContentArrayItem struct { + Type param.Field[NamespaceSearchParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r NamespaceSearchParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceSearchParamsMessagesContentArrayItem) implementsNamespaceSearchParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by [ai_search.NamespaceSearchParamsMessagesContentArrayObject], +// [ai_search.NamespaceSearchParamsMessagesContentArrayObject], +// [NamespaceSearchParamsMessagesContentArrayItem]. +type NamespaceSearchParamsMessagesContentArrayItemUnion interface { + implementsNamespaceSearchParamsMessagesContentArrayItemUnion() +} + +type NamespaceSearchParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[NamespaceSearchParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r NamespaceSearchParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceSearchParamsMessagesContentArrayObject) implementsNamespaceSearchParamsMessagesContentArrayItemUnion() { +} + +type NamespaceSearchParamsMessagesContentArrayObjectType string + +const ( + NamespaceSearchParamsMessagesContentArrayObjectTypeText NamespaceSearchParamsMessagesContentArrayObjectType = "text" +) + +func (r NamespaceSearchParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceSearchParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceSearchParamsMessagesContentArrayType string + +const ( + NamespaceSearchParamsMessagesContentArrayTypeText NamespaceSearchParamsMessagesContentArrayType = "text" + NamespaceSearchParamsMessagesContentArrayTypeImageURL NamespaceSearchParamsMessagesContentArrayType = "image_url" +) + +func (r NamespaceSearchParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case NamespaceSearchParamsMessagesContentArrayTypeText, NamespaceSearchParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceSearchParamsMessagesRole string const ( diff --git a/ai_search/namespace_test.go b/ai_search/namespace_test.go index 0436037c349..f7e75f06f61 100644 --- a/ai_search/namespace_test.go +++ b/ai_search/namespace_test.go @@ -12,6 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v7/ai_search" "github.com/cloudflare/cloudflare-go/v7/internal/testutil" "github.com/cloudflare/cloudflare-go/v7/option" + "github.com/cloudflare/cloudflare-go/v7/shared" ) func TestNamespaceNewWithOptionalParams(t *testing.T) { @@ -185,7 +186,7 @@ func TestNamespaceChatCompletionsWithOptionalParams(t *testing.T) { }), }), Messages: cloudflare.F([]ai_search.NamespaceChatCompletionsParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.NamespaceChatCompletionsParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.NamespaceChatCompletionsParamsMessagesRoleSystem), }}), Model: cloudflare.F(ai_search.NamespaceChatCompletionsParamsModelCfMetaLlama3_3_70bInstructFp8Fast), @@ -284,7 +285,7 @@ func TestNamespaceSearchWithOptionalParams(t *testing.T) { }), }), Messages: cloudflare.F([]ai_search.NamespaceSearchParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.NamespaceSearchParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.NamespaceSearchParamsMessagesRoleSystem), }}), Query: cloudflare.F("x"), diff --git a/ai_search/namespaceinstance.go b/ai_search/namespaceinstance.go index 6a1905f5ab8..6092df3829c 100644 --- a/ai_search/namespaceinstance.go +++ b/ai_search/namespaceinstance.go @@ -8,6 +8,7 @@ import ( "fmt" "net/http" "net/url" + "reflect" "slices" "time" @@ -17,7 +18,8 @@ import ( "github.com/cloudflare/cloudflare-go/v7/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v7/option" "github.com/cloudflare/cloudflare-go/v7/packages/pagination" - "github.com/cloudflare/cloudflare-go/v7/r2" + "github.com/cloudflare/cloudflare-go/v7/shared" + "github.com/tidwall/gjson" ) // NamespaceInstanceService contains methods and other services that help with @@ -480,6 +482,7 @@ type NamespaceInstanceNewResponseEmbeddingModel string const ( NamespaceInstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceNewResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceNewResponseEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceNewResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeM3 NamespaceInstanceNewResponseEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceNewResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceNewResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -492,7 +495,7 @@ const ( func (r NamespaceInstanceNewResponseEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceNewResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceNewResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceNewResponseEmbeddingModelEmpty: + case NamespaceInstanceNewResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceNewResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceNewResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceNewResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceNewResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceNewResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceNewResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceNewResponseEmbeddingModelEmpty: return true } return false @@ -610,11 +613,16 @@ func (r namespaceInstanceNewResponseMetadataJSON) RawJSON() string { type NamespaceInstanceNewResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint NamespaceInstanceNewResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp NamespaceInstanceNewResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit NamespaceInstanceNewResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint NamespaceInstanceNewResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON namespaceInstanceNewResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp NamespaceInstanceNewResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit NamespaceInstanceNewResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint NamespaceInstanceNewResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON namespaceInstanceNewResponsePublicEndpointParamsJSON `json:"-"` } // namespaceInstanceNewResponsePublicEndpointParamsJSON contains the JSON metadata @@ -622,6 +630,7 @@ type NamespaceInstanceNewResponsePublicEndpointParams struct { type namespaceInstanceNewResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -945,7 +954,6 @@ func (r namespaceInstanceNewResponseSourceParamsJSON) RawJSON() string { type NamespaceInstanceNewResponseSourceParamsWebCrawler struct { ParseOptions NamespaceInstanceNewResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions NamespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON namespaceInstanceNewResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -954,7 +962,6 @@ type NamespaceInstanceNewResponseSourceParamsWebCrawler struct { type namespaceInstanceNewResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1039,44 +1046,17 @@ type NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType string const ( NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceNewResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceNewResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON namespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// namespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON contains the -// JSON metadata for the struct -// [NamespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptions] -type namespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceInstanceNewResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceNewResponseSyncInterval float64 @@ -1353,6 +1333,7 @@ type NamespaceInstanceUpdateResponseEmbeddingModel string const ( NamespaceInstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceUpdateResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceUpdateResponseEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceUpdateResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeM3 NamespaceInstanceUpdateResponseEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceUpdateResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceUpdateResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -1365,7 +1346,7 @@ const ( func (r NamespaceInstanceUpdateResponseEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceUpdateResponseEmbeddingModelEmpty: + case NamespaceInstanceUpdateResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceUpdateResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceUpdateResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceUpdateResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceUpdateResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceUpdateResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceUpdateResponseEmbeddingModelEmpty: return true } return false @@ -1483,11 +1464,16 @@ func (r namespaceInstanceUpdateResponseMetadataJSON) RawJSON() string { type NamespaceInstanceUpdateResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint NamespaceInstanceUpdateResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp NamespaceInstanceUpdateResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit NamespaceInstanceUpdateResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint NamespaceInstanceUpdateResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON namespaceInstanceUpdateResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp NamespaceInstanceUpdateResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit NamespaceInstanceUpdateResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint NamespaceInstanceUpdateResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON namespaceInstanceUpdateResponsePublicEndpointParamsJSON `json:"-"` } // namespaceInstanceUpdateResponsePublicEndpointParamsJSON contains the JSON @@ -1495,6 +1481,7 @@ type NamespaceInstanceUpdateResponsePublicEndpointParams struct { type namespaceInstanceUpdateResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -1818,7 +1805,6 @@ func (r namespaceInstanceUpdateResponseSourceParamsJSON) RawJSON() string { type NamespaceInstanceUpdateResponseSourceParamsWebCrawler struct { ParseOptions NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions NamespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON namespaceInstanceUpdateResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -1827,7 +1813,6 @@ type NamespaceInstanceUpdateResponseSourceParamsWebCrawler struct { type namespaceInstanceUpdateResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -1912,44 +1897,17 @@ type NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType string const ( NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceUpdateResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON namespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// namespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON contains -// the JSON metadata for the struct -// [NamespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptions] -type namespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceInstanceUpdateResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceUpdateResponseSyncInterval float64 @@ -2226,6 +2184,7 @@ type NamespaceInstanceListResponseEmbeddingModel string const ( NamespaceInstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceListResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceListResponseEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceListResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeM3 NamespaceInstanceListResponseEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceListResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceListResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -2238,7 +2197,7 @@ const ( func (r NamespaceInstanceListResponseEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceListResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceListResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceListResponseEmbeddingModelEmpty: + case NamespaceInstanceListResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceListResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceListResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceListResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceListResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceListResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceListResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceListResponseEmbeddingModelEmpty: return true } return false @@ -2356,11 +2315,16 @@ func (r namespaceInstanceListResponseMetadataJSON) RawJSON() string { type NamespaceInstanceListResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint NamespaceInstanceListResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp NamespaceInstanceListResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit NamespaceInstanceListResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint NamespaceInstanceListResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON namespaceInstanceListResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp NamespaceInstanceListResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit NamespaceInstanceListResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint NamespaceInstanceListResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON namespaceInstanceListResponsePublicEndpointParamsJSON `json:"-"` } // namespaceInstanceListResponsePublicEndpointParamsJSON contains the JSON metadata @@ -2368,6 +2332,7 @@ type NamespaceInstanceListResponsePublicEndpointParams struct { type namespaceInstanceListResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -2691,7 +2656,6 @@ func (r namespaceInstanceListResponseSourceParamsJSON) RawJSON() string { type NamespaceInstanceListResponseSourceParamsWebCrawler struct { ParseOptions NamespaceInstanceListResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType NamespaceInstanceListResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions NamespaceInstanceListResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON namespaceInstanceListResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -2700,7 +2664,6 @@ type NamespaceInstanceListResponseSourceParamsWebCrawler struct { type namespaceInstanceListResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -2785,44 +2748,17 @@ type NamespaceInstanceListResponseSourceParamsWebCrawlerParseType string const ( NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceListResponseSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceListResponseSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceListResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceListResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceListResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceListResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON namespaceInstanceListResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// namespaceInstanceListResponseSourceParamsWebCrawlerStoreOptionsJSON contains the -// JSON metadata for the struct -// [NamespaceInstanceListResponseSourceParamsWebCrawlerStoreOptions] -type namespaceInstanceListResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceInstanceListResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceInstanceListResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceListResponseSyncInterval float64 @@ -3099,6 +3035,7 @@ type NamespaceInstanceDeleteResponseEmbeddingModel string const ( NamespaceInstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceDeleteResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceDeleteResponseEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceDeleteResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeM3 NamespaceInstanceDeleteResponseEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceDeleteResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceDeleteResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -3111,7 +3048,7 @@ const ( func (r NamespaceInstanceDeleteResponseEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceDeleteResponseEmbeddingModelEmpty: + case NamespaceInstanceDeleteResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceDeleteResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceDeleteResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceDeleteResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceDeleteResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceDeleteResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceDeleteResponseEmbeddingModelEmpty: return true } return false @@ -3229,11 +3166,16 @@ func (r namespaceInstanceDeleteResponseMetadataJSON) RawJSON() string { type NamespaceInstanceDeleteResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint NamespaceInstanceDeleteResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp NamespaceInstanceDeleteResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit NamespaceInstanceDeleteResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint NamespaceInstanceDeleteResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON namespaceInstanceDeleteResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp NamespaceInstanceDeleteResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit NamespaceInstanceDeleteResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint NamespaceInstanceDeleteResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON namespaceInstanceDeleteResponsePublicEndpointParamsJSON `json:"-"` } // namespaceInstanceDeleteResponsePublicEndpointParamsJSON contains the JSON @@ -3241,6 +3183,7 @@ type NamespaceInstanceDeleteResponsePublicEndpointParams struct { type namespaceInstanceDeleteResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -3564,7 +3507,6 @@ func (r namespaceInstanceDeleteResponseSourceParamsJSON) RawJSON() string { type NamespaceInstanceDeleteResponseSourceParamsWebCrawler struct { ParseOptions NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions NamespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON namespaceInstanceDeleteResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -3573,7 +3515,6 @@ type NamespaceInstanceDeleteResponseSourceParamsWebCrawler struct { type namespaceInstanceDeleteResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -3658,44 +3599,17 @@ type NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType string const ( NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceDeleteResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON namespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// namespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON contains -// the JSON metadata for the struct -// [NamespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptions] -type namespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceInstanceDeleteResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceDeleteResponseSyncInterval float64 @@ -3788,10 +3702,10 @@ func (r namespaceInstanceChatCompletionsResponseChoiceJSON) RawJSON() string { } type NamespaceInstanceChatCompletionsResponseChoicesMessage struct { - Content string `json:"content" api:"required,nullable"` - Role NamespaceInstanceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-" api:"extrafields"` - JSON namespaceInstanceChatCompletionsResponseChoicesMessageJSON `json:"-"` + Content NamespaceInstanceChatCompletionsResponseChoicesMessageContentUnion `json:"content" api:"required,nullable"` + Role NamespaceInstanceChatCompletionsResponseChoicesMessageRole `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-" api:"extrafields"` + JSON namespaceInstanceChatCompletionsResponseChoicesMessageJSON `json:"-"` } // namespaceInstanceChatCompletionsResponseChoicesMessageJSON contains the JSON @@ -3811,6 +3725,155 @@ func (r namespaceInstanceChatCompletionsResponseChoicesMessageJSON) RawJSON() st return r.raw } +// Union satisfied by [shared.UnionString] or +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArray]. +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentUnion interface { + ImplementsNamespaceInstanceChatCompletionsResponseChoicesMessageContentUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceInstanceChatCompletionsResponseChoicesMessageContentUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceInstanceChatCompletionsResponseChoicesMessageContentArray{}), + }, + ) +} + +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArray []NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem + +func (r NamespaceInstanceChatCompletionsResponseChoicesMessageContentArray) ImplementsNamespaceInstanceChatCompletionsResponseChoicesMessageContentUnion() { +} + +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem struct { + Type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayType `json:"type" api:"required"` + // This field can have the runtime type of + // [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectImageURL]. + ImageURL interface{} `json:"image_url"` + Text string `json:"text"` + JSON namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItemJSON `json:"-"` + union NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem +} + +// namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItemJSON +// contains the JSON metadata for the struct +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem] +type namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItemJSON struct { + Type apijson.Field + ImageURL apijson.Field + Text apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItemJSON) RawJSON() string { + return r.raw +} + +func (r *NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem) UnmarshalJSON(data []byte) (err error) { + *r = NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem{} + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) +} + +// AsUnion returns a +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem] +// interface which you can cast to the specific types for more type safety. +// +// Possible runtime types of the union are +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject], +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject]. +func (r NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem) AsUnion() NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem { + return r.union +} + +// Union satisfied by +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject] or +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject]. +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem interface { + implementsNamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayUnionItem)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject{}), + }, + ) +} + +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject struct { + Text string `json:"text" api:"required"` + Type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectType `json:"type" api:"required"` + JSON namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON `json:"-"` +} + +// namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON +// contains the JSON metadata for the struct +// [NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject] +type namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON struct { + Text apijson.Field + Type apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r namespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectJSON) RawJSON() string { + return r.raw +} + +func (r NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObject) implementsNamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayItem() { +} + +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectType string + +const ( + NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectType = "text" +) + +func (r NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayType string + +const ( + NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayTypeText NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayType = "text" + NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayType = "image_url" +) + +func (r NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayType) IsKnown() bool { + switch r { + case NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayTypeText, NamespaceInstanceChatCompletionsResponseChoicesMessageContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceInstanceChatCompletionsResponseChoicesMessageRole string const ( @@ -4170,6 +4233,7 @@ type NamespaceInstanceReadResponseEmbeddingModel string const ( NamespaceInstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceReadResponseEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceReadResponseEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceReadResponseEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeM3 NamespaceInstanceReadResponseEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceReadResponseEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceReadResponseEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -4182,7 +4246,7 @@ const ( func (r NamespaceInstanceReadResponseEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceReadResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceReadResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceReadResponseEmbeddingModelEmpty: + case NamespaceInstanceReadResponseEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceReadResponseEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeM3, NamespaceInstanceReadResponseEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceReadResponseEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceReadResponseEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceReadResponseEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceReadResponseEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceReadResponseEmbeddingModelEmpty: return true } return false @@ -4300,11 +4364,16 @@ func (r namespaceInstanceReadResponseMetadataJSON) RawJSON() string { type NamespaceInstanceReadResponsePublicEndpointParams struct { AuthorizedHosts []string `json:"authorized_hosts"` ChatCompletionsEndpoint NamespaceInstanceReadResponsePublicEndpointParamsChatCompletionsEndpoint `json:"chat_completions_endpoint"` - Enabled bool `json:"enabled"` - Mcp NamespaceInstanceReadResponsePublicEndpointParamsMcp `json:"mcp"` - RateLimit NamespaceInstanceReadResponsePublicEndpointParamsRateLimit `json:"rate_limit"` - SearchEndpoint NamespaceInstanceReadResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` - JSON namespaceInstanceReadResponsePublicEndpointParamsJSON `json:"-"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains []string `json:"custom_domains" api:"nullable"` + Enabled bool `json:"enabled"` + Mcp NamespaceInstanceReadResponsePublicEndpointParamsMcp `json:"mcp"` + RateLimit NamespaceInstanceReadResponsePublicEndpointParamsRateLimit `json:"rate_limit"` + SearchEndpoint NamespaceInstanceReadResponsePublicEndpointParamsSearchEndpoint `json:"search_endpoint"` + JSON namespaceInstanceReadResponsePublicEndpointParamsJSON `json:"-"` } // namespaceInstanceReadResponsePublicEndpointParamsJSON contains the JSON metadata @@ -4312,6 +4381,7 @@ type NamespaceInstanceReadResponsePublicEndpointParams struct { type namespaceInstanceReadResponsePublicEndpointParamsJSON struct { AuthorizedHosts apijson.Field ChatCompletionsEndpoint apijson.Field + CustomDomains apijson.Field Enabled apijson.Field Mcp apijson.Field RateLimit apijson.Field @@ -4635,7 +4705,6 @@ func (r namespaceInstanceReadResponseSourceParamsJSON) RawJSON() string { type NamespaceInstanceReadResponseSourceParamsWebCrawler struct { ParseOptions NamespaceInstanceReadResponseSourceParamsWebCrawlerParseOptions `json:"parse_options"` ParseType NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType `json:"parse_type"` - StoreOptions NamespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptions `json:"store_options"` JSON namespaceInstanceReadResponseSourceParamsWebCrawlerJSON `json:"-"` } @@ -4644,7 +4713,6 @@ type NamespaceInstanceReadResponseSourceParamsWebCrawler struct { type namespaceInstanceReadResponseSourceParamsWebCrawlerJSON struct { ParseOptions apijson.Field ParseType apijson.Field - StoreOptions apijson.Field raw string ExtraFields map[string]apijson.Field } @@ -4729,44 +4797,17 @@ type NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType string const ( NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceReadResponseSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceReadResponseSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptions struct { - StorageID string `json:"storage_id" api:"required"` - R2Jurisdiction string `json:"r2_jurisdiction"` - StorageType r2.Provider `json:"storage_type"` - JSON namespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON `json:"-"` -} - -// namespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON contains the -// JSON metadata for the struct -// [NamespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptions] -type namespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON struct { - StorageID apijson.Field - R2Jurisdiction apijson.Field - StorageType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *NamespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptions) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r namespaceInstanceReadResponseSourceParamsWebCrawlerStoreOptionsJSON) RawJSON() string { - return r.raw -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceReadResponseSyncInterval float64 @@ -4806,15 +4847,17 @@ func (r NamespaceInstanceReadResponseType) IsKnown() bool { } type NamespaceInstanceSearchResponse struct { - Chunks []NamespaceInstanceSearchResponseChunk `json:"chunks" api:"required"` - SearchQuery string `json:"search_query" api:"required"` - JSON namespaceInstanceSearchResponseJSON `json:"-"` + Chunks []NamespaceInstanceSearchResponseChunk `json:"chunks" api:"required"` + QueryKind NamespaceInstanceSearchResponseQueryKind `json:"query_kind" api:"required"` + SearchQuery string `json:"search_query"` + JSON namespaceInstanceSearchResponseJSON `json:"-"` } // namespaceInstanceSearchResponseJSON contains the JSON metadata for the struct // [NamespaceInstanceSearchResponse] type namespaceInstanceSearchResponseJSON struct { Chunks apijson.Field + QueryKind apijson.Field SearchQuery apijson.Field raw string ExtraFields map[string]apijson.Field @@ -4930,6 +4973,22 @@ func (r NamespaceInstanceSearchResponseChunksScoringDetailsFusionMethod) IsKnown return false } +type NamespaceInstanceSearchResponseQueryKind string + +const ( + NamespaceInstanceSearchResponseQueryKindText NamespaceInstanceSearchResponseQueryKind = "text" + NamespaceInstanceSearchResponseQueryKindImage NamespaceInstanceSearchResponseQueryKind = "image" + NamespaceInstanceSearchResponseQueryKindMultimodal NamespaceInstanceSearchResponseQueryKind = "multimodal" +) + +func (r NamespaceInstanceSearchResponseQueryKind) IsKnown() bool { + switch r { + case NamespaceInstanceSearchResponseQueryKindText, NamespaceInstanceSearchResponseQueryKindImage, NamespaceInstanceSearchResponseQueryKindMultimodal: + return true + } + return false +} + type NamespaceInstanceStatsResponse struct { Completed int64 `json:"completed"` // True when status counts are unavailable (e.g. legacy stats query exceeded D1 @@ -5212,6 +5271,7 @@ type NamespaceInstanceNewParamsEmbeddingModel string const ( NamespaceInstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceNewParamsEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceNewParamsEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceNewParamsEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeM3 NamespaceInstanceNewParamsEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceNewParamsEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceNewParamsEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -5224,7 +5284,7 @@ const ( func (r NamespaceInstanceNewParamsEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeM3, NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceNewParamsEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceNewParamsEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceNewParamsEmbeddingModelEmpty: + case NamespaceInstanceNewParamsEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceNewParamsEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeM3, NamespaceInstanceNewParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceNewParamsEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceNewParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceNewParamsEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceNewParamsEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceNewParamsEmbeddingModelEmpty: return true } return false @@ -5301,10 +5361,15 @@ func (r NamespaceInstanceNewParamsMetadata) MarshalJSON() (data []byte, err erro type NamespaceInstanceNewParamsPublicEndpointParams struct { AuthorizedHosts param.Field[[]string] `json:"authorized_hosts"` ChatCompletionsEndpoint param.Field[NamespaceInstanceNewParamsPublicEndpointParamsChatCompletionsEndpoint] `json:"chat_completions_endpoint"` - Enabled param.Field[bool] `json:"enabled"` - Mcp param.Field[NamespaceInstanceNewParamsPublicEndpointParamsMcp] `json:"mcp"` - RateLimit param.Field[NamespaceInstanceNewParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` - SearchEndpoint param.Field[NamespaceInstanceNewParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains param.Field[[]string] `json:"custom_domains"` + Enabled param.Field[bool] `json:"enabled"` + Mcp param.Field[NamespaceInstanceNewParamsPublicEndpointParamsMcp] `json:"mcp"` + RateLimit param.Field[NamespaceInstanceNewParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` + SearchEndpoint param.Field[NamespaceInstanceNewParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` } func (r NamespaceInstanceNewParamsPublicEndpointParams) MarshalJSON() (data []byte, err error) { @@ -5515,7 +5580,6 @@ func (r NamespaceInstanceNewParamsSourceParams) MarshalJSON() (data []byte, err type NamespaceInstanceNewParamsSourceParamsWebCrawler struct { ParseOptions param.Field[NamespaceInstanceNewParamsSourceParamsWebCrawlerParseOptions] `json:"parse_options"` ParseType param.Field[NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType] `json:"parse_type"` - StoreOptions param.Field[NamespaceInstanceNewParamsSourceParamsWebCrawlerStoreOptions] `json:"store_options"` } func (r NamespaceInstanceNewParamsSourceParamsWebCrawler) MarshalJSON() (data []byte, err error) { @@ -5561,28 +5625,17 @@ type NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType string const ( NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceNewParamsSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceNewParamsSourceParamsWebCrawlerStoreOptions struct { - StorageID param.Field[string] `json:"storage_id" api:"required"` - R2Jurisdiction param.Field[string] `json:"r2_jurisdiction"` - StorageType param.Field[r2.Provider] `json:"storage_type"` -} - -func (r NamespaceInstanceNewParamsSourceParamsWebCrawlerStoreOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // Interval between automatic syncs, in seconds. Allowed values: 900 (15min), 1800 // (30min), 3600 (1h), 7200 (2h), 14400 (4h), 21600 (6h), 43200 (12h), 86400 (24h). type NamespaceInstanceNewParamsSyncInterval float64 @@ -5674,6 +5727,7 @@ type NamespaceInstanceUpdateParams struct { RewriteModel param.Field[NamespaceInstanceUpdateParamsRewriteModel] `json:"rewrite_model"` RewriteQuery param.Field[bool] `json:"rewrite_query"` ScoreThreshold param.Field[float64] `json:"score_threshold"` + Source param.Field[string] `json:"source"` SourceParams param.Field[NamespaceInstanceUpdateParamsSourceParams] `json:"source_params"` Summarization param.Field[bool] `json:"summarization"` SummarizationModel param.Field[NamespaceInstanceUpdateParamsSummarizationModel] `json:"summarization_model"` @@ -5806,6 +5860,7 @@ type NamespaceInstanceUpdateParamsEmbeddingModel string const ( NamespaceInstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b NamespaceInstanceUpdateParamsEmbeddingModel = "@cf/qwen/qwen3-embedding-0.6b" + NamespaceInstanceUpdateParamsEmbeddingModelCfQwenQwen3VlEmbedding2b NamespaceInstanceUpdateParamsEmbeddingModel = "@cf/qwen/qwen3-vl-embedding-2b" NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeM3 NamespaceInstanceUpdateParamsEmbeddingModel = "@cf/baai/bge-m3" NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5 NamespaceInstanceUpdateParamsEmbeddingModel = "@cf/baai/bge-large-en-v1.5" NamespaceInstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m NamespaceInstanceUpdateParamsEmbeddingModel = "@cf/google/embeddinggemma-300m" @@ -5818,7 +5873,7 @@ const ( func (r NamespaceInstanceUpdateParamsEmbeddingModel) IsKnown() bool { switch r { - case NamespaceInstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeM3, NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceUpdateParamsEmbeddingModelEmpty: + case NamespaceInstanceUpdateParamsEmbeddingModelCfQwenQwen3Embedding0_6b, NamespaceInstanceUpdateParamsEmbeddingModelCfQwenQwen3VlEmbedding2b, NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeM3, NamespaceInstanceUpdateParamsEmbeddingModelCfBaaiBgeLargeEnV1_5, NamespaceInstanceUpdateParamsEmbeddingModelCfGoogleEmbeddinggemma300m, NamespaceInstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding001, NamespaceInstanceUpdateParamsEmbeddingModelGoogleAIStudioGeminiEmbedding2Preview, NamespaceInstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Small, NamespaceInstanceUpdateParamsEmbeddingModelOpenAITextEmbedding3Large, NamespaceInstanceUpdateParamsEmbeddingModelEmpty: return true } return false @@ -5895,10 +5950,15 @@ func (r NamespaceInstanceUpdateParamsMetadata) MarshalJSON() (data []byte, err e type NamespaceInstanceUpdateParamsPublicEndpointParams struct { AuthorizedHosts param.Field[[]string] `json:"authorized_hosts"` ChatCompletionsEndpoint param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsChatCompletionsEndpoint] `json:"chat_completions_endpoint"` - Enabled param.Field[bool] `json:"enabled"` - Mcp param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsMcp] `json:"mcp"` - RateLimit param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` - SearchEndpoint param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` + // Custom domain hostnames that alias this public endpoint. GET and create + // responses return the current set; on update (PUT) this field is only echoed back + // when supplied in the request body, otherwise it is null (omit it to leave + // domains unchanged). + CustomDomains param.Field[[]string] `json:"custom_domains"` + Enabled param.Field[bool] `json:"enabled"` + Mcp param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsMcp] `json:"mcp"` + RateLimit param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsRateLimit] `json:"rate_limit"` + SearchEndpoint param.Field[NamespaceInstanceUpdateParamsPublicEndpointParamsSearchEndpoint] `json:"search_endpoint"` } func (r NamespaceInstanceUpdateParamsPublicEndpointParams) MarshalJSON() (data []byte, err error) { @@ -6109,7 +6169,6 @@ func (r NamespaceInstanceUpdateParamsSourceParams) MarshalJSON() (data []byte, e type NamespaceInstanceUpdateParamsSourceParamsWebCrawler struct { ParseOptions param.Field[NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseOptions] `json:"parse_options"` ParseType param.Field[NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType] `json:"parse_type"` - StoreOptions param.Field[NamespaceInstanceUpdateParamsSourceParamsWebCrawlerStoreOptions] `json:"store_options"` } func (r NamespaceInstanceUpdateParamsSourceParamsWebCrawler) MarshalJSON() (data []byte, err error) { @@ -6155,28 +6214,17 @@ type NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType string const ( NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType = "sitemap" - NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeFeedRss NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType = "feed-rss" NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType = "crawl" ) func (r NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseType) IsKnown() bool { switch r { - case NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeFeedRss, NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl: + case NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap, NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeCrawl: return true } return false } -type NamespaceInstanceUpdateParamsSourceParamsWebCrawlerStoreOptions struct { - StorageID param.Field[string] `json:"storage_id" api:"required"` - R2Jurisdiction param.Field[string] `json:"r2_jurisdiction"` - StorageType param.Field[r2.Provider] `json:"storage_type"` -} - -func (r NamespaceInstanceUpdateParamsSourceParamsWebCrawlerStoreOptions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type NamespaceInstanceUpdateParamsSummarizationModel string const ( @@ -6362,15 +6410,88 @@ func (r NamespaceInstanceChatCompletionsParams) MarshalJSON() (data []byte, err } type NamespaceInstanceChatCompletionsParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[NamespaceInstanceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[NamespaceInstanceChatCompletionsParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[NamespaceInstanceChatCompletionsParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r NamespaceInstanceChatCompletionsParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.NamespaceInstanceChatCompletionsParamsMessagesContentArray]. +type NamespaceInstanceChatCompletionsParamsMessagesContentUnion interface { + ImplementsNamespaceInstanceChatCompletionsParamsMessagesContentUnion() +} + +type NamespaceInstanceChatCompletionsParamsMessagesContentArray []NamespaceInstanceChatCompletionsParamsMessagesContentArrayItemUnion + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArray) ImplementsNamespaceInstanceChatCompletionsParamsMessagesContentUnion() { +} + +type NamespaceInstanceChatCompletionsParamsMessagesContentArrayItem struct { + Type param.Field[NamespaceInstanceChatCompletionsParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayItem) implementsNamespaceInstanceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by +// [ai_search.NamespaceInstanceChatCompletionsParamsMessagesContentArrayObject], +// [ai_search.NamespaceInstanceChatCompletionsParamsMessagesContentArrayObject], +// [NamespaceInstanceChatCompletionsParamsMessagesContentArrayItem]. +type NamespaceInstanceChatCompletionsParamsMessagesContentArrayItemUnion interface { + implementsNamespaceInstanceChatCompletionsParamsMessagesContentArrayItemUnion() +} + +type NamespaceInstanceChatCompletionsParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayObject) implementsNamespaceInstanceChatCompletionsParamsMessagesContentArrayItemUnion() { +} + +type NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectType string + +const ( + NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectTypeText NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectType = "text" +) + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceInstanceChatCompletionsParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceInstanceChatCompletionsParamsMessagesContentArrayType string + +const ( + NamespaceInstanceChatCompletionsParamsMessagesContentArrayTypeText NamespaceInstanceChatCompletionsParamsMessagesContentArrayType = "text" + NamespaceInstanceChatCompletionsParamsMessagesContentArrayTypeImageURL NamespaceInstanceChatCompletionsParamsMessagesContentArrayType = "image_url" +) + +func (r NamespaceInstanceChatCompletionsParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case NamespaceInstanceChatCompletionsParamsMessagesContentArrayTypeText, NamespaceInstanceChatCompletionsParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceInstanceChatCompletionsParamsMessagesRole string const ( @@ -6689,7 +6810,12 @@ func (r namespaceInstanceReadResponseEnvelopeJSON) RawJSON() string { type NamespaceInstanceSearchParams struct { AccountID param.Field[string] `path:"account_id" api:"required"` AISearchOptions param.Field[NamespaceInstanceSearchParamsAISearchOptions] `json:"ai_search_options"` - Messages param.Field[[]NamespaceInstanceSearchParamsMessage] `json:"messages"` + // OpenAI-compatible message array. For multimodal queries, set the last user + // message's `content` to an array of typed parts: + // `[{type:'text', text:'…'}, {type:'image_url', image_url:{url:'…'}}]`. Image + // inputs require the RAG's embedding_model to declare 'image' in + // supported_modalities. + Messages param.Field[[]NamespaceInstanceSearchParamsMessage] `json:"messages"` // A simple text query string. Alternative to 'messages' — provide either this or // 'messages', not both. Query param.Field[string] `json:"query"` @@ -6927,15 +7053,88 @@ func (r NamespaceInstanceSearchParamsAISearchOptionsRetrievalRetrievalType) IsKn } type NamespaceInstanceSearchParamsMessage struct { - Content param.Field[string] `json:"content" api:"required"` - Role param.Field[NamespaceInstanceSearchParamsMessagesRole] `json:"role" api:"required"` - ExtraFields map[string]interface{} `json:"-,extras"` + Content param.Field[NamespaceInstanceSearchParamsMessagesContentUnion] `json:"content" api:"required"` + Role param.Field[NamespaceInstanceSearchParamsMessagesRole] `json:"role" api:"required"` + ExtraFields map[string]interface{} `json:"-,extras"` } func (r NamespaceInstanceSearchParamsMessage) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +// Satisfied by [shared.UnionString], +// [ai_search.NamespaceInstanceSearchParamsMessagesContentArray]. +type NamespaceInstanceSearchParamsMessagesContentUnion interface { + ImplementsNamespaceInstanceSearchParamsMessagesContentUnion() +} + +type NamespaceInstanceSearchParamsMessagesContentArray []NamespaceInstanceSearchParamsMessagesContentArrayItemUnion + +func (r NamespaceInstanceSearchParamsMessagesContentArray) ImplementsNamespaceInstanceSearchParamsMessagesContentUnion() { +} + +type NamespaceInstanceSearchParamsMessagesContentArrayItem struct { + Type param.Field[NamespaceInstanceSearchParamsMessagesContentArrayType] `json:"type" api:"required"` + ImageURL param.Field[interface{}] `json:"image_url"` + Text param.Field[string] `json:"text"` +} + +func (r NamespaceInstanceSearchParamsMessagesContentArrayItem) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceInstanceSearchParamsMessagesContentArrayItem) implementsNamespaceInstanceSearchParamsMessagesContentArrayItemUnion() { +} + +// Satisfied by +// [ai_search.NamespaceInstanceSearchParamsMessagesContentArrayObject], +// [ai_search.NamespaceInstanceSearchParamsMessagesContentArrayObject], +// [NamespaceInstanceSearchParamsMessagesContentArrayItem]. +type NamespaceInstanceSearchParamsMessagesContentArrayItemUnion interface { + implementsNamespaceInstanceSearchParamsMessagesContentArrayItemUnion() +} + +type NamespaceInstanceSearchParamsMessagesContentArrayObject struct { + Text param.Field[string] `json:"text" api:"required"` + Type param.Field[NamespaceInstanceSearchParamsMessagesContentArrayObjectType] `json:"type" api:"required"` +} + +func (r NamespaceInstanceSearchParamsMessagesContentArrayObject) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r NamespaceInstanceSearchParamsMessagesContentArrayObject) implementsNamespaceInstanceSearchParamsMessagesContentArrayItemUnion() { +} + +type NamespaceInstanceSearchParamsMessagesContentArrayObjectType string + +const ( + NamespaceInstanceSearchParamsMessagesContentArrayObjectTypeText NamespaceInstanceSearchParamsMessagesContentArrayObjectType = "text" +) + +func (r NamespaceInstanceSearchParamsMessagesContentArrayObjectType) IsKnown() bool { + switch r { + case NamespaceInstanceSearchParamsMessagesContentArrayObjectTypeText: + return true + } + return false +} + +type NamespaceInstanceSearchParamsMessagesContentArrayType string + +const ( + NamespaceInstanceSearchParamsMessagesContentArrayTypeText NamespaceInstanceSearchParamsMessagesContentArrayType = "text" + NamespaceInstanceSearchParamsMessagesContentArrayTypeImageURL NamespaceInstanceSearchParamsMessagesContentArrayType = "image_url" +) + +func (r NamespaceInstanceSearchParamsMessagesContentArrayType) IsKnown() bool { + switch r { + case NamespaceInstanceSearchParamsMessagesContentArrayTypeText, NamespaceInstanceSearchParamsMessagesContentArrayTypeImageURL: + return true + } + return false +} + type NamespaceInstanceSearchParamsMessagesRole string const ( diff --git a/ai_search/namespaceinstance_test.go b/ai_search/namespaceinstance_test.go index 8d33e058fab..b2454685ca6 100644 --- a/ai_search/namespaceinstance_test.go +++ b/ai_search/namespaceinstance_test.go @@ -12,7 +12,7 @@ import ( "github.com/cloudflare/cloudflare-go/v7/ai_search" "github.com/cloudflare/cloudflare-go/v7/internal/testutil" "github.com/cloudflare/cloudflare-go/v7/option" - "github.com/cloudflare/cloudflare-go/v7/r2" + "github.com/cloudflare/cloudflare-go/v7/shared" ) func TestNamespaceInstanceNewWithOptionalParams(t *testing.T) { @@ -67,7 +67,8 @@ func TestNamespaceInstanceNewWithOptionalParams(t *testing.T) { ChatCompletionsEndpoint: cloudflare.F(ai_search.NamespaceInstanceNewParamsPublicEndpointParamsChatCompletionsEndpoint{ Disabled: cloudflare.F(true), }), - Enabled: cloudflare.F(true), + CustomDomains: cloudflare.F([]string{"search.example.com"}), + Enabled: cloudflare.F(true), Mcp: cloudflare.F(ai_search.NamespaceInstanceNewParamsPublicEndpointParamsMcp{ Description: cloudflare.F("description"), Disabled: cloudflare.F(true), @@ -116,11 +117,6 @@ func TestNamespaceInstanceNewWithOptionalParams(t *testing.T) { UseBrowserRendering: cloudflare.F(true), }), ParseType: cloudflare.F(ai_search.NamespaceInstanceNewParamsSourceParamsWebCrawlerParseTypeSitemap), - StoreOptions: cloudflare.F(ai_search.NamespaceInstanceNewParamsSourceParamsWebCrawlerStoreOptions{ - StorageID: cloudflare.F("storage_id"), - R2Jurisdiction: cloudflare.F("r2_jurisdiction"), - StorageType: cloudflare.F(r2.ProviderR2), - }), }), }), SyncInterval: cloudflare.F(ai_search.NamespaceInstanceNewParamsSyncInterval900), @@ -189,7 +185,8 @@ func TestNamespaceInstanceUpdateWithOptionalParams(t *testing.T) { ChatCompletionsEndpoint: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsPublicEndpointParamsChatCompletionsEndpoint{ Disabled: cloudflare.F(true), }), - Enabled: cloudflare.F(true), + CustomDomains: cloudflare.F([]string{"search.example.com"}), + Enabled: cloudflare.F(true), Mcp: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsPublicEndpointParamsMcp{ Description: cloudflare.F("description"), Disabled: cloudflare.F(true), @@ -215,6 +212,7 @@ func TestNamespaceInstanceUpdateWithOptionalParams(t *testing.T) { RewriteModel: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsRewriteModelCfMetaLlama3_3_70bInstructFp8Fast), RewriteQuery: cloudflare.F(true), ScoreThreshold: cloudflare.F(0.000000), + Source: cloudflare.F("source"), SourceParams: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsSourceParams{ ExcludeItems: cloudflare.F([]string{"/admin/**", "/private/**", "**\\temp\\**"}), IncludeItems: cloudflare.F([]string{"/blog/**", "/docs/**/*.html", "**\\blog\\**.html"}), @@ -237,11 +235,6 @@ func TestNamespaceInstanceUpdateWithOptionalParams(t *testing.T) { UseBrowserRendering: cloudflare.F(true), }), ParseType: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsSourceParamsWebCrawlerParseTypeSitemap), - StoreOptions: cloudflare.F(ai_search.NamespaceInstanceUpdateParamsSourceParamsWebCrawlerStoreOptions{ - StorageID: cloudflare.F("storage_id"), - R2Jurisdiction: cloudflare.F("r2_jurisdiction"), - StorageType: cloudflare.F(r2.ProviderR2), - }), }), }), Summarization: cloudflare.F(true), @@ -350,7 +343,7 @@ func TestNamespaceInstanceChatCompletionsWithOptionalParams(t *testing.T) { ai_search.NamespaceInstanceChatCompletionsParams{ AccountID: cloudflare.F("c3dc5f0b34a14ff8e1b3ec04895e1b22"), Messages: cloudflare.F([]ai_search.NamespaceInstanceChatCompletionsParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.NamespaceInstanceChatCompletionsParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.NamespaceInstanceChatCompletionsParamsMessagesRoleSystem), }}), AISearchOptions: cloudflare.F(ai_search.NamespaceInstanceChatCompletionsParamsAISearchOptions{ @@ -482,7 +475,7 @@ func TestNamespaceInstanceSearchWithOptionalParams(t *testing.T) { }), }), Messages: cloudflare.F([]ai_search.NamespaceInstanceSearchParamsMessage{{ - Content: cloudflare.F("content"), + Content: cloudflare.F[ai_search.NamespaceInstanceSearchParamsMessagesContentUnion](shared.UnionString("string")), Role: cloudflare.F(ai_search.NamespaceInstanceSearchParamsMessagesRoleSystem), }}), Query: cloudflare.F("x"), diff --git a/api.md b/api.md index 89bde83b08c..70b335dda5a 100644 --- a/api.md +++ b/api.md @@ -79,6 +79,8 @@ # [EmailSecurity](email_security/api.md) +# [EmailAuth](email_auth/api.md) + # [EmailRouting](email_routing/api.md) # [EmailSending](email_sending/api.md) @@ -215,6 +217,8 @@ # [Calls](calls/api.md) +# [MoQ](moq/api.md) + # [CloudforceOne](cloudforce_one/api.md) # [AIGateway](ai_gateway/api.md) diff --git a/api_gateway/schema.go b/api_gateway/schema.go index ca07d984bb6..488c1213bd9 100644 --- a/api_gateway/schema.go +++ b/api_gateway/schema.go @@ -36,7 +36,7 @@ func NewSchemaService(opts ...option.RequestOption) (r *SchemaService) { return } -// Retrieve operations and features as OpenAPI schemas +// Retrieves API operations and their features exported as OpenAPI schemas. func (r *SchemaService) List(ctx context.Context, params SchemaListParams, opts ...option.RequestOption) (res *SchemaListResponse, err error) { var env SchemaListResponseEnvelope opts = slices.Concat(r.Options, opts) diff --git a/api_gateway/userschema.go b/api_gateway/userschema.go index ad157377428..d2476466e6f 100644 --- a/api_gateway/userschema.go +++ b/api_gateway/userschema.go @@ -50,7 +50,8 @@ func NewUserSchemaService(opts ...option.RequestOption) (r *UserSchemaService) { return } -// Upload a schema to a zone +// Uploads a new OpenAPI schema for API Shield schema validation. The schema +// defines expected request/response formats for API endpoints. // // Deprecated: Use // [Schema Validation API](https://developers.cloudflare.com/api/resources/schema_validation/) diff --git a/billing/usage.go b/billing/usage.go index 09c498588d7..e7a94bdf52e 100644 --- a/billing/usage.go +++ b/billing/usage.go @@ -302,6 +302,8 @@ type UsagePaygoResponse struct { ServiceName string `json:"ServiceName" api:"required"` // Identifies the product family for the Cloudflare service. ServiceFamilyName string `json:"ServiceFamilyName"` + // The identifier for the Cloudflare subscription. + SubscriptionID string `json:"SubscriptionId" api:"nullable"` // The identifier for the Cloudflare zone (zone tag). ZoneID string `json:"ZoneId" api:"nullable"` // The display name of the Cloudflare zone. @@ -324,6 +326,7 @@ type usagePaygoResponseJSON struct { PricingQuantity apijson.Field ServiceName apijson.Field ServiceFamilyName apijson.Field + SubscriptionID apijson.Field ZoneID apijson.Field ZoneName apijson.Field raw string diff --git a/bot_management/botmanagement.go b/bot_management/botmanagement.go index 2d8cb34dc3e..c04cf6c3b7a 100644 --- a/bot_management/botmanagement.go +++ b/bot_management/botmanagement.go @@ -139,8 +139,7 @@ func (r *BotManagementService) Get(ctx context.Context, query BotManagementGetPa } type BotFightModeConfiguration struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection BotFightModeConfigurationAIBotsProtection `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant BotFightModeConfigurationCfRobotsVariant `json:"cf_robots_variant"` @@ -195,8 +194,7 @@ func (r BotFightModeConfiguration) implementsBotManagementUpdateResponse() {} func (r BotFightModeConfiguration) implementsBotManagementGetResponse() {} -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type BotFightModeConfigurationAIBotsProtection string const ( @@ -305,8 +303,7 @@ func (r botFightModeConfigurationStaleZoneConfigurationJSON) RawJSON() string { } type BotFightModeConfigurationParam struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection param.Field[BotFightModeConfigurationAIBotsProtection] `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant param.Field[BotFightModeConfigurationCfRobotsVariant] `json:"cf_robots_variant"` @@ -356,8 +353,7 @@ func (r BotFightModeConfigurationStaleZoneConfigurationParam) MarshalJSON() (dat } type SubscriptionConfiguration struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection SubscriptionConfigurationAIBotsProtection `json:"ai_bots_protection"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. @@ -422,8 +418,7 @@ func (r SubscriptionConfiguration) implementsBotManagementUpdateResponse() {} func (r SubscriptionConfiguration) implementsBotManagementGetResponse() {} -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type SubscriptionConfigurationAIBotsProtection string const ( @@ -532,8 +527,7 @@ func (r subscriptionConfigurationStaleZoneConfigurationJSON) RawJSON() string { } type SubscriptionConfigurationParam struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection param.Field[SubscriptionConfigurationAIBotsProtection] `json:"ai_bots_protection"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. @@ -591,8 +585,7 @@ func (r SubscriptionConfigurationStaleZoneConfigurationParam) MarshalJSON() (dat } type SuperBotFightModeDefinitelyConfiguration struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection SuperBotFightModeDefinitelyConfigurationAIBotsProtection `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant SuperBotFightModeDefinitelyConfigurationCfRobotsVariant `json:"cf_robots_variant"` @@ -658,8 +651,7 @@ func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementUpdateR func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementGetResponse() {} -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type SuperBotFightModeDefinitelyConfigurationAIBotsProtection string const ( @@ -789,8 +781,7 @@ func (r superBotFightModeDefinitelyConfigurationStaleZoneConfigurationJSON) RawJ } type SuperBotFightModeDefinitelyConfigurationParam struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection param.Field[SuperBotFightModeDefinitelyConfigurationAIBotsProtection] `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant param.Field[SuperBotFightModeDefinitelyConfigurationCfRobotsVariant] `json:"cf_robots_variant"` @@ -840,8 +831,7 @@ func (r SuperBotFightModeDefinitelyConfigurationStaleZoneConfigurationParam) Mar } type SuperBotFightModeLikelyConfiguration struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection SuperBotFightModeLikelyConfigurationAIBotsProtection `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant SuperBotFightModeLikelyConfigurationCfRobotsVariant `json:"cf_robots_variant"` @@ -910,8 +900,7 @@ func (r SuperBotFightModeLikelyConfiguration) implementsBotManagementUpdateRespo func (r SuperBotFightModeLikelyConfiguration) implementsBotManagementGetResponse() {} -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type SuperBotFightModeLikelyConfigurationAIBotsProtection string const ( @@ -1054,8 +1043,7 @@ func (r superBotFightModeLikelyConfigurationStaleZoneConfigurationJSON) RawJSON( } type SuperBotFightModeLikelyConfigurationParam struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection param.Field[SuperBotFightModeLikelyConfigurationAIBotsProtection] `json:"ai_bots_protection"` // Specifies the Robots Access Control License variant to use. CfRobotsVariant param.Field[SuperBotFightModeLikelyConfigurationCfRobotsVariant] `json:"cf_robots_variant"` @@ -1103,8 +1091,7 @@ func (r SuperBotFightModeLikelyConfigurationStaleZoneConfigurationParam) Marshal } type BotManagementUpdateResponse struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection BotManagementUpdateResponseAIBotsProtection `json:"ai_bots_protection"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. @@ -1234,8 +1221,7 @@ func init() { ) } -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type BotManagementUpdateResponseAIBotsProtection string const ( @@ -1353,8 +1339,7 @@ func (r BotManagementUpdateResponseSBFMVerifiedBots) IsKnown() bool { } type BotManagementGetResponse struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection BotManagementGetResponseAIBotsProtection `json:"ai_bots_protection"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. @@ -1484,8 +1469,7 @@ func init() { ) } -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type BotManagementGetResponseAIBotsProtection string const ( @@ -1613,8 +1597,7 @@ func (r BotManagementUpdateParams) MarshalJSON() (data []byte, err error) { } type BotManagementUpdateParamsBody struct { - // Enable rule to block AI Scrapers and Crawlers. Please note the value - // `only_on_ad_pages` is currently not available for Enterprise customers. + // Enable rule to block AI Scrapers and Crawlers. AIBotsProtection param.Field[BotManagementUpdateParamsBodyAIBotsProtection] `json:"ai_bots_protection"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. @@ -1672,8 +1655,7 @@ type BotManagementUpdateParamsBodyUnion interface { implementsBotManagementUpdateParamsBodyUnion() } -// Enable rule to block AI Scrapers and Crawlers. Please note the value -// `only_on_ad_pages` is currently not available for Enterprise customers. +// Enable rule to block AI Scrapers and Crawlers. type BotManagementUpdateParamsBodyAIBotsProtection string const ( diff --git a/brand_protection/v2query.go b/brand_protection/v2query.go index f29b23c0c1a..f40fd47297f 100644 --- a/brand_protection/v2query.go +++ b/brand_protection/v2query.go @@ -105,18 +105,16 @@ func (r v2QueryGetResponseParametersJSON) RawJSON() string { } type V2QueryGetResponseParametersStringMatch struct { - MaxEditDistance float64 `json:"max_edit_distance" api:"required"` - Pattern string `json:"pattern" api:"required"` - JSON v2QueryGetResponseParametersStringMatchJSON `json:"-"` + Pattern string `json:"pattern" api:"required"` + JSON v2QueryGetResponseParametersStringMatchJSON `json:"-"` } // v2QueryGetResponseParametersStringMatchJSON contains the JSON metadata for the // struct [V2QueryGetResponseParametersStringMatch] type v2QueryGetResponseParametersStringMatchJSON struct { - MaxEditDistance apijson.Field - Pattern apijson.Field - raw string - ExtraFields map[string]apijson.Field + Pattern apijson.Field + raw string + ExtraFields map[string]apijson.Field } func (r *V2QueryGetResponseParametersStringMatch) UnmarshalJSON(data []byte) (err error) { diff --git a/browser_rendering/accessibilitytree.go b/browser_rendering/accessibilitytree.go new file mode 100644 index 00000000000..59d0e7872ce --- /dev/null +++ b/browser_rendering/accessibilitytree.go @@ -0,0 +1,731 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +package browser_rendering + +import ( + "context" + "errors" + "fmt" + "net/http" + "net/url" + "reflect" + "slices" + + "github.com/cloudflare/cloudflare-go/v7/internal/apijson" + "github.com/cloudflare/cloudflare-go/v7/internal/apiquery" + "github.com/cloudflare/cloudflare-go/v7/internal/param" + "github.com/cloudflare/cloudflare-go/v7/internal/requestconfig" + "github.com/cloudflare/cloudflare-go/v7/option" + "github.com/cloudflare/cloudflare-go/v7/shared" + "github.com/tidwall/gjson" +) + +// AccessibilityTreeService contains methods and other services that help with +// interacting with the cloudflare API. +// +// Note, unlike clients, this service does not read variables from the environment +// automatically. You should not instantiate this service directly, and instead use +// the [NewAccessibilityTreeService] method instead. +type AccessibilityTreeService struct { + Options []option.RequestOption +} + +// NewAccessibilityTreeService generates a new service that applies the given +// options to each request. These options are applied after the parent client's +// options (if there is one), and before any request-specific options. +func NewAccessibilityTreeService(opts ...option.RequestOption) (r *AccessibilityTreeService) { + r = &AccessibilityTreeService{} + r.Options = opts + return +} + +// Returns the page's accessibility tree. Use `interestingOnly` to only return +// semantically meaningful nodes; use `root` to scope the tree to a +// CSS-selector-anchored subtree. Control page loading with `gotoOptions` and +// `waitFor*` options. +func (r *AccessibilityTreeService) New(ctx context.Context, params AccessibilityTreeNewParams, opts ...option.RequestOption) (res *AccessibilityTreeNewResponse, err error) { + var env AccessibilityTreeNewResponseEnvelope + opts = slices.Concat(r.Options, opts) + if params.AccountID.Value == "" { + err = errors.New("missing required account_id parameter") + return nil, err + } + path := fmt.Sprintf("accounts/%s/browser-rendering/accessibilityTree", params.AccountID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, params, &env, opts...) + if err != nil { + return nil, err + } + res = &env.Result + return res, nil +} + +type AccessibilityTreeNewResponse struct { + // Accessibility tree node + AccessibilityTree AccessibilityTreeNewResponseAccessibilityTree `json:"accessibilityTree" api:"required,nullable"` + JSON accessibilityTreeNewResponseJSON `json:"-"` +} + +// accessibilityTreeNewResponseJSON contains the JSON metadata for the struct +// [AccessibilityTreeNewResponse] +type accessibilityTreeNewResponseJSON struct { + AccessibilityTree apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessibilityTreeNewResponse) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessibilityTreeNewResponseJSON) RawJSON() string { + return r.raw +} + +// Accessibility tree node +type AccessibilityTreeNewResponseAccessibilityTree struct { + Role string `json:"role" api:"required"` + Autocomplete string `json:"autocomplete"` + Checked AccessibilityTreeNewResponseAccessibilityTreeCheckedUnion `json:"checked"` + Children []interface{} `json:"children"` + Description string `json:"description"` + Disabled bool `json:"disabled"` + Expanded bool `json:"expanded"` + Focused bool `json:"focused"` + Haspopup string `json:"haspopup"` + Invalid string `json:"invalid"` + Keyshortcuts string `json:"keyshortcuts"` + Level float64 `json:"level"` + Modal bool `json:"modal"` + Multiline bool `json:"multiline"` + Multiselectable bool `json:"multiselectable"` + Name string `json:"name"` + Orientation string `json:"orientation"` + Pressed AccessibilityTreeNewResponseAccessibilityTreePressedUnion `json:"pressed"` + Readonly bool `json:"readonly"` + Required bool `json:"required"` + Roledescription string `json:"roledescription"` + Selected bool `json:"selected"` + Value AccessibilityTreeNewResponseAccessibilityTreeValueUnion `json:"value"` + Valuemax float64 `json:"valuemax"` + Valuemin float64 `json:"valuemin"` + Valuetext string `json:"valuetext"` + JSON accessibilityTreeNewResponseAccessibilityTreeJSON `json:"-"` +} + +// accessibilityTreeNewResponseAccessibilityTreeJSON contains the JSON metadata for +// the struct [AccessibilityTreeNewResponseAccessibilityTree] +type accessibilityTreeNewResponseAccessibilityTreeJSON struct { + Role apijson.Field + Autocomplete apijson.Field + Checked apijson.Field + Children apijson.Field + Description apijson.Field + Disabled apijson.Field + Expanded apijson.Field + Focused apijson.Field + Haspopup apijson.Field + Invalid apijson.Field + Keyshortcuts apijson.Field + Level apijson.Field + Modal apijson.Field + Multiline apijson.Field + Multiselectable apijson.Field + Name apijson.Field + Orientation apijson.Field + Pressed apijson.Field + Readonly apijson.Field + Required apijson.Field + Roledescription apijson.Field + Selected apijson.Field + Value apijson.Field + Valuemax apijson.Field + Valuemin apijson.Field + Valuetext apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AccessibilityTreeNewResponseAccessibilityTree) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r accessibilityTreeNewResponseAccessibilityTreeJSON) RawJSON() string { + return r.raw +} + +// Union satisfied by [shared.UnionBool] or +// [AccessibilityTreeNewResponseAccessibilityTreeCheckedString]. +type AccessibilityTreeNewResponseAccessibilityTreeCheckedUnion interface { + ImplementsAccessibilityTreeNewResponseAccessibilityTreeCheckedUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessibilityTreeNewResponseAccessibilityTreeCheckedUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.True, + Type: reflect.TypeOf(shared.UnionBool(false)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.False, + Type: reflect.TypeOf(shared.UnionBool(false)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(AccessibilityTreeNewResponseAccessibilityTreeCheckedString("")), + }, + ) +} + +type AccessibilityTreeNewResponseAccessibilityTreeCheckedString string + +const ( + AccessibilityTreeNewResponseAccessibilityTreeCheckedStringMixed AccessibilityTreeNewResponseAccessibilityTreeCheckedString = "mixed" +) + +func (r AccessibilityTreeNewResponseAccessibilityTreeCheckedString) IsKnown() bool { + switch r { + case AccessibilityTreeNewResponseAccessibilityTreeCheckedStringMixed: + return true + } + return false +} + +func (r AccessibilityTreeNewResponseAccessibilityTreeCheckedString) ImplementsAccessibilityTreeNewResponseAccessibilityTreeCheckedUnion() { +} + +// Union satisfied by [shared.UnionBool] or +// [AccessibilityTreeNewResponseAccessibilityTreePressedString]. +type AccessibilityTreeNewResponseAccessibilityTreePressedUnion interface { + ImplementsAccessibilityTreeNewResponseAccessibilityTreePressedUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessibilityTreeNewResponseAccessibilityTreePressedUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.True, + Type: reflect.TypeOf(shared.UnionBool(false)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.False, + Type: reflect.TypeOf(shared.UnionBool(false)), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(AccessibilityTreeNewResponseAccessibilityTreePressedString("")), + }, + ) +} + +type AccessibilityTreeNewResponseAccessibilityTreePressedString string + +const ( + AccessibilityTreeNewResponseAccessibilityTreePressedStringMixed AccessibilityTreeNewResponseAccessibilityTreePressedString = "mixed" +) + +func (r AccessibilityTreeNewResponseAccessibilityTreePressedString) IsKnown() bool { + switch r { + case AccessibilityTreeNewResponseAccessibilityTreePressedStringMixed: + return true + } + return false +} + +func (r AccessibilityTreeNewResponseAccessibilityTreePressedString) ImplementsAccessibilityTreeNewResponseAccessibilityTreePressedUnion() { +} + +// Union satisfied by [shared.UnionString] or [shared.UnionFloat]. +type AccessibilityTreeNewResponseAccessibilityTreeValueUnion interface { + ImplementsAccessibilityTreeNewResponseAccessibilityTreeValueUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*AccessibilityTreeNewResponseAccessibilityTreeValueUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.Number, + Type: reflect.TypeOf(shared.UnionFloat(0)), + }, + ) +} + +type AccessibilityTreeNewParams struct { + // Account ID. + AccountID param.Field[string] `path:"account_id" api:"required"` + Body AccessibilityTreeNewParamsBodyUnion `json:"body" api:"required"` + // Cache TTL default is 5s. Set to 0 to disable. + CacheTTL param.Field[float64] `query:"cacheTTL"` +} + +func (r AccessibilityTreeNewParams) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r.Body) +} + +// URLQuery serializes [AccessibilityTreeNewParams]'s query parameters as +// `url.Values`. +func (r AccessibilityTreeNewParams) URLQuery() (v url.Values) { + return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ + ArrayFormat: apiquery.ArrayQueryFormatRepeat, + NestedFormat: apiquery.NestedQueryFormatDots, + }) +} + +type AccessibilityTreeNewParamsBody struct { + // The maximum duration allowed for the browser action to complete after the page + // has loaded (such as taking screenshots, extracting content, or generating PDFs). + // If this time limit is exceeded, the action stops and returns a timeout error. + ActionTimeout param.Field[float64] `json:"actionTimeout"` + AddScriptTag param.Field[interface{}] `json:"addScriptTag"` + AddStyleTag param.Field[interface{}] `json:"addStyleTag"` + AllowRequestPattern param.Field[interface{}] `json:"allowRequestPattern"` + AllowResourceTypes param.Field[interface{}] `json:"allowResourceTypes"` + Authenticate param.Field[interface{}] `json:"authenticate"` + // Attempt to proceed when 'awaited' events fail or timeout. + BestAttempt param.Field[bool] `json:"bestAttempt"` + Cookies param.Field[interface{}] `json:"cookies"` + EmulateMediaType param.Field[string] `json:"emulateMediaType"` + GotoOptions param.Field[interface{}] `json:"gotoOptions"` + // Set the content of the page, eg: `

Hello World!!

`. Either `html` or + // `url` must be set. + HTML param.Field[string] `json:"html"` + InterestingOnly param.Field[bool] `json:"interestingOnly"` + RejectRequestPattern param.Field[interface{}] `json:"rejectRequestPattern"` + RejectResourceTypes param.Field[interface{}] `json:"rejectResourceTypes"` + Root param.Field[string] `json:"root"` + SetExtraHTTPHeaders param.Field[interface{}] `json:"setExtraHTTPHeaders"` + SetJavaScriptEnabled param.Field[bool] `json:"setJavaScriptEnabled"` + // URL to navigate to, eg. `https://example.com`. + URL param.Field[string] `json:"url" format:"uri"` + UserAgent param.Field[string] `json:"userAgent"` + Viewport param.Field[interface{}] `json:"viewport"` + WaitForSelector param.Field[interface{}] `json:"waitForSelector"` + // Waits for a specified timeout before continuing. + WaitForTimeout param.Field[float64] `json:"waitForTimeout"` +} + +func (r AccessibilityTreeNewParamsBody) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +func (r AccessibilityTreeNewParamsBody) implementsAccessibilityTreeNewParamsBodyUnion() {} + +// Satisfied by [browser_rendering.AccessibilityTreeNewParamsBodyObject], +// [browser_rendering.AccessibilityTreeNewParamsBodyObject], +// [AccessibilityTreeNewParamsBody]. +type AccessibilityTreeNewParamsBodyUnion interface { + implementsAccessibilityTreeNewParamsBodyUnion() +} + +type AccessibilityTreeNewParamsBodyObject struct { + // URL to navigate to, eg. `https://example.com`. + URL param.Field[string] `json:"url" api:"required" format:"uri"` + // The maximum duration allowed for the browser action to complete after the page + // has loaded (such as taking screenshots, extracting content, or generating PDFs). + // If this time limit is exceeded, the action stops and returns a timeout error. + ActionTimeout param.Field[float64] `json:"actionTimeout"` + // Adds a `