Skip to content

Commit

Permalink
Merge branch 'main' into delete-calls-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziine authored Jul 22, 2024
2 parents 5554b03 + cca2c04 commit 9536e85
Show file tree
Hide file tree
Showing 27 changed files with 5,644 additions and 1,807 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ MAKEFLAGS += -j$(NPROCS)

CURRENT_VERSION_MAJOR = 1
CURRENT_VERSION_MINOR = 19
CURRENT_VERSION_BUG = 0
CURRENT_VERSION_BUG = 4

GIT_DESCRIBE := $(shell git describe)
GITHUB_HEAD_REF ?= $(shell git branch --show-current)
Expand Down
49 changes: 49 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/async-tasks.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// Example of monitoring the status of an async task
// The logic is same for all async tasks
const response = await client.<async operation>();

// you need to poll this endpoint
const taskResponse = await client.getTaskStatus({id: response.task_id})

console.log(taskResponse.status === 'completed');
```

</TabItem>
<TabItem value="py" label="Python">

```py
# Example of monitoring the status of an async task
# The logic is same for all async tasks
response = client.<async operation>()
task_id = response.data.task_id

# get information about the task
task_status = client.get_task(task_id)

# just an example, in reality it can take a few seconds for a task to be processed
if task_status.data.status == "completed":
print(task_status.data.result)
```

</TabItem>

<TabItem value="curl" label="cURL">

```bash
# When an operation is async, a task_id will be included in the API response
# That task_id can be used to monitor the status of the task
# When finished, task status will be completed
curl -X GET https://video.stream-io-api.com/api/v2/tasks/${TASK_ID}?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
```

</TabItem>
</Tabs>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import AsyncTasks from '../_common_/async-tasks.mdx';

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">
Expand All @@ -18,11 +19,6 @@ client.reactivateUsers({
const deactivateResponse = client.deactivateUsers({
user_ids: ['<id1>', '<id2>'...],
});

// you need to poll this endpoint
const taskResponse = await client.getTaskStatus({id: deactivateResponse.task_id})

console.log(taskResponse.status === 'completed');
```

</TabItem>
Expand All @@ -37,14 +33,6 @@ client.reactivate_user(user_id=alice.id)

# deactivates users in bulk, this is an async operation
response = client.deactivate_users(user_ids=[alice.id, bob.id])
task_id = response.data.task_id

# get information about the task
task_status = client.get_task(task_id)

# just an example, in reality it can take a few seconds for a task to be processed
if task_status.data.status == "completed":
print(task_status.data.result)
```

</TabItem>
Expand All @@ -62,20 +50,20 @@ curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${A
}'

# Reactivate users
curl -X POST https://video.stream-io-api.com/api/v2/users/deactivate?api_key=${API_KEY} \
curl -X POST https://video.stream-io-api.com/api/v2/users/reactivate?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Reactivate users in bulk can take some time, you can poll task status using the task id from the response
# When finished, task status will be completed
curl -X GET https://video.stream-io-api.com/api/v2/tasks/${TASK_ID}?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt"
```

</TabItem>
</Tabs>

Deactivating users in bulk can take some time, this is how you can check the progress:

<AsyncTasks />

For more informiation, please refer to the [async operations guide](/api/misc/async)
71 changes: 71 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import AsyncTasks from '../_common_/async-tasks.mdx';

Deleting a user means:

- the user can't connect to Stream API
- their data won't appear in user queries

Delete has the following opitions:

| Name | Type | Description | Optional |
| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `user` | Enum (soft, pruning, hard) | - Soft: marks user as deleted and retains all user data. <br /> - Pruning: marks user as deleted and nullifies user information. <br /> - Hard: deletes user completely - this requires hard option for messages and conversation as well. | Yes |
| `conversations` | Enum (soft, hard) | - Soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled). <br /> - Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with 'hard' option enabled). | Yes |
| `messages` | Enum (soft, pruning, hard) | - Soft: marks all user messages as deleted without removing any related message data. <br /> - Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags. <br /> - Hard: deletes messages completely with all related information. | Yes |
| `new_channel_owner_id` | string | Channels owned by hard-deleted users will be transferred to this userID. If you doesn't provide a value, the channel owner will have a system generated ID like `delete-user-8219f6578a7395g` | Yes |
| `calls` | Enum (soft, hard) | - Soft: marks calls and related data as deleted. <br /> - Hard: deletes calls and related data completely <br /> Note that this applies only to 1:1 calls, not group calls | Yes |

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.deleteUsers({ user_ids: ['<id>'] });

//restore
client.restoreUsers({ user_ids: ['<id>'] });
```

</TabItem>

<TabItem value="py" label="Python">

```py
client.delete_users(user_ids=["<id>"])

