|
3 | 3 | package vectorize
|
4 | 4 |
|
5 | 5 | import (
|
6 |
| - "bytes" |
7 | 6 | "context"
|
8 | 7 | "errors"
|
9 | 8 | "fmt"
|
10 |
| - "io" |
11 |
| - "mime/multipart" |
12 | 9 | "net/http"
|
13 | 10 | "net/url"
|
14 | 11 | "time"
|
15 | 12 |
|
16 |
| - "github.com/cloudflare/cloudflare-go/v4/internal/apiform" |
17 | 13 | "github.com/cloudflare/cloudflare-go/v4/internal/apijson"
|
18 | 14 | "github.com/cloudflare/cloudflare-go/v4/internal/apiquery"
|
19 | 15 | "github.com/cloudflare/cloudflare-go/v4/internal/param"
|
@@ -911,24 +907,13 @@ type IndexInsertParams struct {
|
911 | 907 | // Identifier
|
912 | 908 | AccountID param.Field[string] `path:"account_id,required"`
|
913 | 909 | // ndjson file containing vectors to insert.
|
914 |
| - Body io.Reader `json:"body,required" format:"binary"` |
| 910 | + Body string `json:"body,required"` |
915 | 911 | // Behavior for ndjson parse failures.
|
916 | 912 | UnparsableBehavior param.Field[IndexInsertParamsUnparsableBehavior] `query:"unparsable-behavior"`
|
917 | 913 | }
|
918 | 914 |
|
919 |
| -func (r IndexInsertParams) MarshalMultipart() (data []byte, contentType string, err error) { |
920 |
| - buf := bytes.NewBuffer(nil) |
921 |
| - writer := multipart.NewWriter(buf) |
922 |
| - err = apiform.MarshalRoot(r, writer) |
923 |
| - if err != nil { |
924 |
| - writer.Close() |
925 |
| - return nil, "", err |
926 |
| - } |
927 |
| - err = writer.Close() |
928 |
| - if err != nil { |
929 |
| - return nil, "", err |
930 |
| - } |
931 |
| - return buf.Bytes(), writer.FormDataContentType(), nil |
| 915 | +func (r IndexInsertParams) MarshalJSON() (data []byte, err error) { |
| 916 | + return apijson.MarshalRoot(r.Body) |
932 | 917 | }
|
933 | 918 |
|
934 | 919 | // URLQuery serializes [IndexInsertParams]'s query parameters as `url.Values`.
|
@@ -1083,24 +1068,13 @@ type IndexUpsertParams struct {
|
1083 | 1068 | // Identifier
|
1084 | 1069 | AccountID param.Field[string] `path:"account_id,required"`
|
1085 | 1070 | // ndjson file containing vectors to upsert.
|
1086 |
| - Body io.Reader `json:"body,required" format:"binary"` |
| 1071 | + Body string `json:"body,required"` |
1087 | 1072 | // Behavior for ndjson parse failures.
|
1088 | 1073 | UnparsableBehavior param.Field[IndexUpsertParamsUnparsableBehavior] `query:"unparsable-behavior"`
|
1089 | 1074 | }
|
1090 | 1075 |
|
1091 |
| -func (r IndexUpsertParams) MarshalMultipart() (data []byte, contentType string, err error) { |
1092 |
| - buf := bytes.NewBuffer(nil) |
1093 |
| - writer := multipart.NewWriter(buf) |
1094 |
| - err = apiform.MarshalRoot(r, writer) |
1095 |
| - if err != nil { |
1096 |
| - writer.Close() |
1097 |
| - return nil, "", err |
1098 |
| - } |
1099 |
| - err = writer.Close() |
1100 |
| - if err != nil { |
1101 |
| - return nil, "", err |
1102 |
| - } |
1103 |
| - return buf.Bytes(), writer.FormDataContentType(), nil |
| 1076 | +func (r IndexUpsertParams) MarshalJSON() (data []byte, err error) { |
| 1077 | + return apijson.MarshalRoot(r.Body) |
1104 | 1078 | }
|
1105 | 1079 |
|
1106 | 1080 | // URLQuery serializes [IndexUpsertParams]'s query parameters as `url.Values`.
|
|
0 commit comments