Skip to content

Commit

Permalink
Merge branch 'pbe-5141-rtmp-public-docs' of github.com:GetStream/prot…
Browse files Browse the repository at this point in the history
…ocol into pbe-5141-rtmp-public-docs
  • Loading branch information
Bruno Ribeiro authored and Bruno Ribeiro committed Jul 29, 2024
2 parents d877a0c + 41ec9bc commit 5ba71b6
Show file tree
Hide file tree
Showing 39 changed files with 13,803 additions and 3,575 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ MAKEFLAGS += --no-builtin-rules
MAKEFLAGS += -j$(NPROCS)

CURRENT_VERSION_MAJOR = 1
CURRENT_VERSION_MINOR = 16
CURRENT_VERSION_BUG = 0
CURRENT_VERSION_MINOR = 19
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>
40 changes: 40 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/custom-events.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

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

```js
// send a custom event to all users watching the call
call.sendCustomEvent({
custom: {
'render-animation': 'balloons',
},
user_id: 'john',
});
```

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

```py
# send a custom event to all users watching the call
call.send_call_event(user_id=user.id, custom={"render-animation": "balloons"})
```

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

```bash
curl -X POST https://video.stream-io-api.com/api/v2/video/call/${CALL_TYPE}/${CALL_ID}/event?api_key=${API_KEY} \
-H "Authorization: ${TOKEN}" \
-H "stream-auth-type: jwt" \
-H 'Content-Type: application/json' \
-d '{
"custom": {"render-animation": "balloons"},
"user_id": "john"
}'
```

</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
Loading

0 comments on commit 5ba71b6

Please sign in to comment.