Skip to content

Commit 367f71b

Browse files
feat(api): manual updates
1 parent 13d6559 commit 367f71b

File tree

5 files changed

+73
-74
lines changed

5 files changed

+73
-74
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 42
22
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/imagekit-inc%2Fimagekit-76afc867b06fdc43b339f2c7d19f25a46481b25e8264ca24ea43daa1ea9234fc.yml
33
openapi_spec_hash: a1455d2ab02c48a14551362dd8ec2261
4-
config_hash: 396f0b1c74b8b5bc4dd6b5d87e374d90
4+
config_hash: c434cea5e670c34d574784866661bebd

src/resources/accounts/origins.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ export class Origins extends APIResource {
3636
* @example
3737
* ```ts
3838
* const origin = await client.accounts.origins.update('id', {
39-
* accessKey: 'AKIAIOSFODNN7EXAMPLE',
40-
* bucket: 'product-images',
41-
* name: 'US S3 Storage',
42-
* secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
43-
* type: 'S3',
39+
* origin: {
40+
* accessKey: 'AKIATEST123',
41+
* bucket: 'test-bucket',
42+
* name: 'My S3 Origin',
43+
* secretKey: 'secrettest123',
44+
* type: 'S3',
45+
* },
4446
* });
4547
* ```
4648
*/
47-
update(id: string, body: OriginUpdateParams, options?: RequestOptions): APIPromise<OriginUpdateResponse> {
48-
return this._client.put(path`/v1/accounts/origins/${id}`, { body, ...options });
49+
update(id: string, params: OriginUpdateParams, options?: RequestOptions): APIPromise<OriginUpdateResponse> {
50+
const { origin } = params;
51+
return this._client.put(path`/v1/accounts/origins/${id}`, { body: origin, ...options });
4952
}
5053

5154
/**
@@ -1508,17 +1511,22 @@ export namespace OriginCreateParams {
15081511
}
15091512
}
15101513

1511-
export type OriginUpdateParams =
1512-
| OriginUpdateParams.S3
1513-
| OriginUpdateParams.S3Compatible
1514-
| OriginUpdateParams.CloudinaryBackup
1515-
| OriginUpdateParams.WebFolder
1516-
| OriginUpdateParams.WebProxy
1517-
| OriginUpdateParams.GoogleCloudStorageGcs
1518-
| OriginUpdateParams.AzureBlobStorage
1519-
| OriginUpdateParams.AkeneoPim;
1520-
1521-
export declare namespace OriginUpdateParams {
1514+
export interface OriginUpdateParams {
1515+
/**
1516+
* Schema for origin resources.
1517+
*/
1518+
origin:
1519+
| OriginUpdateParams.S3
1520+
| OriginUpdateParams.S3Compatible
1521+
| OriginUpdateParams.CloudinaryBackup
1522+
| OriginUpdateParams.WebFolder
1523+
| OriginUpdateParams.WebProxy
1524+
| OriginUpdateParams.GoogleCloudStorageGcs
1525+
| OriginUpdateParams.AzureBlobStorage
1526+
| OriginUpdateParams.AkeneoPim;
1527+
}
1528+
1529+
export namespace OriginUpdateParams {
15221530
export interface S3 {
15231531
/**
15241532
* Access key for the bucket.

src/resources/files/files.ts

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,36 +50,16 @@ export class Files extends APIResource {
5050
*
5151
* @example
5252
* ```ts
53-
* const file = await client.files.update('fileId', {
54-
* customCoordinates: '10,10,100,100',
55-
* customMetadata: { brand: 'Nike', color: 'red' },
56-
* extensions: [
57-
* { name: 'remove-bg', options: { add_shadow: true } },
58-
* {
59-
* name: 'google-auto-tagging',
60-
* minConfidence: 80,
61-
* maxTags: 10,
62-
* },
63-
* {
64-
* name: 'aws-auto-tagging',
65-
* minConfidence: 80,
66-
* maxTags: 10,
67-
* },
68-
* { name: 'ai-auto-description' },
69-
* ],
70-
* removeAITags: ['car', 'vehicle', 'motorsports'],
71-
* tags: ['tag1', 'tag2'],
72-
* webhookUrl:
73-
* 'https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a',
74-
* });
53+
* const file = await client.files.update('fileId');
7554
* ```
7655
*/
7756
update(
7857
fileID: string,
79-
body: FileUpdateParams | null | undefined = {},
58+
params: FileUpdateParams | null | undefined = undefined,
8059
options?: RequestOptions,
8160
): APIPromise<FileUpdateResponse> {
82-
return this._client.patch(path`/v1/files/${fileID}/details`, { body, ...options });
61+
const { update } = params ?? {};
62+
return this._client.patch(path`/v1/files/${fileID}/details`, { body: update, ...options });
8363
}
8464

8565
/**
@@ -967,9 +947,11 @@ export namespace FileUploadResponse {
967947
}
968948
}
969949

970-
export type FileUpdateParams = FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus;
950+
export interface FileUpdateParams {
951+
update?: FileUpdateParams.UpdateFileDetails | FileUpdateParams.ChangePublicationStatus;
952+
}
971953

972-
export declare namespace FileUpdateParams {
954+
export namespace FileUpdateParams {
973955
export interface UpdateFileDetails {
974956
/**
975957
* Define an important area in the image in the format `x,y,width,height` e.g.

tests/api-resources/accounts/origins.test.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ describe('resource origins', () => {
4848
// Prism tests are disabled
4949
test.skip('update: only required params', async () => {
5050
const responsePromise = client.accounts.origins.update('id', {
51-
accessKey: 'AKIAIOSFODNN7EXAMPLE',
52-
bucket: 'product-images',
53-
name: 'US S3 Storage',
54-
secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
55-
type: 'S3',
51+
origin: {
52+
accessKey: 'AKIATEST123',
53+
bucket: 'test-bucket',
54+
name: 'My S3 Origin',
55+
secretKey: 'secrettest123',
56+
type: 'S3',
57+
},
5658
});
5759
const rawResponse = await responsePromise.asResponse();
5860
expect(rawResponse).toBeInstanceOf(Response);
@@ -66,14 +68,16 @@ describe('resource origins', () => {
6668
// Prism tests are disabled
6769
test.skip('update: required and optional params', async () => {
6870
const response = await client.accounts.origins.update('id', {
69-
accessKey: 'AKIAIOSFODNN7EXAMPLE',
70-
bucket: 'product-images',
71-
name: 'US S3 Storage',
72-
secretKey: 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY',
73-
type: 'S3',
74-
baseUrlForCanonicalHeader: 'https://cdn.example.com',
75-
includeCanonicalHeader: false,
76-
prefix: 'raw-assets',
71+
origin: {
72+
accessKey: 'AKIATEST123',
73+
bucket: 'test-bucket',
74+
name: 'My S3 Origin',
75+
secretKey: 'secrettest123',
76+
type: 'S3',
77+
baseUrlForCanonicalHeader: 'https://cdn.example.com',
78+
includeCanonicalHeader: false,
79+
prefix: 'images',
80+
},
7781
});
7882
});
7983

tests/api-resources/files/files.test.ts

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,28 @@ describe('resource files', () => {
2828
client.files.update(
2929
'fileId',
3030
{
31-
customCoordinates: 'customCoordinates',
32-
customMetadata: { foo: 'bar' },
33-
description: 'description',
34-
extensions: [
35-
{
36-
name: 'remove-bg',
37-
options: {
38-
add_shadow: true,
39-
bg_color: 'bg_color',
40-
bg_image_url: 'bg_image_url',
41-
semitransparency: true,
31+
update: {
32+
customCoordinates: '10,10,100,100',
33+
customMetadata: { brand: 'bar', color: 'bar' },
34+
description: 'description',
35+
extensions: [
36+
{
37+
name: 'remove-bg',
38+
options: {
39+
add_shadow: true,
40+
bg_color: 'bg_color',
41+
bg_image_url: 'bg_image_url',
42+
semitransparency: true,
43+
},
4244
},
43-
},
44-
],
45-
removeAITags: ['string'],
46-
tags: ['tag1', 'tag2'],
47-
webhookUrl: 'https://example.com',
45+
{ maxTags: 10, minConfidence: 80, name: 'google-auto-tagging' },
46+
{ maxTags: 10, minConfidence: 80, name: 'aws-auto-tagging' },
47+
{ name: 'ai-auto-description' },
48+
],
49+
removeAITags: ['car', 'vehicle', 'motorsports'],
50+
tags: ['tag1', 'tag2'],
51+
webhookUrl: 'https://webhook.site/0d6b6c7a-8e5a-4b3a-8b7c-0d6b6c7a8e5a',
52+
},
4853
},
4954
{ path: '/_stainless_unknown_path' },
5055
),

0 commit comments

Comments
 (0)