# restore
client.restore_users(user_ids=["<id>"])
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
# Delete users
curl -X POST https://video.stream-io-api.com/api/v2/users/delete?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Restore users
curl -X POST https://video.stream-io-api.com/api/v2/users/restore?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'
```

</TabItem>
</Tabs>

Deleting and restoring users in bulk can take some time, this is how you can check the progress:

<AsyncTasks />

For more informiation, please refer to the [async operations guide](/api/misc/async)
68 changes: 5 additions & 63 deletions docusaurus/video/docusaurus/docs/api/basics/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ title: Users & Tokens
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import DeactivateReactivate from '../_common_/deactivate-reactivate.mdx';
import DeleteUsers from '../_common_/delete-users.mdx';

## Creating users

Expand All @@ -21,7 +22,7 @@ You can provide additional data for the user object using the `custom` field.
<TabItem value="js" label="JavaScript">

```js
const newUser: UserObjectRequest = {
const newUser: UserRequest = {
id: 'userid',
role: 'user',
custom: {
Expand Down Expand Up @@ -91,7 +92,7 @@ There are two ways to update user objects:
<TabItem value="js" label="JavaScript">

```js
const user: UserObjectRequest = {
const user: UserRequest = {
id: 'userid',
role: 'user',
custom: {
Expand Down Expand Up @@ -210,69 +211,10 @@ Deactivating a user means:
- their data will be retained
- a deactivated user can be reactivated

Deleting a user means:

- the user can't connect to Stream API
- their data won't appear in user queries

Delete has the following opitions:

| Name | Type | Description | Optional |
| ---------------------- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- |
| `user` | Enum (soft, pruning, hard) | - Soft: marks user as deleted and retains all user data. <br /> - Pruning: marks user as deleted and nullifies user information. <br /> - Hard: deletes user completely - this requires hard option for messages and conversation as well. | Yes |
| `conversations` | Enum (soft, hard) | - Soft: marks all conversation channels as deleted (same effect as Delete Channels with 'hard' option disabled). <br /> - Hard: deletes channel and all its data completely including messages (same effect as Delete Channels with 'hard' option enabled). | Yes |
| `messages` | Enum (soft, pruning, hard) | - Soft: marks all user messages as deleted without removing any related message data. <br /> - Pruning: marks all user messages as deleted, nullifies message information and removes some message data such as reactions and flags. <br /> - Hard: deletes messages completely with all related information. | Yes |
| `new_channel_owner_id` | string | Channels owned by hard-deleted users will be transferred to this userID. If you doesn't provide a value, the channel owner will have a system generated ID like `delete-user-8219f6578a7395g` | Yes |

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.deleteUsers({ user_ids: ['<id>'] });

//restore
client.restoreUsers({ user_ids: ['<id>'] });
```

</TabItem>

<TabItem value="py" label="Python">

```py
client.delete_users(user_ids=["<id>"])

# restore
client.restore_users(user_ids=["<id>"])
```

</TabItem>
<TabItem value="curl" label="cURL">

```bash
# Delete users
curl -X POST https://video.stream-io-api.com/api/v2/users/delete?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'

# Restore users
curl -X POST https://video.stream-io-api.com/api/v2/users/restore?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H "Content-Type: application/json" \
-d '{
"user_ids": ["sara"]
}'
```

</TabItem>
</Tabs>

<DeactivateReactivate />

<DeleteUsers />

## User tokens

Stream uses JWT (JSON Web Tokens) to authenticate chat users, enabling them to log in. Knowing whether a user is authorized to perform certain actions is managed separately via a role-based permissions system. Tokens need to be generated server-side.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Tokens need to be generated server-side. Typically, you integrate this into the

```js
const userId = 'john';
const newUser: UserObjectRequest = {
const newUser: UserRequest = {
id: userId,
role: 'user',
custom: {
Expand Down
56 changes: 10 additions & 46 deletions docusaurus/video/docusaurus/docs/api/gdpr/users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ title: Users

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

import DeleteUsers from '../_common_/delete-users.mdx';
import AsyncTasks from '../_common_/async-tasks.mdx';

## Users export

Expand All @@ -17,35 +18,23 @@ _This endpoint requires a server-side authentication._

:::

Stream allows you to export users with their data, including the calls they participated in.
The operation is performed asynchronously, so calling this endpoint will return a task ID that you can use to [monitor the execution of the export](../../misc/async).

Once the task is completed, the result of the `GetTask` endpoint call will contain a URL to the file.
Stream allows you to export users with their data, including the calls they participated in.

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// export users
let resp = await client.exportUsers([userid1,userid2]);
// resp.task_id is the ID to be used for monitoring the task

// when the export is done and the task is completed, an URL is returned to have access to the file
resp = await client.get_task(resp.task_id)
console.log(resp)
// output:
{
"task_id": "123",
"status": "completed",
"result": {
"url": https://link/to/file.json'
}
}
await client.exportUsers({ user_ids: ['<user id1>', '<user id1>'] });
```

</TabItem>
</Tabs>

Exporting users can take some time, this is how you can check the progress:

<AsyncTasks />

For more informiation, please refer to the [async operations guide](/api/misc/async)

## Users deletion

Expand All @@ -58,29 +47,4 @@ _This endpoint requires a server-side authentication._
Stream allows you to delete users and optionally the calls they were part of.
Note that this apply only to 1:1 calls, not group calls.

This operation is done asynchronously and you can use the returned `task_id` to monitor its progress.
See [how to monitor an async task](../../misc/async).

Deleting a user accepts some parameters

| param | type | description | required |
|----------|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
| user_ids | array | List of users who will be deleted ||
| user | enum (soft, pruning, hard) | **Soft:** marks user as deleted and retains all user data. (default) **Pruning:** marks user as deleted and nullifies user information. **Hard:** deletes user completely | |
| calls | enum (soft, hard) | **Soft:** marks calls and related data as deleted. **Hard:** deletes calls and related data completely | |


<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
// hard delete users
let resp = await client.deleteUsers([userid1,userid2], { user: 'hard' });
// resp.task_id is the ID to be used for monitoring the task

// hard delete users and soft delete calls
resp = await client.deleteUsers([userid1,userid2], { user: 'hard', calls: 'soft' });
// resp.task_id is the ID to be used for monitoring the task
```
</TabItem>
</Tabs>
<DeleteUsers />
Loading

0 comments on commit 9536e85

Please sign in to comment.