Skip to content

Commit 0ffd9c8

Browse files
feat: Add support for proxy (box/box-codegen#559) (#337)
1 parent f83807c commit 0ffd9c8

15 files changed

+592
-512
lines changed

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "edc49a6", "specHash": "6ca858e", "version": "1.5.1" }
1+
{ "engineHash": "5d1b305", "specHash": "6ca858e", "version": "1.5.1" }

docs/client.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,15 @@ divided across resource managers.
66
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
77
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
88

9+
- [Client](#client)
910
- [Additional headers](#additional-headers)
1011
- [As-User header](#as-user-header)
1112
- [Suppress notifications](#suppress-notifications)
1213
- [Custom headers](#custom-headers)
1314
- [Custom Base URLs](#custom-base-urls)
15+
- [Custom Agent Options](#custom-agent-options)
1416
- [Interceptors](#interceptors)
17+
- [Use Proxy for API calls](#use-proxy-for-api-calls)
1518

1619
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1720

@@ -129,3 +132,19 @@ const clientWithInterceptor: BoxClient = client.withInterceptors([
129132
},
130133
]);
131134
```
135+
136+
# Use Proxy for API calls
137+
138+
In order to use a proxy for API calls, calling the `client.withProxy(proxyConfig)` method creates a new client, leaving the original client unmodified, with the username and password being optional.
139+
140+
If both custom agent options and proxy are provided, the proxy will take precedence.
141+
142+
**Note:** We are only supporting http/s proxies with basic authentication. NTLM and other authentication methods are not supported.
143+
144+
```js
145+
newClient = client.withProxy({
146+
url: 'http://127.0.0.1:1234/',
147+
username: 'user',
148+
password: 'password',
149+
});
150+
```

docs/events.md

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,7 @@
11
# EventsManager
22

3-
- [List user and enterprise events](#list-user-and-enterprise-events)
43
- [Get events long poll endpoint](#get-events-long-poll-endpoint)
5-
6-
## List user and enterprise events
7-
8-
Returns up to a year of past events for a given user
9-
or for the entire enterprise.
10-
11-
By default this returns events for the authenticated user. To retrieve events
12-
for the entire enterprise, set the `stream_type` to `admin_logs_streaming`
13-
for live monitoring of new events, or `admin_logs` for querying across
14-
historical events. The user making the API call will
15-
need to have admin privileges, and the application will need to have the
16-
scope `manage enterprise properties` checked.
17-
18-
This operation is performed by calling function `getEvents`.
19-
20-
See the endpoint docs at
21-
[API Reference](https://developer.box.com/reference/get-events/).
22-
23-
<!-- sample get_events -->
24-
25-
```ts
26-
await client.events.getEvents({
27-
streamType: 'admin_logs' as GetEventsQueryParamsStreamTypeField,
28-
limit: 1,
29-
createdAfter: createdAfterDate,
30-
createdBefore: createdBeforeDate,
31-
} satisfies GetEventsQueryParams);
32-
```
33-
34-
### Arguments
35-
36-
- queryParams `GetEventsQueryParams`
37-
- Query parameters of getEvents method
38-
- headersInput `GetEventsHeadersInput`
39-
- Headers of getEvents method
40-
- cancellationToken `undefined | CancellationToken`
41-
- Token used for request cancellation.
42-
43-
### Returns
44-
45-
This function returns a value of type `Events`.
46-
47-
Returns a list of event objects.
48-
49-
Events objects are returned in pages, with each page (chunk)
50-
including a list of event objects. The response includes a
51-
`chunk_size` parameter indicating how many events were returned in this
52-
chunk, as well as the next `stream_position` that can be
53-
queried.
4+
- [List user and enterprise events](#list-user-and-enterprise-events)
545

556
## Get events long poll endpoint
567

@@ -112,3 +63,52 @@ This function returns a value of type `RealtimeServers`.
11263

11364
Returns a paginated array of servers that can be used
11465
instead of the regular endpoints for long-polling events.
66+
67+
## List user and enterprise events
68+
69+
Returns up to a year of past events for a given user
70+
or for the entire enterprise.
71+
72+
By default this returns events for the authenticated user. To retrieve events
73+
for the entire enterprise, set the `stream_type` to `admin_logs_streaming`
74+
for live monitoring of new events, or `admin_logs` for querying across
75+
historical events. The user making the API call will
76+
need to have admin privileges, and the application will need to have the
77+
scope `manage enterprise properties` checked.
78+
79+
This operation is performed by calling function `getEvents`.
80+
81+
See the endpoint docs at
82+
[API Reference](https://developer.box.com/reference/get-events/).
83+
84+
<!-- sample get_events -->
85+
86+
```ts
87+
await client.events.getEvents({
88+
streamType: 'admin_logs' as GetEventsQueryParamsStreamTypeField,
89+
limit: 1,
90+
createdAfter: createdAfterDate,
91+
createdBefore: createdBeforeDate,
92+
} satisfies GetEventsQueryParams);
93+
```
94+
95+
### Arguments
96+
97+
- queryParams `GetEventsQueryParams`
98+
- Query parameters of getEvents method
99+
- headersInput `GetEventsHeadersInput`
100+
- Headers of getEvents method
101+
- cancellationToken `undefined | CancellationToken`
102+
- Token used for request cancellation.
103+
104+
### Returns
105+
106+
This function returns a value of type `Events`.
107+
108+
Returns a list of event objects.
109+
110+
Events objects are returned in pages, with each page (chunk)
111+
including a list of event objects. The response includes a
112+
`chunk_size` parameter indicating how many events were returned in this
113+
chunk, as well as the next `stream_position` that can be
114+
queried.

docs/fileVersions.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
- [List all file versions](#list-all-file-versions)
44
- [Get file version](#get-file-version)
5-
- [Restore file version](#restore-file-version)
65
- [Remove file version](#remove-file-version)
6+
- [Restore file version](#restore-file-version)
77
- [Promote file version](#promote-file-version)
88

99
## List all file versions
@@ -76,67 +76,67 @@ Not all available fields are returned by default. Use the
7676
[fields](#param-fields) query parameter to explicitly request
7777
any specific fields.
7878

79-
## Restore file version
79+
## Remove file version
8080

81-
Restores a specific version of a file after it was deleted.
82-
Don't use this endpoint to restore Box Notes,
83-
as it works with file formats such as PDF, DOC,
84-
PPTX or similar.
81+
Move a file version to the trash.
8582

86-
This operation is performed by calling function `updateFileVersionById`.
83+
Versions are only tracked for Box users with premium accounts.
84+
85+
This operation is performed by calling function `deleteFileVersionById`.
8786

8887
See the endpoint docs at
89-
[API Reference](https://developer.box.com/reference/put-files-id-versions-id/).
88+
[API Reference](https://developer.box.com/reference/delete-files-id-versions-id/).
9089

91-
_Currently we don't have an example for calling `updateFileVersionById` in integration tests_
90+
<!-- sample delete_files_id_versions_id -->
91+
92+
```ts
93+
await client.fileVersions.deleteFileVersionById(file.id, fileVersion.id);
94+
```
9295

9396
### Arguments
9497

9598
- fileId `string`
9699
- The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345"
97100
- fileVersionId `string`
98101
- The ID of the file version Example: "1234"
99-
- optionalsInput `UpdateFileVersionByIdOptionalsInput`
102+
- optionalsInput `DeleteFileVersionByIdOptionalsInput`
100103
-
101104

102105
### Returns
103106

104-
This function returns a value of type `FileVersionFull`.
105-
106-
Returns a restored file version object.
107+
This function returns a value of type `undefined`.
107108

108-
## Remove file version
109+
Returns an empty response when the file has been successfully
110+
deleted.
109111

110-
Move a file version to the trash.
112+
## Restore file version
111113

112-
Versions are only tracked for Box users with premium accounts.
114+
Restores a specific version of a file after it was deleted.
115+
Don't use this endpoint to restore Box Notes,
116+
as it works with file formats such as PDF, DOC,
117+
PPTX or similar.
113118

114-
This operation is performed by calling function `deleteFileVersionById`.
119+
This operation is performed by calling function `updateFileVersionById`.
115120

116121
See the endpoint docs at
117-
[API Reference](https://developer.box.com/reference/delete-files-id-versions-id/).
118-
119-
<!-- sample delete_files_id_versions_id -->
122+
[API Reference](https://developer.box.com/reference/put-files-id-versions-id/).
120123

121-
```ts
122-
await client.fileVersions.deleteFileVersionById(file.id, fileVersion.id);
123-
```
124+
_Currently we don't have an example for calling `updateFileVersionById` in integration tests_
124125

125126
### Arguments
126127

127128
- fileId `string`
128129
- The unique identifier that represents a file. The ID for any file can be determined by visiting a file in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the `file_id` is `123`. Example: "12345"
129130
- fileVersionId `string`
130131
- The ID of the file version Example: "1234"
131-
- optionalsInput `DeleteFileVersionByIdOptionalsInput`
132+
- optionalsInput `UpdateFileVersionByIdOptionalsInput`
132133
-
133134

134135
### Returns
135136

136-
This function returns a value of type `undefined`.
137+
This function returns a value of type `FileVersionFull`.
137138

138-
Returns an empty response when the file has been successfully
139-
deleted.
139+
Returns a restored file version object.
140140

141141
## Promote file version
142142

docs/shieldInformationBarrierSegments.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# ShieldInformationBarrierSegmentsManager
22

33
- [Get shield information barrier segment with specified ID](#get-shield-information-barrier-segment-with-specified-id)
4-
- [Update shield information barrier segment with specified ID](#update-shield-information-barrier-segment-with-specified-id)
54
- [Delete shield information barrier segment](#delete-shield-information-barrier-segment)
5+
- [Update shield information barrier segment with specified ID](#update-shield-information-barrier-segment-with-specified-id)
66
- [List shield information barrier segments](#list-shield-information-barrier-segments)
77
- [Create shield information barrier segment](#create-shield-information-barrier-segment)
88

@@ -36,71 +36,71 @@ This function returns a value of type `ShieldInformationBarrierSegment`.
3636

3737
Returns the shield information barrier segment object.
3838

39-
## Update shield information barrier segment with specified ID
39+
## Delete shield information barrier segment
4040

41-
Updates the shield information barrier segment based on provided ID..
41+
Deletes the shield information barrier segment
42+
based on provided ID.
4243

43-
This operation is performed by calling function `updateShieldInformationBarrierSegmentById`.
44+
This operation is performed by calling function `deleteShieldInformationBarrierSegmentById`.
4445

4546
See the endpoint docs at
46-
[API Reference](https://developer.box.com/reference/put-shield-information-barrier-segments-id/).
47+
[API Reference](https://developer.box.com/reference/delete-shield-information-barrier-segments-id/).
4748

48-
<!-- sample put_shield_information_barrier_segments_id -->
49+
<!-- sample delete_shield_information_barrier_segments_id -->
4950

5051
```ts
51-
await client.shieldInformationBarrierSegments.updateShieldInformationBarrierSegmentById(
52-
segmentId,
53-
{
54-
requestBody: {
55-
description: updatedSegmentDescription,
56-
} satisfies UpdateShieldInformationBarrierSegmentByIdRequestBody,
57-
} satisfies UpdateShieldInformationBarrierSegmentByIdOptionalsInput
52+
await client.shieldInformationBarrierSegments.deleteShieldInformationBarrierSegmentById(
53+
segment.id!
5854
);
5955
```
6056

6157
### Arguments
6258

6359
- shieldInformationBarrierSegmentId `string`
6460
- The ID of the shield information barrier segment. Example: "3423"
65-
- optionalsInput `UpdateShieldInformationBarrierSegmentByIdOptionalsInput`
61+
- optionalsInput `DeleteShieldInformationBarrierSegmentByIdOptionalsInput`
6662
-
6763

6864
### Returns
6965

70-
This function returns a value of type `ShieldInformationBarrierSegment`.
66+
This function returns a value of type `undefined`.
7167

72-
Returns the updated shield information barrier segment object.
68+
Empty body in response
7369

74-
## Delete shield information barrier segment
70+
## Update shield information barrier segment with specified ID
7571

76-
Deletes the shield information barrier segment
77-
based on provided ID.
72+
Updates the shield information barrier segment based on provided ID..
7873

79-
This operation is performed by calling function `deleteShieldInformationBarrierSegmentById`.
74+
This operation is performed by calling function `updateShieldInformationBarrierSegmentById`.
8075

8176
See the endpoint docs at
82-
[API Reference](https://developer.box.com/reference/delete-shield-information-barrier-segments-id/).
77+
[API Reference](https://developer.box.com/reference/put-shield-information-barrier-segments-id/).
8378

84-
<!-- sample delete_shield_information_barrier_segments_id -->
79+
<!-- sample put_shield_information_barrier_segments_id -->
8580

8681
```ts
87-
await client.shieldInformationBarrierSegments.deleteShieldInformationBarrierSegmentById(
88-
segment.id!
82+
await client.shieldInformationBarrierSegments.updateShieldInformationBarrierSegmentById(
83+
segmentId,
84+
{
85+
requestBody: {
86+
description: updatedSegmentDescription,
87+
} satisfies UpdateShieldInformationBarrierSegmentByIdRequestBody,
88+
} satisfies UpdateShieldInformationBarrierSegmentByIdOptionalsInput
8989
);
9090
```
9191

9292
### Arguments
9393

9494
- shieldInformationBarrierSegmentId `string`
9595
- The ID of the shield information barrier segment. Example: "3423"
96-
- optionalsInput `DeleteShieldInformationBarrierSegmentByIdOptionalsInput`
96+
- optionalsInput `UpdateShieldInformationBarrierSegmentByIdOptionalsInput`
9797
-
9898

9999
### Returns
100100

101-
This function returns a value of type `undefined`.
101+
This function returns a value of type `ShieldInformationBarrierSegment`.
102102

103-
Empty body in response
103+
Returns the updated shield information barrier segment object.
104104

105105
## List shield information barrier segments
106106

package-lock.json

Lines changed: 3 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "box-typescript-sdk-gen",
33
"author": "Box <[email protected]>",
44
"version": "1.5.1",
5-
"description": "[Box Platform](https://box.dev) provides functionality to provide access to content stored within [Box](https://box.com). It provides endpoints for basic manipulation of files and folders, management of users within an enterprise, as well as more complex topics such as legal holds and retention policies.",
5+
"description": "Official Box TypeScript Generated SDK",
66
"keywords": [
77
"box",
88
"sdk",
@@ -20,7 +20,6 @@
2020
"start": "echo \"Error: no start specified\" && exit 1",
2121
"test": "jest"
2222
},
23-
"license": "Apache-2.0",
2423
"repository": {
2524
"type": "git",
2625
"url": "https://github.com/box/box-typescript-sdk-gen.git"

0 commit comments

Comments
 (0)