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 30 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
21 changes: 21 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/create-call.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ call.create(

</TabItem>

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

```go
members := []MemberRequest{
{UserID: "john", Role: PtrTo("admin")},
{UserID: "jack"},
}
callRequest := GetOrCreateCallRequest{
Data: &CallRequest{
CreatedByID: PtrTo("sacha"),
Members: &members,
Custom: &map[string]any{
"color": "blue",
},
},
}
_, 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 @@ -37,6 +37,21 @@ response = client.deactivate_users(user_ids=[alice.id, bob.id])

</TabItem>

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

```go
// deactivate one user
client.DeactivateUser(ctx, alice.ID, &DeactivateUserRequest{})

// reactivates the user
client.ReactivateUser(ctx, alice.ID, &ReactivateUserRequest{})

// deactivates users in bulk, this is an async operation
response = client.DeactivateUsers(ctx, &DeactivateUsersRequest{UserIDs: []string{alice.ID, bob.ID}})
```

</TabItem>

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

```bash
Expand Down
11 changes: 11 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/delete-users.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ client.delete_users(user_ids=["<id>"])
client.restore_users(user_ids=["<id>"])
```

</TabItem>

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

```go
client.DeleteUsers(ctx, &DeleteUsersRequest{UserIDs: []string{"<id>"}})

# restore
client.RestoreUsers(ctx, &RestoreUsersRequest{UserIDs: []string{"<id>"}})
```

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

Expand Down
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
Expand Up @@ -31,6 +31,20 @@ call.update_call_members(
)
```

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

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

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

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
94 changes: 94 additions & 0 deletions docusaurus/video/docusaurus/docs/api/_common_/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,35 @@ response = client.video.check_external_storage(name='my-s3')
client.video.update_call_type(name='allhands', external_storage='my-s3')
```

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

```go
// 1. create a new storage with all the required parameters

client.CreateExternalStorage(ctx, &CreateExternalStorageRequest{
Name: "my-s3",
StorageType: "s3",
Bucket: "my-bucket",
Path: PtrTo("directory_name/"),
AwsS3: &S3Request{
S3Region: "us-east-1",
S3ApiKey: PtrTo("my-access"),
S3Secret: PtrTo("my-secret"),
},
})


// 2. (Optional) Check storage configuration for correctness
// In case of any errors, this will throw a StreamAPIException.
response, err := client.CheckExternalStorage(ctx, "my-s3")

// 3. update the call type to use the new storage
client.Video().UpdateCallType(ctx, "allhands", &UpdateCallTypeRequest{
ExternalStorage: PtrTo("my-s3"),
})
```

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

Expand Down Expand Up @@ -189,6 +218,27 @@ call.start_transcription(transcription_external_storage="my-storage")
call.start_recording(recording_external_storage="my-storage")
```

</TabItem>

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

```go
// update the call type to use Stream S3 storage for recordings
client.Video().UpdateCallType(ctx, "my-call-type", &UpdateCallTypeRequest{
ExternalStorage: PtrTo("stream-s3"),
})

// specify my-storage storage when starting call transcribing
call.StartTranscription(ctx, &StartTranscriptionRequest{
TranscriptionExternalStorage: PtrTo("my-storage"),
})

// specify my-storage storage for recording
call.StartRecording(ctx, &StartRecordingRequest{
RecordingExternalStorage: PtrTo("my-storage"),
})
```

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

Expand Down Expand Up @@ -315,6 +365,30 @@ client.create_external_storage(

</TabItem>

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

```go
file, err := os.Open("/path/to/your/service-account-file.json")
if err != nil {
log.Fatal(err)
}
defer file.Close()
creds, err := io.ReadAll(file)
if err != nil {
log.Fatal(err)
}

client.CreateExternalStorage(ctx, &CreateExternalStorageRequest{
Name: "my-gcs",
StorageType: "gcs",
Bucket: "my-bucket",
Path: PtrTo("directory_name/"),
GcsCredentials: PtrTo(string(creds)),
})
```

</TabItem>

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

```bash
Expand Down Expand Up @@ -411,6 +485,26 @@ client.create_external_storage(

</TabItem>

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

```go
client.CreateExternalStorage(ctx, &CreateExternalStorageRequest{
Name: "my-abs",
StorageType: "abs",
Bucket: "my-bucket",
Path: PtrTo("directory_name/"),
AzureBlob: &AzureRequest{
AbsAccountName: "...",
AbsClientID: "...",
AbsClientSecret: "...",
AbsTenantID: "...",
},
},
)
```

</TabItem>

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

```bash
Expand Down
Loading
Loading