Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go serverside SDK docs #746

Merged
merged 32 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
895583d
go docs wip
sachaarbonel Sep 18, 2024
f3723af
broadcast RTMPSettingsRequest calltype
sachaarbonel Sep 18, 2024
6c967a8
broadcasting
sachaarbonel Sep 18, 2024
b062cd8
custom events
sachaarbonel Sep 18, 2024
ee2c3ce
deactivate user
sachaarbonel Sep 18, 2024
f75bbda
delete users
sachaarbonel Sep 18, 2024
3d64b42
go live
sachaarbonel Sep 18, 2024
81f3fe3
UpdateCallMembers
sachaarbonel Sep 18, 2024
af0c6c0
StartRTMPBroadcasts
sachaarbonel Sep 18, 2024
fb0a752
StopAllRTMPBroadcasts
sachaarbonel Sep 18, 2024
c8fd111
StopRTMPBroadcast
sachaarbonel Sep 18, 2024
c835046
rtmp
sachaarbonel Sep 18, 2024
811b6a0
storage
sachaarbonel Sep 18, 2024
643dcc3
update call
sachaarbonel Sep 18, 2024
8296e4e
auth
sachaarbonel Sep 18, 2024
bc5bc35
calls
sachaarbonel Sep 19, 2024
44c8bb7
multi tenant
sachaarbonel Sep 19, 2024
5f0afa9
geofencing
sachaarbonel Sep 19, 2024
2d3ade3
manage types
sachaarbonel Sep 19, 2024
ff4b33f
permissions
sachaarbonel Sep 19, 2024
1dd6948
settings
sachaarbonel Sep 19, 2024
c9274f9
moderation wip
sachaarbonel Sep 19, 2024
c1befb9
recording calls
sachaarbonel Sep 19, 2024
d576988
backstage
sachaarbonel Sep 20, 2024
fff9bd7
hls
sachaarbonel Sep 20, 2024
cce617b
streaming overview
sachaarbonel Sep 20, 2024
110dea2
rtmp broadcast
sachaarbonel Sep 20, 2024
63f515c
transcription
sachaarbonel Sep 20, 2024
3989e7d
fix rendering
sachaarbonel Sep 20, 2024
aa9df36
Merge branch 'main' into go-sdk-docs
sachaarbonel Sep 20, 2024
77c5f5c
Merge branch 'main' into go-sdk-docs
tbarbugli Oct 4, 2024
57563dd
improve go docs
tbarbugli Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/broadcast.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ call.start_hls_broadcasting()
call.stop_hls_broadcasting()
```

</TabItem>
<TabItem value="go" label="Golang">

```go
call.StartHLSBroadcasting(ctx)
// to end broadcasting
call.StopHLSBroadcasting(ctx)
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,27 @@ client.video.update_call_type(

</TabItem>

<TabItem value="go" label="Golang">

```go
response, err := client.Video().UpdateCallType(ctx, callTypeName, &UpdateCallTypeRequest{
Settings: &CallSettingsRequest{
Broadcasting: &BroadcastSettingsRequest{
Enabled: PtrTo(true),
Rtmp: &RTMPSettingsRequest{
Enabled: PtrTo(true),
Quality: PtrTo("1080p"),
Layout: &LayoutSettingsRequest{
Name: "spotlight",
},
},
},
},
})
```

</TabItem>

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

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Call types provide sensible default settings for different use-cases. We provide
- **Default** (`default`) for 1:1 or group calls that use both video and audio
- **Livestreaming** (`livestream`) to build ultra low latency livestreaming for your app on our global edge network. Broadcast from your phone or RTMP and scale to millions of participants.
- **Audio room** (`audio_room`) to build audio experiences for your app. You can build basic calling or feature rich experience like Twitter spaces. Audio quality, reliability and scalability is far ahead of competing solutions.
- **Development** (`development`) This call type comes with almost all permission settings disabled so that it is simpler to get your initial implementation up and running. You should only use this call type early-on during development.

Each of our [SDKs have tutorials specific for each call type](https://getstream.io/video/sdk/). If you want to know the default settings for each of the call types check out the [Built-in call types page](/api/call_types/builtin).

Expand Down
33 changes: 32 additions & 1 deletion docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import TabItem from '@theme/TabItem';
You can create a call by providing the call type and an ID:

- The [call type](/api/call_types/builtin) controls which features are enabled and sets up permissions. Call type settings and permissions can be set from API, or using the [Stream Dashboard](https://dashboard.getstream.io/).
- Calls IDs can be reused, which means they can be joined multiple times, so it's possible to set up recurring calls.
- Calls can be used once or multiple times depending on your app. Unless you want to re-use the same call multiple times, the recommended way to pick a call ID is to use a uuid v4 so that each call gets a unique random ID.

You can specify call members who can receive push notification about the call.

Expand Down Expand Up @@ -66,6 +66,37 @@ call.create(

</TabItem>

<TabItem value="go" label="Golang">

```go

import (
"github.com/GetStream/getstream-go"
"github.com/google/uuid"
)

call := client.Video().Call("default", uuid.NewString())

members := []getstream.MemberRequest{
{UserID: "john", Role: getstream.PtrTo("admin")},
{UserID: "jack"},
}

callRequest := getstream.GetOrCreateCallRequest{
Data: &getstream.CallRequest{
CreatedByID: getstream.PtrTo("sacha"),
Members: members,
Custom: map[string]any{
"color": "blue",
},
},
}

response, err := call.GetOrCreate(ctx, &callRequest)
```

</TabItem>

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

```bash
Expand Down
14 changes: 14 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/custom-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ call.sendCallEvent({
call.send_call_event(user_id=user.id, custom={"render-animation": "balloons"})
```

</TabItem>

<TabItem value="go" label="Golang">

```go
// send a custom event to all users watching the call
call.SendCallEvent(ctx, &SendCallEventRequest{
Custom: &map[string]interface{}{
"render-animation": "balloons",
},
UserID: PtrTo("john"),
})
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ client.deactivateUser({
user_id: '<id>',
});

//reactivate
// reactivate
client.reactivateUsers({
user_ids: ['<id>'],
});

// deactivativating users in bulk can take some time
// deactivating users in bulk is performed asynchronously
const deactivateResponse = client.deactivateUsers({
user_ids: ['<id1>', '<id2>'...],
});
Expand All @@ -31,12 +31,29 @@ client.deactivate_user(user_id=alice.id)
# reactivates the user
client.reactivate_user(user_id=alice.id)

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

</TabItem>

<TabItem value="go" label="Golang">

```go
// deactivate one user
response, err := client.DeactivateUser(ctx, "alice", &getstream.DeactivateUserRequest{})

// reactivates the user
_, err = client.ReactivateUser(ctx, "alice", &getstream.ReactivateUserRequest{})

// deactivates users in bulk, this is an async operation
_, err = client.DeactivateUsers(ctx, &getstream.DeactivateUsersRequest{
UserIds: []string{"alice", "bob"},
})
```

</TabItem>

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

```bash
Expand Down Expand Up @@ -66,4 +83,4 @@ Deactivating users in bulk can take some time, this is how you can check the pro

<AsyncTasks />

For more informiation, please refer to the [async operations guide](/api/misc/async)
For more information, please refer to the [async operations guide](/api/misc/async)
37 changes: 22 additions & 15 deletions docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,6 @@ 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">
Expand All @@ -38,6 +24,17 @@ client.delete_users(user_ids=["<id>"])
client.restore_users(user_ids=["<id>"])
```

</TabItem>

<TabItem value="go" label="Golang">

```go
response, err := client.DeleteUsers(ctx, &getstream.DeleteUsersRequest{UserIds: []string{"<id>"}})

// restore a soft-deleted user
_, err = client.RestoreUsers(ctx, &getstream.RestoreUsersRequest{UserIds: []string{"<id>"}})
```

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

Expand All @@ -64,8 +61,18 @@ curl -X POST https://video.stream-io-api.com/api/v2/users/restore?api_key=${API_
</TabItem>
</Tabs>

The delete users endpoints supports the following parameters to control which data needs to be deleted and how. By default users and their data are soft-deleted.

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

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)
For more information, please refer to the [async operations guide](/api/misc/async)
11 changes: 11 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/go_live.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ call.go_live(start_hls=True, start_recording=True)

</TabItem>

<TabItem value="go" label="Golang">

```go
call.GoLive(ctx, &GoLiveRequest{
StartHls: PtrTo(true),
StartRecording: PtrTo(true),
})
```
</TabItem>


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

```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You can provide a list of call members. Call members need to be existing users. Every call member has a call-level role, [you can configure roles](/api/call_types/permissions/) on the call type.
You can provide a list of call members, this can be done when you create a call or later on when the call already exists. Please note that call members need to be existing users.

Call members can receive [push notifications](/api/call_types/settings/#push-notifications-settings).
There are two reasons to use call members:

- Call membership allows you to have more flexibility when it comes to permissions. The permission system allows you to grant different permissions to users and members, this way one user can be a member on one call or a member on another.
Membership also allows you to specify a role for user in a call. You can more information about the roles and permissions [here](/api/call_types/permissions/).
- Call members will receive [push notifications](/api/call_types/settings/#push-notifications-settings).

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">
Expand Down Expand Up @@ -31,6 +35,20 @@ call.update_call_members(
)
```

</TabItem>
<TabItem value="go" label="Golang">

```go
// Call members need to be existing users (use `client.UpdateUsers` for that)
// You can also update the role of existing members
response, err := call.UpdateCallMembers(ctx, &getstream.UpdateCallMembersRequest{
UpdateMembers: []getstream.MemberRequest{
{UserID: "sara"},
{UserID: "emily", Role: getstream.PtrTo("admin")},
},
})
```

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

Expand Down Expand Up @@ -66,7 +84,18 @@ call.updateCallMembers({
<TabItem value="py" label="Python">

```py
call.update_call_members(remove_members=["jack", "sara"])
call.update_call_members(remove_members=["sara"])
```

</TabItem>
<TabItem value="go" label="Golang">

```go
response, err := call.UpdateCallMembers(ctx, &getstream.UpdateCallMembersRequest{
RemoveMembers: []string{
"sara",
},
})
```

</TabItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ call.start_rtmp_broadcasts(
)
```

</TabItem>
<TabItem value="go" label="Golang">

```go
call.StartRTMPBroadcasts(ctx, &StartRTMPBroadcastsRequest{
Broadcasts: []RTMPBroadcastRequest{
{
Name: "youtube_channel",
StreamUrl: "rtmps://x.rtmps.youtube.com/live2",
StreamKey: PtrTo("your_stream_key"),
},
},
})
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ call.stopAllRTMPBroadcasts();
call.stop_all_rtmp_broadcasts()
```

</TabItem>
<TabItem value="go" label="Golang">

```go
call.StopAllRTMPBroadcasts(ctx)
```

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ call.stopRTMPBroadcast("youtube_channel");
call.stop_rtmp_broadcast(name='youtube_channel')
```

</TabItem>

<TabItem value="go" label="Golang">

```go
call.StopRTMPBroadcast(ctx, "youtube_channel", &StopRTMPBroadcastsRequest{})
```

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

Expand Down
25 changes: 25 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/rtmp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ rtmp_url = response.data.call.ingress.rtmp.address
print(rtmp_url, stream_key)
```

</TabItem>
<TabItem value="go" label="Golang">

```go
call := client.Video().Call("default", uuid.New().String())
// create the call where the RTMP will be sent to
response, err := call.GetOrCreate(ctx, nil)

// ensure we have a user for the host to send video via RTMP
client.UpdateUsers(ctx, &UpdateUsersRequest{
Users: map[string]UserRequest{
"tommaso-the-host": {
ID: "tommaso-the-host",
},
},
})

// create a token for the user sending video, this can be used as the stream key
expiration := time.Now().Add(1 * time.Hour)
streamKey, err := client.CreateToken("tommaso-the-host", &StreamJWTClaims{Expire: &expiration})

rtmpURL := response.Data.Call.Ingress.Rtmp.Address
fmt.Println("RTMP URL:", rtmpURL, "Stream Key:", streamKey)
```

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

Expand Down
Loading
Loading