Skip to content

Commit

Permalink
feat: Add support for proxy (box/box-codegen#559) (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
box-sdk-build authored Sep 11, 2024
1 parent f83807c commit 0ffd9c8
Show file tree
Hide file tree
Showing 15 changed files with 592 additions and 512 deletions.
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "edc49a6", "specHash": "6ca858e", "version": "1.5.1" }
{ "engineHash": "5d1b305", "specHash": "6ca858e", "version": "1.5.1" }
19 changes: 19 additions & 0 deletions docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@ divided across resource managers.
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Client](#client)
- [Additional headers](#additional-headers)
- [As-User header](#as-user-header)
- [Suppress notifications](#suppress-notifications)
- [Custom headers](#custom-headers)
- [Custom Base URLs](#custom-base-urls)
- [Custom Agent Options](#custom-agent-options)
- [Interceptors](#interceptors)
- [Use Proxy for API calls](#use-proxy-for-api-calls)

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

Expand Down Expand Up @@ -129,3 +132,19 @@ const clientWithInterceptor: BoxClient = client.withInterceptors([
},
]);
```

# Use Proxy for API calls

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.

If both custom agent options and proxy are provided, the proxy will take precedence.

**Note:** We are only supporting http/s proxies with basic authentication. NTLM and other authentication methods are not supported.

```js
newClient = client.withProxy({
url: 'http://127.0.0.1:1234/',
username: 'user',
password: 'password',
});
```
100 changes: 50 additions & 50 deletions docs/events.md
Original file line number Diff line number Diff line change
@@ -1,56 +1,7 @@
# EventsManager

- [List user and enterprise events](#list-user-and-enterprise-events)
- [Get events long poll endpoint](#get-events-long-poll-endpoint)

## List user and enterprise events

Returns up to a year of past events for a given user
or for the entire enterprise.

By default this returns events for the authenticated user. To retrieve events
for the entire enterprise, set the `stream_type` to `admin_logs_streaming`
for live monitoring of new events, or `admin_logs` for querying across
historical events. The user making the API call will
need to have admin privileges, and the application will need to have the
scope `manage enterprise properties` checked.

This operation is performed by calling function `getEvents`.

See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-events/).

<!-- sample get_events -->

```ts
await client.events.getEvents({
streamType: 'admin_logs' as GetEventsQueryParamsStreamTypeField,
limit: 1,
createdAfter: createdAfterDate,
createdBefore: createdBeforeDate,
} satisfies GetEventsQueryParams);
```

### Arguments

- queryParams `GetEventsQueryParams`
- Query parameters of getEvents method
- headersInput `GetEventsHeadersInput`
- Headers of getEvents method
- cancellationToken `undefined | CancellationToken`
- Token used for request cancellation.

### Returns

This function returns a value of type `Events`.

Returns a list of event objects.

Events objects are returned in pages, with each page (chunk)
including a list of event objects. The response includes a
`chunk_size` parameter indicating how many events were returned in this
chunk, as well as the next `stream_position` that can be
queried.
- [List user and enterprise events](#list-user-and-enterprise-events)

## Get events long poll endpoint

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

Returns a paginated array of servers that can be used
instead of the regular endpoints for long-polling events.

## List user and enterprise events

Returns up to a year of past events for a given user
or for the entire enterprise.

By default this returns events for the authenticated user. To retrieve events
for the entire enterprise, set the `stream_type` to `admin_logs_streaming`
for live monitoring of new events, or `admin_logs` for querying across
historical events. The user making the API call will
need to have admin privileges, and the application will need to have the
scope `manage enterprise properties` checked.

This operation is performed by calling function `getEvents`.

See the endpoint docs at
[API Reference](https://developer.box.com/reference/get-events/).

<!-- sample get_events -->

```ts
await client.events.getEvents({
streamType: 'admin_logs' as GetEventsQueryParamsStreamTypeField,
limit: 1,
createdAfter: createdAfterDate,
createdBefore: createdBeforeDate,
} satisfies GetEventsQueryParams);
```

### Arguments

- queryParams `GetEventsQueryParams`
- Query parameters of getEvents method
- headersInput `GetEventsHeadersInput`
- Headers of getEvents method
- cancellationToken `undefined | CancellationToken`
- Token used for request cancellation.

### Returns

This function returns a value of type `Events`.

Returns a list of event objects.

Events objects are returned in pages, with each page (chunk)
including a list of event objects. The response includes a
`chunk_size` parameter indicating how many events were returned in this
chunk, as well as the next `stream_position` that can be
queried.
54 changes: 27 additions & 27 deletions docs/fileVersions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

- [List all file versions](#list-all-file-versions)
- [Get file version](#get-file-version)
- [Restore file version](#restore-file-version)
- [Remove file version](#remove-file-version)
- [Restore file version](#restore-file-version)
- [Promote file version](#promote-file-version)

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

## Restore file version
## Remove file version

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

This operation is performed by calling function `updateFileVersionById`.
Versions are only tracked for Box users with premium accounts.

This operation is performed by calling function `deleteFileVersionById`.

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

_Currently we don't have an example for calling `updateFileVersionById` in integration tests_
<!-- sample delete_files_id_versions_id -->

```ts
await client.fileVersions.deleteFileVersionById(file.id, fileVersion.id);
```

### Arguments

- fileId `string`
- 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"
- fileVersionId `string`
- The ID of the file version Example: "1234"
- optionalsInput `UpdateFileVersionByIdOptionalsInput`
- optionalsInput `DeleteFileVersionByIdOptionalsInput`
-

### Returns

This function returns a value of type `FileVersionFull`.

Returns a restored file version object.
This function returns a value of type `undefined`.

## Remove file version
Returns an empty response when the file has been successfully
deleted.

Move a file version to the trash.
## Restore file version

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

This operation is performed by calling function `deleteFileVersionById`.
This operation is performed by calling function `updateFileVersionById`.

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

<!-- sample delete_files_id_versions_id -->
[API Reference](https://developer.box.com/reference/put-files-id-versions-id/).

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

### Arguments

- fileId `string`
- 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"
- fileVersionId `string`
- The ID of the file version Example: "1234"
- optionalsInput `DeleteFileVersionByIdOptionalsInput`
- optionalsInput `UpdateFileVersionByIdOptionalsInput`
-

### Returns

This function returns a value of type `undefined`.
This function returns a value of type `FileVersionFull`.

Returns an empty response when the file has been successfully
deleted.
Returns a restored file version object.

## Promote file version

Expand Down
54 changes: 27 additions & 27 deletions docs/shieldInformationBarrierSegments.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# ShieldInformationBarrierSegmentsManager

- [Get shield information barrier segment with specified ID](#get-shield-information-barrier-segment-with-specified-id)
- [Update shield information barrier segment with specified ID](#update-shield-information-barrier-segment-with-specified-id)
- [Delete shield information barrier segment](#delete-shield-information-barrier-segment)
- [Update shield information barrier segment with specified ID](#update-shield-information-barrier-segment-with-specified-id)
- [List shield information barrier segments](#list-shield-information-barrier-segments)
- [Create shield information barrier segment](#create-shield-information-barrier-segment)

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

Returns the shield information barrier segment object.

## Update shield information barrier segment with specified ID
## Delete shield information barrier segment

Updates the shield information barrier segment based on provided ID..
Deletes the shield information barrier segment
based on provided ID.

This operation is performed by calling function `updateShieldInformationBarrierSegmentById`.
This operation is performed by calling function `deleteShieldInformationBarrierSegmentById`.

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

<!-- sample put_shield_information_barrier_segments_id -->
<!-- sample delete_shield_information_barrier_segments_id -->

```ts
await client.shieldInformationBarrierSegments.updateShieldInformationBarrierSegmentById(
segmentId,
{
requestBody: {
description: updatedSegmentDescription,
} satisfies UpdateShieldInformationBarrierSegmentByIdRequestBody,
} satisfies UpdateShieldInformationBarrierSegmentByIdOptionalsInput
await client.shieldInformationBarrierSegments.deleteShieldInformationBarrierSegmentById(
segment.id!
);
```

### Arguments

- shieldInformationBarrierSegmentId `string`
- The ID of the shield information barrier segment. Example: "3423"
- optionalsInput `UpdateShieldInformationBarrierSegmentByIdOptionalsInput`
- optionalsInput `DeleteShieldInformationBarrierSegmentByIdOptionalsInput`
-

### Returns

This function returns a value of type `ShieldInformationBarrierSegment`.
This function returns a value of type `undefined`.

Returns the updated shield information barrier segment object.
Empty body in response

## Delete shield information barrier segment
## Update shield information barrier segment with specified ID

Deletes the shield information barrier segment
based on provided ID.
Updates the shield information barrier segment based on provided ID..

This operation is performed by calling function `deleteShieldInformationBarrierSegmentById`.
This operation is performed by calling function `updateShieldInformationBarrierSegmentById`.

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

<!-- sample delete_shield_information_barrier_segments_id -->
<!-- sample put_shield_information_barrier_segments_id -->

```ts
await client.shieldInformationBarrierSegments.deleteShieldInformationBarrierSegmentById(
segment.id!
await client.shieldInformationBarrierSegments.updateShieldInformationBarrierSegmentById(
segmentId,
{
requestBody: {
description: updatedSegmentDescription,
} satisfies UpdateShieldInformationBarrierSegmentByIdRequestBody,
} satisfies UpdateShieldInformationBarrierSegmentByIdOptionalsInput
);
```

### Arguments

- shieldInformationBarrierSegmentId `string`
- The ID of the shield information barrier segment. Example: "3423"
- optionalsInput `DeleteShieldInformationBarrierSegmentByIdOptionalsInput`
- optionalsInput `UpdateShieldInformationBarrierSegmentByIdOptionalsInput`
-

### Returns

This function returns a value of type `undefined`.
This function returns a value of type `ShieldInformationBarrierSegment`.

Empty body in response
Returns the updated shield information barrier segment object.

## List shield information barrier segments

Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "box-typescript-sdk-gen",
"author": "Box <oss@box.com>",
"version": "1.5.1",
"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.",
"description": "Official Box TypeScript Generated SDK",
"keywords": [
"box",
"sdk",
Expand All @@ -20,7 +20,6 @@
"start": "echo \"Error: no start specified\" && exit 1",
"test": "jest"
},
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/box/box-typescript-sdk-gen.git"
Expand Down
Loading

0 comments on commit 0ffd9c8

Please sign in to comment.