forked from livekit/server-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ingressclient.go
74 lines (62 loc) · 1.79 KB
/
ingressclient.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package lksdk
import (
"context"
"net/http"
"github.com/livekit/protocol/auth"
"github.com/livekit/protocol/livekit"
)
type IngressClient struct {
ingressClient livekit.Ingress
authBase
}
func NewIngressClient(url string, apiKey string, secretKey string) *IngressClient {
url = ToHttpURL(url)
client := livekit.NewIngressProtobufClient(url, &http.Client{})
return &IngressClient{
ingressClient: client,
authBase: authBase{
apiKey: apiKey,
apiSecret: secretKey,
},
}
}
func (c *IngressClient) CreateIngress(ctx context.Context, in *livekit.CreateIngressRequest) (*livekit.IngressInfo, error) {
if in == nil {
return nil, ErrInvalidParameter
}
ctx, err := c.withAuth(ctx, auth.VideoGrant{IngressAdmin: true})
if err != nil {
return nil, err
}
return c.ingressClient.CreateIngress(ctx, in)
}
func (c *IngressClient) UpdateIngress(ctx context.Context, in *livekit.UpdateIngressRequest) (*livekit.IngressInfo, error) {
if in == nil {
return nil, ErrInvalidParameter
}
ctx, err := c.withAuth(ctx, auth.VideoGrant{IngressAdmin: true})
if err != nil {
return nil, err
}
return c.ingressClient.UpdateIngress(ctx, in)
}
func (c *IngressClient) ListIngress(ctx context.Context, in *livekit.ListIngressRequest) (*livekit.ListIngressResponse, error) {
if in == nil {
return nil, ErrInvalidParameter
}
ctx, err := c.withAuth(ctx, auth.VideoGrant{IngressAdmin: true})
if err != nil {
return nil, err
}
return c.ingressClient.ListIngress(ctx, in)
}
func (c *IngressClient) DeleteIngress(ctx context.Context, in *livekit.DeleteIngressRequest) (*livekit.IngressInfo, error) {
if in == nil {
return nil, ErrInvalidParameter
}
ctx, err := c.withAuth(ctx, auth.VideoGrant{IngressAdmin: true})
if err != nil {
return nil, err
}
return c.ingressClient.DeleteIngress(ctx, in)
}