Skip to content

Commit 67adab7

Browse files
feat(api): manual updates
1 parent 9aa2ded commit 67adab7

File tree

6 files changed

+635
-178
lines changed

6 files changed

+635
-178
lines changed

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-667f7f4988b44bc587d6eb9960ff5c8326e9f7e9b072f3f724f9f54166eff8b1.yml
3-
openapi_spec_hash: f2081864a4abee0480e5ff991b4c936a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-e7bc47a9221d7da9c8c9653d3fd1d4cfdf2408588e32c4aa62bd02a50ec93c36.yml
3+
openapi_spec_hash: 8d061396a2fff9d1add4d5baf03ab939
44
config_hash: 70f9408b8d1dfbcf262a20d6eed50e1c

README.md

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func main() {
5555
option.WithPrivateAPIKey("My Private API Key"), // defaults to os.LookupEnv("IMAGEKIT_PRIVATE_API_KEY")
5656
option.WithPassword("My Password"), // defaults to os.LookupEnv("OPTIONAL_IMAGEKIT_IGNORES_THIS")
5757
)
58-
response, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{
58+
response, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParamsFileUploadV1{
5959
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
6060
FileName: "file-name.jpg",
6161
})
@@ -299,10 +299,7 @@ When the API returns a non-success status code, we return an error with type
299299
To handle errors, we recommend that you use the `errors.As` pattern:
300300

301301
```go
302-
_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{
303-
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
304-
FileName: "file-name.jpg",
305-
})
302+
_, err := client.Files.Upload(context.TODO(), imagekit.FileUploadParams{})
306303
if err != nil {
307304
var apierr *imagekit.Error
308305
if errors.As(err, &apierr) {
@@ -329,10 +326,7 @@ ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
329326
defer cancel()
330327
client.Files.Upload(
331328
ctx,
332-
imagekit.FileUploadParams{
333-
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
334-
FileName: "file-name.jpg",
335-
},
329+
imagekit.FileUploadParams{},
336330
// This sets the per-retry timeout
337331
option.WithRequestTimeout(20*time.Second),
338332
)
@@ -354,19 +348,19 @@ which can be used to wrap any `io.Reader` with the appropriate file name and con
354348
```go
355349
// A file from the file system
356350
file, err := os.Open("/path/to/file")
357-
imagekit.FileUploadParams{
351+
imagekit.FileUploadParamsFileUploadV1{
358352
File: file,
359353
FileName: "fileName",
360354
}
361355

362356
// A file from a string
363-
imagekit.FileUploadParams{
357+
imagekit.FileUploadParamsFileUploadV1{
364358
File: strings.NewReader("my file contents"),
365359
FileName: "fileName",
366360
}
367361

368362
// With a custom filename and contentType
369-
imagekit.FileUploadParams{
363+
imagekit.FileUploadParamsFileUploadV1{
370364
File: imagekit.NewFile(strings.NewReader(`{"hello": "foo"}`), "file.go", "application/json"),
371365
FileName: "fileName",
372366
}
@@ -389,10 +383,7 @@ client := imagekit.NewClient(
389383
// Override per-request:
390384
client.Files.Upload(
391385
context.TODO(),
392-
imagekit.FileUploadParams{
393-
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
394-
FileName: "file-name.jpg",
395-
},
386+
imagekit.FileUploadParams{},
396387
option.WithMaxRetries(5),
397388
)
398389
```
@@ -407,10 +398,7 @@ you need to examine response headers, status codes, or other details.
407398
var response *http.Response
408399
response, err := client.Files.Upload(
409400
context.TODO(),
410-
imagekit.FileUploadParams{
411-
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
412-
FileName: "file-name.jpg",
413-
},
401+
imagekit.FileUploadParams{},
414402
option.WithResponseInto(&response),
415403
)
416404
if err != nil {

client_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func TestUserAgentHeader(t *testing.T) {
4141
},
4242
}),
4343
)
44-
client.Files.Upload(context.Background(), imagekit.FileUploadParams{
44+
client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
4545
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
4646
FileName: "file-name.jpg",
4747
})
@@ -69,7 +69,7 @@ func TestRetryAfter(t *testing.T) {
6969
},
7070
}),
7171
)
72-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
72+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
7373
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
7474
FileName: "file-name.jpg",
7575
})
@@ -108,7 +108,7 @@ func TestDeleteRetryCountHeader(t *testing.T) {
108108
}),
109109
option.WithHeaderDel("X-Stainless-Retry-Count"),
110110
)
111-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
111+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
112112
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
113113
FileName: "file-name.jpg",
114114
})
@@ -142,7 +142,7 @@ func TestOverwriteRetryCountHeader(t *testing.T) {
142142
}),
143143
option.WithHeader("X-Stainless-Retry-Count", "42"),
144144
)
145-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
145+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
146146
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
147147
FileName: "file-name.jpg",
148148
})
@@ -175,7 +175,7 @@ func TestRetryAfterMs(t *testing.T) {
175175
},
176176
}),
177177
)
178-
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParams{
178+
_, err := client.Files.Upload(context.Background(), imagekit.FileUploadParamsFileUploadV1{
179179
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
180180
FileName: "file-name.jpg",
181181
})
@@ -202,7 +202,7 @@ func TestContextCancel(t *testing.T) {
202202
)
203203
cancelCtx, cancel := context.WithCancel(context.Background())
204204
cancel()
205-
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParams{
205+
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParamsFileUploadV1{
206206
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
207207
FileName: "file-name.jpg",
208208
})
@@ -226,7 +226,7 @@ func TestContextCancelDelay(t *testing.T) {
226226
)
227227
cancelCtx, cancel := context.WithTimeout(context.Background(), 2*time.Millisecond)
228228
defer cancel()
229-
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParams{
229+
_, err := client.Files.Upload(cancelCtx, imagekit.FileUploadParamsFileUploadV1{
230230
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
231231
FileName: "file-name.jpg",
232232
})
@@ -256,7 +256,7 @@ func TestContextDeadline(t *testing.T) {
256256
},
257257
}),
258258
)
259-
_, err := client.Files.Upload(deadlineCtx, imagekit.FileUploadParams{
259+
_, err := client.Files.Upload(deadlineCtx, imagekit.FileUploadParamsFileUploadV1{
260260
File: io.Reader(bytes.NewBuffer([]byte("https://www.example.com/public-url.jpg"))),
261261
FileName: "file-name.jpg",
262262
})

0 commit comments

Comments
 (0)