livekit-server-sdk 0.6.6 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/banner_dark.png +0 -0
- data/.github/banner_light.png +0 -0
- data/.github/workflows/test.yml +15 -15
- data/Gemfile.lock +16 -9
- data/README.md +11 -8
- data/Rakefile +3 -0
- data/lib/livekit/access_token.rb +36 -5
- data/lib/livekit/auth_mixin.rb +10 -2
- data/lib/livekit/egress_service_client.rb +10 -10
- data/lib/livekit/grants.rb +52 -3
- data/lib/livekit/ingress_service_client.rb +4 -4
- data/lib/livekit/proto/livekit_agent_dispatch_pb.rb +25 -0
- data/lib/livekit/proto/livekit_agent_dispatch_twirp.rb +19 -0
- data/lib/livekit/proto/livekit_agent_pb.rb +37 -0
- data/lib/livekit/proto/livekit_agent_twirp.rb +8 -0
- data/lib/livekit/proto/livekit_egress_pb.rb +1 -1
- data/lib/livekit/proto/livekit_metrics_pb.rb +23 -0
- data/lib/livekit/proto/livekit_metrics_twirp.rb +8 -0
- data/lib/livekit/proto/livekit_models_pb.rb +11 -1
- data/lib/livekit/proto/livekit_room_pb.rb +4 -1
- data/lib/livekit/proto/livekit_sip_pb.rb +24 -1
- data/lib/livekit/proto/livekit_sip_twirp.rb +7 -1
- data/lib/livekit/room_service_client.rb +26 -12
- data/lib/livekit/sip_service_client.rb +226 -0
- data/lib/livekit/version.rb +1 -1
- data/lib/livekit.rb +1 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffba3e4bb237a3d72727a1b4f394ee48df1e01ba8979784cd150f5b151b79551
|
4
|
+
data.tar.gz: 5b7800d0bfcd95463df67b3ee20260a690436b46b3fb61dbf33592255fcc42d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72d3c6b27843214b6d39cb5036c38db4f33edc7ec31cbe0410a42b0cd6d628d0187de991fa1738774b6affbb0e08c55890b7de0427da8044276642a73e439bf9
|
7
|
+
data.tar.gz: f4d6833eccf51dd6270ba9cacd9fbe48404a8ddee94075d5587f15e2dd3fed0f10ccce9a4b9cd9a86f5ca4adb5c172efdc40d694595563ae79c9f4d70016cde9
|
data/.github/banner_dark.png
CHANGED
Binary file
|
data/.github/banner_light.png
CHANGED
Binary file
|
data/.github/workflows/test.yml
CHANGED
@@ -7,19 +7,19 @@ jobs:
|
|
7
7
|
strategy:
|
8
8
|
matrix:
|
9
9
|
include:
|
10
|
-
- { os: ubuntu-latest, ruby_version:
|
11
|
-
- { os: ubuntu-latest, ruby_version:
|
12
|
-
- { os: ubuntu-latest, ruby_version:
|
10
|
+
- { os: ubuntu-latest, ruby_version: "3.0" }
|
11
|
+
- { os: ubuntu-latest, ruby_version: "3.3" }
|
12
|
+
- { os: ubuntu-latest, ruby_version: "jruby-9.4" }
|
13
13
|
steps:
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
14
|
+
- name: Setup Ruby, JRuby and TruffleRuby
|
15
|
+
uses: ruby/setup-ruby@v1.190.0
|
16
|
+
with:
|
17
|
+
bundler: 1
|
18
|
+
ruby-version: ${{ matrix.ruby_version }}
|
19
|
+
- name: Checkout code
|
20
|
+
uses: actions/checkout@v2
|
21
|
+
- name: Run tests
|
22
|
+
run: |
|
23
|
+
gem install bundler:2.3.7
|
24
|
+
bundle install --jobs 4 --retry 3
|
25
|
+
bundle exec rspec
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
livekit-server-sdk (0.
|
4
|
+
livekit-server-sdk (0.7.0)
|
5
5
|
google-protobuf (>= 3.21.0, < 4.0)
|
6
6
|
jwt (>= 2.2.3, < 3.0)
|
7
7
|
rack (>= 2.2.3)
|
@@ -10,22 +10,29 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
+
base64 (0.2.0)
|
13
14
|
coderay (1.1.3)
|
14
15
|
diff-lcs (1.5.0)
|
15
|
-
faraday (2.
|
16
|
-
faraday-net_http (>= 2.0, < 3.
|
17
|
-
|
18
|
-
faraday-net_http (3.
|
19
|
-
|
20
|
-
|
16
|
+
faraday (2.10.1)
|
17
|
+
faraday-net_http (>= 2.0, < 3.2)
|
18
|
+
logger
|
19
|
+
faraday-net_http (3.1.1)
|
20
|
+
net-http
|
21
|
+
google-protobuf (3.25.4)
|
22
|
+
google-protobuf (3.25.4-x86_64-linux)
|
23
|
+
jwt (2.8.2)
|
24
|
+
base64
|
25
|
+
logger (1.6.0)
|
21
26
|
method_source (1.0.0)
|
27
|
+
net-http (0.4.1)
|
28
|
+
uri
|
22
29
|
pry (0.14.2)
|
23
30
|
coderay (~> 1.1)
|
24
31
|
method_source (~> 1.0)
|
25
32
|
pry-doc (1.4.0)
|
26
33
|
pry (~> 0.11)
|
27
34
|
yard (~> 0.9.11)
|
28
|
-
rack (
|
35
|
+
rack (3.1.7)
|
29
36
|
rake (13.0.6)
|
30
37
|
rspec (3.12.0)
|
31
38
|
rspec-core (~> 3.12.0)
|
@@ -40,10 +47,10 @@ GEM
|
|
40
47
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
48
|
rspec-support (~> 3.12.0)
|
42
49
|
rspec-support (3.12.0)
|
43
|
-
ruby2_keywords (0.0.5)
|
44
50
|
twirp (1.10.0)
|
45
51
|
faraday (< 3)
|
46
52
|
google-protobuf (~> 3.0, >= 3.7.0)
|
53
|
+
uri (0.13.0)
|
47
54
|
webrick (1.7.0)
|
48
55
|
yard (0.9.28)
|
49
56
|
webrick (~> 1.7.0)
|
data/README.md
CHANGED
@@ -11,7 +11,9 @@
|
|
11
11
|
# LiveKit Server API for Ruby
|
12
12
|
|
13
13
|
<!--BEGIN_DESCRIPTION-->
|
14
|
-
|
14
|
+
|
15
|
+
Use this SDK to interact with <a href="https://livekit.io/">LiveKit</a> server APIs and create access tokens from your Ruby backend.
|
16
|
+
|
15
17
|
<!--END_DESCRIPTION-->
|
16
18
|
|
17
19
|
This library is designed to work with Ruby 2.6.0 and above.
|
@@ -46,8 +48,8 @@ require 'livekit'
|
|
46
48
|
token = LiveKit::AccessToken.new(api_key: 'yourkey', api_secret: 'yoursecret')
|
47
49
|
token.identity = 'participant-identity'
|
48
50
|
token.name = 'participant-name'
|
49
|
-
token.
|
50
|
-
|
51
|
+
token.set_video_grant(LiveKit::VideoGrant.new(roomJoin: true, room: 'room-name'))
|
52
|
+
token.attributes = { "mykey" => "myvalue" }
|
51
53
|
puts token.to_jwt
|
52
54
|
```
|
53
55
|
|
@@ -136,15 +138,16 @@ You may store credentials in environment variables. If api-key or api-secret is
|
|
136
138
|
The gem is available as open source under the terms of Apache 2.0 License.
|
137
139
|
|
138
140
|
<!--BEGIN_REPO_NAV-->
|
141
|
+
|
139
142
|
<br/><table>
|
143
|
+
|
140
144
|
<thead><tr><th colspan="2">LiveKit Ecosystem</th></tr></thead>
|
141
145
|
<tbody>
|
142
|
-
<tr><td>
|
143
|
-
<tr><td>Server APIs</td><td><a href="https://github.com/livekit/
|
146
|
+
<tr><td>Realtime SDKs</td><td><a href="https://github.com/livekit/components-js">React Components</a> · <a href="https://github.com/livekit/client-sdk-js">Browser</a> · <a href="https://github.com/livekit/components-swift">Swift Components</a> · <a href="https://github.com/livekit/client-sdk-swift">iOS/macOS/visionOS</a> · <a href="https://github.com/livekit/client-sdk-android">Android</a> · <a href="https://github.com/livekit/client-sdk-flutter">Flutter</a> · <a href="https://github.com/livekit/client-sdk-react-native">React Native</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/client-sdk-unity-web">Unity (web)</a> · <a href="https://github.com/livekit/client-sdk-unity">Unity (beta)</a></td></tr><tr></tr>
|
147
|
+
<tr><td>Server APIs</td><td><a href="https://github.com/livekit/node-sdks">Node.js</a> · <a href="https://github.com/livekit/server-sdk-go">Golang</a> · <b>Ruby</b> · <a href="https://github.com/livekit/server-sdk-kotlin">Java/Kotlin</a> · <a href="https://github.com/livekit/python-sdks">Python</a> · <a href="https://github.com/livekit/rust-sdks">Rust</a> · <a href="https://github.com/agence104/livekit-server-sdk-php">PHP (community)</a></td></tr><tr></tr>
|
144
148
|
<tr><td>Agents Frameworks</td><td><a href="https://github.com/livekit/agents">Python</a> · <a href="https://github.com/livekit/agent-playground">Playground</a></td></tr><tr></tr>
|
145
|
-
<tr><td>Services</td><td><a href="https://github.com/livekit/livekit">
|
146
|
-
<tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/
|
149
|
+
<tr><td>Services</td><td><a href="https://github.com/livekit/livekit">LiveKit server</a> · <a href="https://github.com/livekit/egress">Egress</a> · <a href="https://github.com/livekit/ingress">Ingress</a> · <a href="https://github.com/livekit/sip">SIP</a></td></tr><tr></tr>
|
150
|
+
<tr><td>Resources</td><td><a href="https://docs.livekit.io">Docs</a> · <a href="https://github.com/livekit-examples">Example apps</a> · <a href="https://livekit.io/cloud">Cloud</a> · <a href="https://docs.livekit.io/home/self-hosting/deployment">Self-hosting</a> · <a href="https://github.com/livekit/livekit-cli">CLI</a></td></tr>
|
147
151
|
</tbody>
|
148
152
|
</table>
|
149
153
|
<!--END_REPO_NAV-->
|
150
|
-
|
data/Rakefile
CHANGED
@@ -12,9 +12,12 @@ task :proto do
|
|
12
12
|
"--ruby_out=lib/livekit/proto",
|
13
13
|
"--twirp_ruby_out=lib/livekit/proto",
|
14
14
|
"-Iprotocol",
|
15
|
+
"./protocol/protobufs/livekit_agent.proto",
|
16
|
+
"./protocol/protobufs/livekit_agent_dispatch.proto",
|
15
17
|
"./protocol/protobufs/livekit_egress.proto",
|
16
18
|
"./protocol/protobufs/livekit_ingress.proto",
|
17
19
|
"./protocol/protobufs/livekit_sip.proto",
|
20
|
+
"./protocol/protobufs/livekit_metrics.proto",
|
18
21
|
"./protocol/protobufs/livekit_models.proto",
|
19
22
|
"./protocol/protobufs/livekit_room.proto",
|
20
23
|
"./protocol/protobufs/livekit_webhook.proto")
|
data/lib/livekit/access_token.rb
CHANGED
@@ -4,35 +4,65 @@ require "jwt"
|
|
4
4
|
|
5
5
|
module LiveKit
|
6
6
|
class AccessToken
|
7
|
-
#
|
8
|
-
DEFAULT_TTL =
|
7
|
+
# 10 minutes in seconds; how long the access token to the server is good for
|
8
|
+
DEFAULT_TTL = 600
|
9
9
|
|
10
10
|
# The signing algorithm used by the {jwt} gem internals
|
11
11
|
SIGNING_ALGORITHM = "HS256"
|
12
12
|
|
13
13
|
attr_accessor :grants, :identity
|
14
14
|
|
15
|
-
def initialize(
|
15
|
+
def initialize(
|
16
|
+
api_key: nil,
|
17
|
+
api_secret: nil,
|
18
|
+
identity: nil,
|
19
|
+
ttl: DEFAULT_TTL,
|
20
|
+
name: nil,
|
21
|
+
metadata: nil,
|
22
|
+
attributes: nil
|
23
|
+
)
|
16
24
|
@api_key = api_key || ENV["LIVEKIT_API_KEY"]
|
17
25
|
@api_secret = api_secret || ENV["LIVEKIT_API_SECRET"]
|
18
26
|
@grants = ClaimGrant.new
|
19
27
|
@grants.name = name
|
20
28
|
@grants.metadata = metadata
|
29
|
+
@grants.attributes = attributes
|
21
30
|
@identity = identity
|
22
31
|
@ttl = ttl
|
23
32
|
end
|
24
33
|
|
34
|
+
# Deprecated, use set_video_grant instead
|
25
35
|
def add_grant(video_grant)
|
26
36
|
if video_grant.is_a?(Hash)
|
27
37
|
video_grant = VideoGrant.from_hash(video_grant)
|
28
38
|
end
|
39
|
+
self.set_video_grant(video_grant)
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_video_grant(video_grant)
|
29
43
|
@grants.video = video_grant
|
30
44
|
end
|
31
45
|
|
46
|
+
# Deprecated, use set_sip_grant instead
|
47
|
+
def add_sip_grant(sip_grant)
|
48
|
+
if sip_grant.is_a?(Hash)
|
49
|
+
sip_grant = SIPGrant.from_hash(sip_grant)
|
50
|
+
end
|
51
|
+
self.set_sip_grant(sip_grant)
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_sip_grant(sip_grant)
|
55
|
+
@grants.sip = sip_grant
|
56
|
+
end
|
57
|
+
|
32
58
|
def metadata=(participant_md)
|
33
59
|
@grants.metadata = participant_md
|
34
60
|
end
|
35
61
|
|
62
|
+
def attributes=(participant_attributes)
|
63
|
+
@grants.attributes = participant_attributes
|
64
|
+
end
|
65
|
+
|
36
66
|
def name=(participant_name)
|
37
67
|
@grants.name = participant_name
|
38
68
|
end
|
@@ -46,8 +76,8 @@ module LiveKit
|
|
46
76
|
end
|
47
77
|
|
48
78
|
def to_jwt
|
49
|
-
if @grants.video.nil?
|
50
|
-
raise ArgumentError, "VideoGrant is required"
|
79
|
+
if @grants.video.nil? && @grants.sip.nil?
|
80
|
+
raise ArgumentError, "VideoGrant or SIPGrant is required"
|
51
81
|
end
|
52
82
|
|
53
83
|
jwt_timestamp = Time.now.to_i
|
@@ -59,6 +89,7 @@ module LiveKit
|
|
59
89
|
iss: @api_key,
|
60
90
|
sub: @identity,
|
61
91
|
})
|
92
|
+
payload.compact!
|
62
93
|
|
63
94
|
return JWT.encode(payload, @api_secret, SIGNING_ALGORITHM)
|
64
95
|
end
|
data/lib/livekit/auth_mixin.rb
CHANGED
@@ -3,10 +3,18 @@
|
|
3
3
|
module LiveKit
|
4
4
|
# Create authenticated headers when keys are provided
|
5
5
|
module AuthMixin
|
6
|
-
def auth_header(
|
6
|
+
def auth_header(
|
7
|
+
video_grant: nil,
|
8
|
+
sip_grant: nil
|
9
|
+
)
|
7
10
|
headers = {}
|
8
11
|
t = ::LiveKit::AccessToken.new(api_key: @api_key, api_secret: @api_secret)
|
9
|
-
|
12
|
+
if video_grant != nil
|
13
|
+
t.set_video_grant(video_grant)
|
14
|
+
end
|
15
|
+
if sip_grant != nil
|
16
|
+
t.set_sip_grant(sip_grant)
|
17
|
+
end
|
10
18
|
headers["Authorization"] = "Bearer #{t.to_jwt}"
|
11
19
|
headers["User-Agent"] = "LiveKit Ruby SDK"
|
12
20
|
headers
|
@@ -46,7 +46,7 @@ module LiveKit
|
|
46
46
|
self.rpc(
|
47
47
|
:StartRoomCompositeEgress,
|
48
48
|
request,
|
49
|
-
headers:
|
49
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
50
50
|
)
|
51
51
|
end
|
52
52
|
|
@@ -73,7 +73,7 @@ module LiveKit
|
|
73
73
|
self.rpc(
|
74
74
|
:StartParticipantEgress,
|
75
75
|
request,
|
76
|
-
headers:
|
76
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
77
77
|
)
|
78
78
|
end
|
79
79
|
|
@@ -101,7 +101,7 @@ module LiveKit
|
|
101
101
|
self.rpc(
|
102
102
|
:StartTrackCompositeEgress,
|
103
103
|
request,
|
104
|
-
headers:
|
104
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
105
105
|
)
|
106
106
|
end
|
107
107
|
|
@@ -123,7 +123,7 @@ module LiveKit
|
|
123
123
|
self.rpc(
|
124
124
|
:StartTrackEgress,
|
125
125
|
request,
|
126
|
-
headers:
|
126
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
127
127
|
)
|
128
128
|
end
|
129
129
|
|
@@ -154,7 +154,7 @@ module LiveKit
|
|
154
154
|
self.rpc(
|
155
155
|
:StartWebEgress,
|
156
156
|
request,
|
157
|
-
headers:
|
157
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
158
158
|
)
|
159
159
|
end
|
160
160
|
|
@@ -165,7 +165,7 @@ module LiveKit
|
|
165
165
|
egress_id: egress_id,
|
166
166
|
layout: layout,
|
167
167
|
),
|
168
|
-
headers:
|
168
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
169
169
|
)
|
170
170
|
end
|
171
171
|
|
@@ -180,7 +180,7 @@ module LiveKit
|
|
180
180
|
add_output_urls: add_output_urls,
|
181
181
|
remove_output_urls: remove_output_urls,
|
182
182
|
),
|
183
|
-
headers:
|
183
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
184
184
|
)
|
185
185
|
end
|
186
186
|
|
@@ -197,7 +197,7 @@ module LiveKit
|
|
197
197
|
active: active,
|
198
198
|
egress_id: egress_id,
|
199
199
|
),
|
200
|
-
headers:
|
200
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
201
201
|
)
|
202
202
|
end
|
203
203
|
|
@@ -205,7 +205,7 @@ module LiveKit
|
|
205
205
|
self.rpc(
|
206
206
|
:StopEgress,
|
207
207
|
Proto::StopEgressRequest.new(egress_id: egress_id),
|
208
|
-
headers:
|
208
|
+
headers:auth_header(video_grant: VideoGrant.new(roomRecord: true)),
|
209
209
|
)
|
210
210
|
end
|
211
211
|
|
@@ -225,7 +225,7 @@ module LiveKit
|
|
225
225
|
elsif out.is_a? LiveKit::Proto::SegmentedFileOutput
|
226
226
|
raise "cannot add multiple segmented file outputs" if request.segment_outputs.any?
|
227
227
|
request.segment_outputs = Google::Protobuf::RepeatedField.new(:message, Proto::SegmentedFileOutput, [out])
|
228
|
-
elsif out.is_a?
|
228
|
+
elsif out.is_a? LiveKit::Proto::StreamOutput
|
229
229
|
raise "cannot add multiple stream outputs" if request.stream_outputs.any?
|
230
230
|
request.stream_outputs = Google::Protobuf::RepeatedField.new(:message, Proto::StreamOutput, [out])
|
231
231
|
elsif out.is_a? LiveKit::Proto::ImageOutput
|
data/lib/livekit/grants.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module LiveKit
|
4
4
|
class ClaimGrant
|
5
|
-
attr_accessor :identity, :name, :metadata, :sha256, :video
|
5
|
+
attr_accessor :identity, :name, :metadata, :sha256, :video, :sip, :attributes
|
6
6
|
|
7
7
|
def self.from_hash(hash)
|
8
8
|
return nil if hash.nil?
|
@@ -11,8 +11,10 @@ module LiveKit
|
|
11
11
|
claim_grant.identity = hash["sub"]
|
12
12
|
claim_grant.name = hash["name"]
|
13
13
|
claim_grant.metadata = hash["metadata"]
|
14
|
+
claim_grant.attributes = hash["attributes"]
|
14
15
|
claim_grant.sha256 = hash["sha256"]
|
15
16
|
claim_grant.video = VideoGrant.from_hash(hash["video"])
|
17
|
+
claim_grant.sip = SIPGrant.from_hash(hash["sip"])
|
16
18
|
return claim_grant
|
17
19
|
end
|
18
20
|
|
@@ -22,15 +24,24 @@ module LiveKit
|
|
22
24
|
@metadata = nil
|
23
25
|
@sha256 = nil
|
24
26
|
@video = nil
|
27
|
+
@sip = nil
|
28
|
+
@attributes = nil
|
25
29
|
end
|
26
30
|
|
27
31
|
def to_hash
|
28
|
-
{
|
32
|
+
val = {
|
29
33
|
name: @name,
|
30
34
|
metadata: @metadata,
|
35
|
+
attributes: @attributes,
|
31
36
|
sha256: @sha256,
|
32
|
-
video: @video.to_hash,
|
33
37
|
}
|
38
|
+
if @video
|
39
|
+
val[:video] = @video.to_hash
|
40
|
+
end
|
41
|
+
if @sip
|
42
|
+
val[:sip] = @sip.to_hash
|
43
|
+
end
|
44
|
+
return val
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
@@ -121,4 +132,42 @@ module LiveKit
|
|
121
132
|
hash
|
122
133
|
end
|
123
134
|
end
|
135
|
+
|
136
|
+
class SIPGrant
|
137
|
+
using LiveKit::Utils::StringifyKeysRefinement
|
138
|
+
|
139
|
+
attr_accessor :admin, :call
|
140
|
+
|
141
|
+
def initialize(
|
142
|
+
# true if can access SIP features
|
143
|
+
admin: nil,
|
144
|
+
# true if can make outgoing call
|
145
|
+
call: nil
|
146
|
+
)
|
147
|
+
@admin = admin
|
148
|
+
@call = call
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.from_hash(hash)
|
152
|
+
return nil if hash.nil?
|
153
|
+
|
154
|
+
hash = hash.stringify_keys
|
155
|
+
|
156
|
+
SIPGrant.new(
|
157
|
+
admin: hash["admin"],
|
158
|
+
call: hash["call"]
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
def to_hash
|
163
|
+
hash = {}
|
164
|
+
instance_variables.each { |var|
|
165
|
+
val = instance_variable_get(var)
|
166
|
+
if val != nil
|
167
|
+
hash[var.to_s.delete("@")] = val
|
168
|
+
end
|
169
|
+
}
|
170
|
+
hash
|
171
|
+
end
|
172
|
+
end
|
124
173
|
end
|
@@ -51,7 +51,7 @@ module LiveKit
|
|
51
51
|
self.rpc(
|
52
52
|
:CreateIngress,
|
53
53
|
request,
|
54
|
-
headers:
|
54
|
+
headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
|
55
55
|
)
|
56
56
|
end
|
57
57
|
|
@@ -89,7 +89,7 @@ module LiveKit
|
|
89
89
|
self.rpc(
|
90
90
|
:UpdateIngress,
|
91
91
|
request,
|
92
|
-
headers:
|
92
|
+
headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
|
93
93
|
)
|
94
94
|
end
|
95
95
|
|
@@ -106,7 +106,7 @@ module LiveKit
|
|
106
106
|
self.rpc(
|
107
107
|
:ListIngress,
|
108
108
|
request,
|
109
|
-
headers:
|
109
|
+
headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
|
110
110
|
)
|
111
111
|
end
|
112
112
|
|
@@ -117,7 +117,7 @@ module LiveKit
|
|
117
117
|
self.rpc(
|
118
118
|
:DeleteIngress,
|
119
119
|
request,
|
120
|
-
headers:
|
120
|
+
headers:auth_header(video_grant: VideoGrant.new(ingressAdmin: true)),
|
121
121
|
)
|
122
122
|
end
|
123
123
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: livekit_agent_dispatch.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
require 'livekit_agent_pb'
|
8
|
+
|
9
|
+
|
10
|
+
descriptor_data = "\n\x1clivekit_agent_dispatch.proto\x12\x07livekit\x1a\x13livekit_agent.proto\"P\n\x1a\x43reateAgentDispatchRequest\x12\x12\n\nagent_name\x18\x01 \x01(\t\x12\x0c\n\x04room\x18\x02 \x01(\t\x12\x10\n\x08metadata\x18\x03 \x01(\t\"9\n\x11RoomAgentDispatch\x12\x12\n\nagent_name\x18\x01 \x01(\t\x12\x10\n\x08metadata\x18\x02 \x01(\t\"?\n\x1a\x44\x65leteAgentDispatchRequest\x12\x13\n\x0b\x64ispatch_id\x18\x01 \x01(\t\x12\x0c\n\x04room\x18\x02 \x01(\t\"=\n\x18ListAgentDispatchRequest\x12\x13\n\x0b\x64ispatch_id\x18\x01 \x01(\t\x12\x0c\n\x04room\x18\x02 \x01(\t\"M\n\x19ListAgentDispatchResponse\x12\x30\n\x10\x61gent_dispatches\x18\x01 \x03(\x0b\x32\x16.livekit.AgentDispatch\"{\n\rAgentDispatch\x12\n\n\x02id\x18\x01 \x01(\t\x12\x12\n\nagent_name\x18\x02 \x01(\t\x12\x0c\n\x04room\x18\x03 \x01(\t\x12\x10\n\x08metadata\x18\x04 \x01(\t\x12*\n\x05state\x18\x05 \x01(\x0b\x32\x1b.livekit.AgentDispatchState\"X\n\x12\x41gentDispatchState\x12\x1a\n\x04jobs\x18\x01 \x03(\x0b\x32\x0c.livekit.Job\x12\x12\n\ncreated_at\x18\x02 \x01(\x03\x12\x12\n\ndeleted_at\x18\x03 \x01(\x03\x32\x8b\x02\n\x14\x41gentDispatchService\x12M\n\x0e\x43reateDispatch\x12#.livekit.CreateAgentDispatchRequest\x1a\x16.livekit.AgentDispatch\x12M\n\x0e\x44\x65leteDispatch\x12#.livekit.DeleteAgentDispatchRequest\x1a\x16.livekit.AgentDispatch\x12U\n\x0cListDispatch\x12!.livekit.ListAgentDispatchRequest\x1a\".livekit.ListAgentDispatchResponseBFZ#github.com/livekit/protocol/livekit\xaa\x02\rLiveKit.Proto\xea\x02\x0eLiveKit::Protob\x06proto3"
|
11
|
+
|
12
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
14
|
+
|
15
|
+
module LiveKit
|
16
|
+
module Proto
|
17
|
+
CreateAgentDispatchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.CreateAgentDispatchRequest").msgclass
|
18
|
+
RoomAgentDispatch = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.RoomAgentDispatch").msgclass
|
19
|
+
DeleteAgentDispatchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.DeleteAgentDispatchRequest").msgclass
|
20
|
+
ListAgentDispatchRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.ListAgentDispatchRequest").msgclass
|
21
|
+
ListAgentDispatchResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.ListAgentDispatchResponse").msgclass
|
22
|
+
AgentDispatch = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.AgentDispatch").msgclass
|
23
|
+
AgentDispatchState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.AgentDispatchState").msgclass
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Code generated by protoc-gen-twirp_ruby 1.11.0, DO NOT EDIT.
|
2
|
+
require 'twirp'
|
3
|
+
require_relative 'livekit_agent_dispatch_pb.rb'
|
4
|
+
|
5
|
+
module LiveKit
|
6
|
+
module Proto
|
7
|
+
class AgentDispatchServiceService < ::Twirp::Service
|
8
|
+
package 'livekit'
|
9
|
+
service 'AgentDispatchService'
|
10
|
+
rpc :CreateDispatch, CreateAgentDispatchRequest, AgentDispatch, :ruby_method => :create_dispatch
|
11
|
+
rpc :DeleteDispatch, DeleteAgentDispatchRequest, AgentDispatch, :ruby_method => :delete_dispatch
|
12
|
+
rpc :ListDispatch, ListAgentDispatchRequest, ListAgentDispatchResponse, :ruby_method => :list_dispatch
|
13
|
+
end
|
14
|
+
|
15
|
+
class AgentDispatchServiceClient < ::Twirp::Client
|
16
|
+
client_for AgentDispatchServiceService
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: livekit_agent.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
require 'livekit_models_pb'
|
8
|
+
|
9
|
+
|
10
|
+
descriptor_data = "\n\x13livekit_agent.proto\x12\x07livekit\x1a\x14livekit_models.proto\"\x86\x02\n\x03Job\x12\n\n\x02id\x18\x01 \x01(\t\x12\x13\n\x0b\x64ispatch_id\x18\t \x01(\t\x12\x1e\n\x04type\x18\x02 \x01(\x0e\x32\x10.livekit.JobType\x12\x1b\n\x04room\x18\x03 \x01(\x0b\x32\r.livekit.Room\x12\x32\n\x0bparticipant\x18\x04 \x01(\x0b\x32\x18.livekit.ParticipantInfoH\x00\x88\x01\x01\x12\x15\n\tnamespace\x18\x05 \x01(\tB\x02\x18\x01\x12\x10\n\x08metadata\x18\x06 \x01(\t\x12\x12\n\nagent_name\x18\x07 \x01(\t\x12 \n\x05state\x18\x08 \x01(\x0b\x32\x11.livekit.JobStateB\x0e\n\x0c_participant\"\x95\x01\n\x08JobState\x12\"\n\x06status\x18\x01 \x01(\x0e\x32\x12.livekit.JobStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t\x12\x12\n\nstarted_at\x18\x03 \x01(\x03\x12\x10\n\x08\x65nded_at\x18\x04 \x01(\x03\x12\x12\n\nupdated_at\x18\x05 \x01(\x03\x12\x1c\n\x14participant_identity\x18\x06 \x01(\t\"\xf8\x02\n\rWorkerMessage\x12\x32\n\x08register\x18\x01 \x01(\x0b\x32\x1e.livekit.RegisterWorkerRequestH\x00\x12\x35\n\x0c\x61vailability\x18\x02 \x01(\x0b\x32\x1d.livekit.AvailabilityResponseH\x00\x12\x34\n\rupdate_worker\x18\x03 \x01(\x0b\x32\x1b.livekit.UpdateWorkerStatusH\x00\x12.\n\nupdate_job\x18\x04 \x01(\x0b\x32\x18.livekit.UpdateJobStatusH\x00\x12#\n\x04ping\x18\x05 \x01(\x0b\x32\x13.livekit.WorkerPingH\x00\x12\x33\n\x0csimulate_job\x18\x06 \x01(\x0b\x32\x1b.livekit.SimulateJobRequestH\x00\x12\x31\n\x0bmigrate_job\x18\x07 \x01(\x0b\x32\x1a.livekit.MigrateJobRequestH\x00\x42\t\n\x07message\"\x88\x02\n\rServerMessage\x12\x33\n\x08register\x18\x01 \x01(\x0b\x32\x1f.livekit.RegisterWorkerResponseH\x00\x12\x34\n\x0c\x61vailability\x18\x02 \x01(\x0b\x32\x1c.livekit.AvailabilityRequestH\x00\x12,\n\nassignment\x18\x03 \x01(\x0b\x32\x16.livekit.JobAssignmentH\x00\x12.\n\x0btermination\x18\x05 \x01(\x0b\x32\x17.livekit.JobTerminationH\x00\x12#\n\x04pong\x18\x04 \x01(\x0b\x32\x13.livekit.WorkerPongH\x00\x42\t\n\x07message\"\x80\x01\n\x12SimulateJobRequest\x12\x1e\n\x04type\x18\x01 \x01(\x0e\x32\x10.livekit.JobType\x12\x1b\n\x04room\x18\x02 \x01(\x0b\x32\r.livekit.Room\x12-\n\x0bparticipant\x18\x03 \x01(\x0b\x32\x18.livekit.ParticipantInfo\"\x1f\n\nWorkerPing\x12\x11\n\ttimestamp\x18\x01 \x01(\x03\"7\n\nWorkerPong\x12\x16\n\x0elast_timestamp\x18\x01 \x01(\x03\x12\x11\n\ttimestamp\x18\x02 \x01(\x03\"\xd6\x01\n\x15RegisterWorkerRequest\x12\x1e\n\x04type\x18\x01 \x01(\x0e\x32\x10.livekit.JobType\x12\x12\n\nagent_name\x18\x08 \x01(\t\x12\x0f\n\x07version\x18\x03 \x01(\t\x12\x15\n\rping_interval\x18\x05 \x01(\r\x12\x16\n\tnamespace\x18\x06 \x01(\tH\x00\x88\x01\x01\x12;\n\x13\x61llowed_permissions\x18\x07 \x01(\x0b\x32\x1e.livekit.ParticipantPermissionB\x0c\n\n_namespace\"U\n\x16RegisterWorkerResponse\x12\x11\n\tworker_id\x18\x01 \x01(\t\x12(\n\x0bserver_info\x18\x03 \x01(\x0b\x32\x13.livekit.ServerInfo\"$\n\x11MigrateJobRequest\x12\x0f\n\x07job_ids\x18\x02 \x03(\t\"B\n\x13\x41vailabilityRequest\x12\x19\n\x03job\x18\x01 \x01(\x0b\x32\x0c.livekit.Job\x12\x10\n\x08resuming\x18\x02 \x01(\x08\"\xc0\x02\n\x14\x41vailabilityResponse\x12\x0e\n\x06job_id\x18\x01 \x01(\t\x12\x11\n\tavailable\x18\x02 \x01(\x08\x12\x17\n\x0fsupports_resume\x18\x03 \x01(\x08\x12\x18\n\x10participant_name\x18\x04 \x01(\t\x12\x1c\n\x14participant_identity\x18\x05 \x01(\t\x12\x1c\n\x14participant_metadata\x18\x06 \x01(\t\x12X\n\x16participant_attributes\x18\x07 \x03(\x0b\x32\x38.livekit.AvailabilityResponse.ParticipantAttributesEntry\x1a<\n\x1aParticipantAttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"T\n\x0fUpdateJobStatus\x12\x0e\n\x06job_id\x18\x01 \x01(\t\x12\"\n\x06status\x18\x02 \x01(\x0e\x32\x12.livekit.JobStatus\x12\r\n\x05\x65rror\x18\x03 \x01(\t\"l\n\x12UpdateWorkerStatus\x12*\n\x06status\x18\x01 \x01(\x0e\x32\x15.livekit.WorkerStatusH\x00\x88\x01\x01\x12\x0c\n\x04load\x18\x03 \x01(\x02\x12\x11\n\tjob_count\x18\x04 \x01(\rB\t\n\x07_status\"S\n\rJobAssignment\x12\x19\n\x03job\x18\x01 \x01(\x0b\x32\x0c.livekit.Job\x12\x10\n\x03url\x18\x02 \x01(\tH\x00\x88\x01\x01\x12\r\n\x05token\x18\x03 \x01(\tB\x06\n\x04_url\" \n\x0eJobTermination\x12\x0e\n\x06job_id\x18\x01 \x01(\t*(\n\x07JobType\x12\x0b\n\x07JT_ROOM\x10\x00\x12\x10\n\x0cJT_PUBLISHER\x10\x01*-\n\x0cWorkerStatus\x12\x10\n\x0cWS_AVAILABLE\x10\x00\x12\x0b\n\x07WS_FULL\x10\x01*J\n\tJobStatus\x12\x0e\n\nJS_PENDING\x10\x00\x12\x0e\n\nJS_RUNNING\x10\x01\x12\x0e\n\nJS_SUCCESS\x10\x02\x12\r\n\tJS_FAILED\x10\x03\x42\x46Z#github.com/livekit/protocol/livekit\xaa\x02\rLiveKit.Proto\xea\x02\x0eLiveKit::Protob\x06proto3"
|
11
|
+
|
12
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
13
|
+
pool.add_serialized_file(descriptor_data)
|
14
|
+
|
15
|
+
module LiveKit
|
16
|
+
module Proto
|
17
|
+
Job = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.Job").msgclass
|
18
|
+
JobState = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.JobState").msgclass
|
19
|
+
WorkerMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.WorkerMessage").msgclass
|
20
|
+
ServerMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.ServerMessage").msgclass
|
21
|
+
SimulateJobRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.SimulateJobRequest").msgclass
|
22
|
+
WorkerPing = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.WorkerPing").msgclass
|
23
|
+
WorkerPong = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.WorkerPong").msgclass
|
24
|
+
RegisterWorkerRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.RegisterWorkerRequest").msgclass
|
25
|
+
RegisterWorkerResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.RegisterWorkerResponse").msgclass
|
26
|
+
MigrateJobRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.MigrateJobRequest").msgclass
|
27
|
+
AvailabilityRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.AvailabilityRequest").msgclass
|
28
|
+
AvailabilityResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.AvailabilityResponse").msgclass
|
29
|
+
UpdateJobStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.UpdateJobStatus").msgclass
|
30
|
+
UpdateWorkerStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.UpdateWorkerStatus").msgclass
|
31
|
+
JobAssignment = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.JobAssignment").msgclass
|
32
|
+
JobTermination = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.JobTermination").msgclass
|
33
|
+
JobType = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.JobType").enummodule
|
34
|
+
WorkerStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.WorkerStatus").enummodule
|
35
|
+
JobStatus = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("livekit.JobStatus").enummodule
|
36
|
+
end
|
37
|
+
end
|