plex_ruby_sdk 0.7.7 → 0.8.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/lib/plex_ruby_sdk/activities.rb +115 -12
- data/lib/plex_ruby_sdk/authentication.rb +233 -29
- data/lib/plex_ruby_sdk/butler.rb +283 -30
- data/lib/plex_ruby_sdk/hubs.rb +174 -21
- data/lib/plex_ruby_sdk/library.rb +1307 -110
- data/lib/plex_ruby_sdk/log.rb +179 -24
- data/lib/plex_ruby_sdk/media.rb +288 -35
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_mediacontainer.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_metadata.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_request.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_response.rb +33 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_arts_responsebody.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_mediacontainer.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_metadata.rb +36 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_request.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_response.rb +33 -0
- data/lib/plex_ruby_sdk/models/operations/get_media_posters_responsebody.rb +24 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_arts_request.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_arts_response.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_poster_request.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations/post_media_poster_response.rb +30 -0
- data/lib/plex_ruby_sdk/models/operations.rb +14 -0
- data/lib/plex_ruby_sdk/playlists.rb +513 -60
- data/lib/plex_ruby_sdk/plex.rb +388 -38
- data/lib/plex_ruby_sdk/plex_api.rb +29 -10
- data/lib/plex_ruby_sdk/sdk_hooks/hooks.rb +103 -0
- data/lib/plex_ruby_sdk/sdk_hooks/registration.rb +35 -0
- data/lib/plex_ruby_sdk/sdk_hooks/types.rb +152 -0
- data/lib/plex_ruby_sdk/sdkconfiguration.rb +26 -7
- data/lib/plex_ruby_sdk/search.rb +174 -21
- data/lib/plex_ruby_sdk/server.rb +505 -53
- data/lib/plex_ruby_sdk/sessions.rb +228 -25
- data/lib/plex_ruby_sdk/statistics.rb +174 -21
- data/lib/plex_ruby_sdk/updater.rb +173 -20
- data/lib/plex_ruby_sdk/users.rb +56 -4
- data/lib/plex_ruby_sdk/utils/retries.rb +95 -0
- data/lib/plex_ruby_sdk/utils/utils.rb +10 -0
- data/lib/plex_ruby_sdk/video.rb +117 -14
- data/lib/plex_ruby_sdk/watchlist.rb +60 -7
- metadata +50 -4
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
require 'faraday'
|
7
7
|
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
8
9
|
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
9
12
|
|
10
13
|
module PlexRubySDK
|
11
14
|
extend T::Sig
|
@@ -20,8 +23,8 @@ module PlexRubySDK
|
|
20
23
|
end
|
21
24
|
|
22
25
|
|
23
|
-
sig { returns(::PlexRubySDK::Operations::GetSessionsResponse) }
|
24
|
-
def get_sessions
|
26
|
+
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetSessionsResponse) }
|
27
|
+
def get_sessions(timeout_ms = nil)
|
25
28
|
# get_sessions - Get Active Sessions
|
26
29
|
# This will retrieve the "Now Playing" Information of the PMS.
|
27
30
|
url, params = @sdk_configuration.get_server_details
|
@@ -31,10 +34,60 @@ module PlexRubySDK
|
|
31
34
|
headers['Accept'] = 'application/json'
|
32
35
|
headers['user-agent'] = @sdk_configuration.user_agent
|
33
36
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
37
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
38
|
+
|
39
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
40
|
+
timeout ||= @sdk_configuration.timeout
|
41
|
+
|
42
|
+
connection = @sdk_configuration.client
|
43
|
+
|
44
|
+
hook_ctx = SDKHooks::HookContext.new(
|
45
|
+
base_url: base_url,
|
46
|
+
oauth2_scopes: nil,
|
47
|
+
operation_id: 'getSessions',
|
48
|
+
security_source: @sdk_configuration.security_source
|
49
|
+
)
|
50
|
+
|
51
|
+
error = T.let(nil, T.nilable(StandardError))
|
52
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
53
|
+
|
54
|
+
begin
|
55
|
+
r = connection.get(url) do |req|
|
56
|
+
req.headers.merge!(headers)
|
57
|
+
req.options.timeout = timeout unless timeout.nil?
|
58
|
+
Utils.configure_request_security(req, security)
|
59
|
+
|
60
|
+
@sdk_configuration.hooks.before_request(
|
61
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
62
|
+
hook_ctx: hook_ctx
|
63
|
+
),
|
64
|
+
request: req
|
65
|
+
)
|
66
|
+
end
|
67
|
+
rescue StandardError => e
|
68
|
+
error = e
|
69
|
+
ensure
|
70
|
+
if r.nil? || Utils.error_status?(r.status)
|
71
|
+
r = @sdk_configuration.hooks.after_error(
|
72
|
+
error: error,
|
73
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
74
|
+
hook_ctx: hook_ctx
|
75
|
+
),
|
76
|
+
response: r
|
77
|
+
)
|
78
|
+
else
|
79
|
+
r = @sdk_configuration.hooks.after_success(
|
80
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
81
|
+
hook_ctx: hook_ctx
|
82
|
+
),
|
83
|
+
response: r
|
84
|
+
)
|
85
|
+
end
|
86
|
+
|
87
|
+
if r.nil?
|
88
|
+
raise error if !error.nil?
|
89
|
+
raise 'no response'
|
90
|
+
end
|
38
91
|
end
|
39
92
|
|
40
93
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -63,8 +116,8 @@ module PlexRubySDK
|
|
63
116
|
end
|
64
117
|
|
65
118
|
|
66
|
-
sig { params(sort: T.nilable(::String), account_id: T.nilable(::Integer), filter: T.nilable(::PlexRubySDK::Operations::QueryParamFilter), library_section_id: T.nilable(::Integer)).returns(::PlexRubySDK::Operations::GetSessionHistoryResponse) }
|
67
|
-
def get_session_history(sort = nil, account_id = nil, filter = nil, library_section_id = nil)
|
119
|
+
sig { params(sort: T.nilable(::String), account_id: T.nilable(::Integer), filter: T.nilable(::PlexRubySDK::Operations::QueryParamFilter), library_section_id: T.nilable(::Integer), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetSessionHistoryResponse) }
|
120
|
+
def get_session_history(sort = nil, account_id = nil, filter = nil, library_section_id = nil, timeout_ms = nil)
|
68
121
|
# get_session_history - Get Session History
|
69
122
|
# This will Retrieve a listing of all history views.
|
70
123
|
request = ::PlexRubySDK::Operations::GetSessionHistoryRequest.new(
|
@@ -82,11 +135,61 @@ module PlexRubySDK
|
|
82
135
|
headers['Accept'] = 'application/json'
|
83
136
|
headers['user-agent'] = @sdk_configuration.user_agent
|
84
137
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
138
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
139
|
+
|
140
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
141
|
+
timeout ||= @sdk_configuration.timeout
|
142
|
+
|
143
|
+
connection = @sdk_configuration.client
|
144
|
+
|
145
|
+
hook_ctx = SDKHooks::HookContext.new(
|
146
|
+
base_url: base_url,
|
147
|
+
oauth2_scopes: nil,
|
148
|
+
operation_id: 'getSessionHistory',
|
149
|
+
security_source: @sdk_configuration.security_source
|
150
|
+
)
|
151
|
+
|
152
|
+
error = T.let(nil, T.nilable(StandardError))
|
153
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
154
|
+
|
155
|
+
begin
|
156
|
+
r = connection.get(url) do |req|
|
157
|
+
req.headers.merge!(headers)
|
158
|
+
req.options.timeout = timeout unless timeout.nil?
|
159
|
+
req.params = query_params
|
160
|
+
Utils.configure_request_security(req, security)
|
161
|
+
|
162
|
+
@sdk_configuration.hooks.before_request(
|
163
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
164
|
+
hook_ctx: hook_ctx
|
165
|
+
),
|
166
|
+
request: req
|
167
|
+
)
|
168
|
+
end
|
169
|
+
rescue StandardError => e
|
170
|
+
error = e
|
171
|
+
ensure
|
172
|
+
if r.nil? || Utils.error_status?(r.status)
|
173
|
+
r = @sdk_configuration.hooks.after_error(
|
174
|
+
error: error,
|
175
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
176
|
+
hook_ctx: hook_ctx
|
177
|
+
),
|
178
|
+
response: r
|
179
|
+
)
|
180
|
+
else
|
181
|
+
r = @sdk_configuration.hooks.after_success(
|
182
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
183
|
+
hook_ctx: hook_ctx
|
184
|
+
),
|
185
|
+
response: r
|
186
|
+
)
|
187
|
+
end
|
188
|
+
|
189
|
+
if r.nil?
|
190
|
+
raise error if !error.nil?
|
191
|
+
raise 'no response'
|
192
|
+
end
|
90
193
|
end
|
91
194
|
|
92
195
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -115,8 +218,8 @@ module PlexRubySDK
|
|
115
218
|
end
|
116
219
|
|
117
220
|
|
118
|
-
sig { returns(::PlexRubySDK::Operations::GetTranscodeSessionsResponse) }
|
119
|
-
def get_transcode_sessions
|
221
|
+
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetTranscodeSessionsResponse) }
|
222
|
+
def get_transcode_sessions(timeout_ms = nil)
|
120
223
|
# get_transcode_sessions - Get Transcode Sessions
|
121
224
|
# Get Transcode Sessions
|
122
225
|
url, params = @sdk_configuration.get_server_details
|
@@ -126,10 +229,60 @@ module PlexRubySDK
|
|
126
229
|
headers['Accept'] = 'application/json'
|
127
230
|
headers['user-agent'] = @sdk_configuration.user_agent
|
128
231
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
232
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
233
|
+
|
234
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
235
|
+
timeout ||= @sdk_configuration.timeout
|
236
|
+
|
237
|
+
connection = @sdk_configuration.client
|
238
|
+
|
239
|
+
hook_ctx = SDKHooks::HookContext.new(
|
240
|
+
base_url: base_url,
|
241
|
+
oauth2_scopes: nil,
|
242
|
+
operation_id: 'getTranscodeSessions',
|
243
|
+
security_source: @sdk_configuration.security_source
|
244
|
+
)
|
245
|
+
|
246
|
+
error = T.let(nil, T.nilable(StandardError))
|
247
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
248
|
+
|
249
|
+
begin
|
250
|
+
r = connection.get(url) do |req|
|
251
|
+
req.headers.merge!(headers)
|
252
|
+
req.options.timeout = timeout unless timeout.nil?
|
253
|
+
Utils.configure_request_security(req, security)
|
254
|
+
|
255
|
+
@sdk_configuration.hooks.before_request(
|
256
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
257
|
+
hook_ctx: hook_ctx
|
258
|
+
),
|
259
|
+
request: req
|
260
|
+
)
|
261
|
+
end
|
262
|
+
rescue StandardError => e
|
263
|
+
error = e
|
264
|
+
ensure
|
265
|
+
if r.nil? || Utils.error_status?(r.status)
|
266
|
+
r = @sdk_configuration.hooks.after_error(
|
267
|
+
error: error,
|
268
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
269
|
+
hook_ctx: hook_ctx
|
270
|
+
),
|
271
|
+
response: r
|
272
|
+
)
|
273
|
+
else
|
274
|
+
r = @sdk_configuration.hooks.after_success(
|
275
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
276
|
+
hook_ctx: hook_ctx
|
277
|
+
),
|
278
|
+
response: r
|
279
|
+
)
|
280
|
+
end
|
281
|
+
|
282
|
+
if r.nil?
|
283
|
+
raise error if !error.nil?
|
284
|
+
raise 'no response'
|
285
|
+
end
|
133
286
|
end
|
134
287
|
|
135
288
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -158,8 +311,8 @@ module PlexRubySDK
|
|
158
311
|
end
|
159
312
|
|
160
313
|
|
161
|
-
sig { params(session_key: ::String).returns(::PlexRubySDK::Operations::StopTranscodeSessionResponse) }
|
162
|
-
def stop_transcode_session(session_key)
|
314
|
+
sig { params(session_key: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::StopTranscodeSessionResponse) }
|
315
|
+
def stop_transcode_session(session_key, timeout_ms = nil)
|
163
316
|
# stop_transcode_session - Stop a Transcode Session
|
164
317
|
# Stop a Transcode Session
|
165
318
|
request = ::PlexRubySDK::Operations::StopTranscodeSessionRequest.new(
|
@@ -178,10 +331,60 @@ module PlexRubySDK
|
|
178
331
|
headers['Accept'] = 'application/json'
|
179
332
|
headers['user-agent'] = @sdk_configuration.user_agent
|
180
333
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
334
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
335
|
+
|
336
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
337
|
+
timeout ||= @sdk_configuration.timeout
|
338
|
+
|
339
|
+
connection = @sdk_configuration.client
|
340
|
+
|
341
|
+
hook_ctx = SDKHooks::HookContext.new(
|
342
|
+
base_url: base_url,
|
343
|
+
oauth2_scopes: nil,
|
344
|
+
operation_id: 'stopTranscodeSession',
|
345
|
+
security_source: @sdk_configuration.security_source
|
346
|
+
)
|
347
|
+
|
348
|
+
error = T.let(nil, T.nilable(StandardError))
|
349
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
350
|
+
|
351
|
+
begin
|
352
|
+
r = connection.delete(url) do |req|
|
353
|
+
req.headers.merge!(headers)
|
354
|
+
req.options.timeout = timeout unless timeout.nil?
|
355
|
+
Utils.configure_request_security(req, security)
|
356
|
+
|
357
|
+
@sdk_configuration.hooks.before_request(
|
358
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
359
|
+
hook_ctx: hook_ctx
|
360
|
+
),
|
361
|
+
request: req
|
362
|
+
)
|
363
|
+
end
|
364
|
+
rescue StandardError => e
|
365
|
+
error = e
|
366
|
+
ensure
|
367
|
+
if r.nil? || Utils.error_status?(r.status)
|
368
|
+
r = @sdk_configuration.hooks.after_error(
|
369
|
+
error: error,
|
370
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
371
|
+
hook_ctx: hook_ctx
|
372
|
+
),
|
373
|
+
response: r
|
374
|
+
)
|
375
|
+
else
|
376
|
+
r = @sdk_configuration.hooks.after_success(
|
377
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
378
|
+
hook_ctx: hook_ctx
|
379
|
+
),
|
380
|
+
response: r
|
381
|
+
)
|
382
|
+
end
|
383
|
+
|
384
|
+
if r.nil?
|
385
|
+
raise error if !error.nil?
|
386
|
+
raise 'no response'
|
387
|
+
end
|
185
388
|
end
|
186
389
|
|
187
390
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -5,7 +5,10 @@
|
|
5
5
|
|
6
6
|
require 'faraday'
|
7
7
|
require 'faraday/multipart'
|
8
|
+
require 'faraday/retry'
|
8
9
|
require 'sorbet-runtime'
|
10
|
+
require_relative 'sdk_hooks/hooks'
|
11
|
+
require_relative 'utils/retries'
|
9
12
|
|
10
13
|
module PlexRubySDK
|
11
14
|
extend T::Sig
|
@@ -20,8 +23,8 @@ module PlexRubySDK
|
|
20
23
|
end
|
21
24
|
|
22
25
|
|
23
|
-
sig { params(timespan: T.nilable(::Integer)).returns(::PlexRubySDK::Operations::GetStatisticsResponse) }
|
24
|
-
def get_statistics(timespan = nil)
|
26
|
+
sig { params(timespan: T.nilable(::Integer), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetStatisticsResponse) }
|
27
|
+
def get_statistics(timespan = nil, timeout_ms = nil)
|
25
28
|
# get_statistics - Get Media Statistics
|
26
29
|
# This will return the media statistics for the server
|
27
30
|
request = ::PlexRubySDK::Operations::GetStatisticsRequest.new(
|
@@ -36,11 +39,61 @@ module PlexRubySDK
|
|
36
39
|
headers['Accept'] = 'application/json'
|
37
40
|
headers['user-agent'] = @sdk_configuration.user_agent
|
38
41
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
43
|
+
|
44
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
45
|
+
timeout ||= @sdk_configuration.timeout
|
46
|
+
|
47
|
+
connection = @sdk_configuration.client
|
48
|
+
|
49
|
+
hook_ctx = SDKHooks::HookContext.new(
|
50
|
+
base_url: base_url,
|
51
|
+
oauth2_scopes: nil,
|
52
|
+
operation_id: 'getStatistics',
|
53
|
+
security_source: @sdk_configuration.security_source
|
54
|
+
)
|
55
|
+
|
56
|
+
error = T.let(nil, T.nilable(StandardError))
|
57
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
58
|
+
|
59
|
+
begin
|
60
|
+
r = connection.get(url) do |req|
|
61
|
+
req.headers.merge!(headers)
|
62
|
+
req.options.timeout = timeout unless timeout.nil?
|
63
|
+
req.params = query_params
|
64
|
+
Utils.configure_request_security(req, security)
|
65
|
+
|
66
|
+
@sdk_configuration.hooks.before_request(
|
67
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
68
|
+
hook_ctx: hook_ctx
|
69
|
+
),
|
70
|
+
request: req
|
71
|
+
)
|
72
|
+
end
|
73
|
+
rescue StandardError => e
|
74
|
+
error = e
|
75
|
+
ensure
|
76
|
+
if r.nil? || Utils.error_status?(r.status)
|
77
|
+
r = @sdk_configuration.hooks.after_error(
|
78
|
+
error: error,
|
79
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
80
|
+
hook_ctx: hook_ctx
|
81
|
+
),
|
82
|
+
response: r
|
83
|
+
)
|
84
|
+
else
|
85
|
+
r = @sdk_configuration.hooks.after_success(
|
86
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
87
|
+
hook_ctx: hook_ctx
|
88
|
+
),
|
89
|
+
response: r
|
90
|
+
)
|
91
|
+
end
|
92
|
+
|
93
|
+
if r.nil?
|
94
|
+
raise error if !error.nil?
|
95
|
+
raise 'no response'
|
96
|
+
end
|
44
97
|
end
|
45
98
|
|
46
99
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -69,8 +122,8 @@ module PlexRubySDK
|
|
69
122
|
end
|
70
123
|
|
71
124
|
|
72
|
-
sig { params(timespan: T.nilable(::Integer)).returns(::PlexRubySDK::Operations::GetResourcesStatisticsResponse) }
|
73
|
-
def get_resources_statistics(timespan = nil)
|
125
|
+
sig { params(timespan: T.nilable(::Integer), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetResourcesStatisticsResponse) }
|
126
|
+
def get_resources_statistics(timespan = nil, timeout_ms = nil)
|
74
127
|
# get_resources_statistics - Get Resources Statistics
|
75
128
|
# This will return the resources for the server
|
76
129
|
request = ::PlexRubySDK::Operations::GetResourcesStatisticsRequest.new(
|
@@ -85,11 +138,61 @@ module PlexRubySDK
|
|
85
138
|
headers['Accept'] = 'application/json'
|
86
139
|
headers['user-agent'] = @sdk_configuration.user_agent
|
87
140
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
141
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
142
|
+
|
143
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
144
|
+
timeout ||= @sdk_configuration.timeout
|
145
|
+
|
146
|
+
connection = @sdk_configuration.client
|
147
|
+
|
148
|
+
hook_ctx = SDKHooks::HookContext.new(
|
149
|
+
base_url: base_url,
|
150
|
+
oauth2_scopes: nil,
|
151
|
+
operation_id: 'getResourcesStatistics',
|
152
|
+
security_source: @sdk_configuration.security_source
|
153
|
+
)
|
154
|
+
|
155
|
+
error = T.let(nil, T.nilable(StandardError))
|
156
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
157
|
+
|
158
|
+
begin
|
159
|
+
r = connection.get(url) do |req|
|
160
|
+
req.headers.merge!(headers)
|
161
|
+
req.options.timeout = timeout unless timeout.nil?
|
162
|
+
req.params = query_params
|
163
|
+
Utils.configure_request_security(req, security)
|
164
|
+
|
165
|
+
@sdk_configuration.hooks.before_request(
|
166
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
167
|
+
hook_ctx: hook_ctx
|
168
|
+
),
|
169
|
+
request: req
|
170
|
+
)
|
171
|
+
end
|
172
|
+
rescue StandardError => e
|
173
|
+
error = e
|
174
|
+
ensure
|
175
|
+
if r.nil? || Utils.error_status?(r.status)
|
176
|
+
r = @sdk_configuration.hooks.after_error(
|
177
|
+
error: error,
|
178
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
179
|
+
hook_ctx: hook_ctx
|
180
|
+
),
|
181
|
+
response: r
|
182
|
+
)
|
183
|
+
else
|
184
|
+
r = @sdk_configuration.hooks.after_success(
|
185
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
186
|
+
hook_ctx: hook_ctx
|
187
|
+
),
|
188
|
+
response: r
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
if r.nil?
|
193
|
+
raise error if !error.nil?
|
194
|
+
raise 'no response'
|
195
|
+
end
|
93
196
|
end
|
94
197
|
|
95
198
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|
@@ -118,8 +221,8 @@ module PlexRubySDK
|
|
118
221
|
end
|
119
222
|
|
120
223
|
|
121
|
-
sig { params(timespan: T.nilable(::Integer)).returns(::PlexRubySDK::Operations::GetBandwidthStatisticsResponse) }
|
122
|
-
def get_bandwidth_statistics(timespan = nil)
|
224
|
+
sig { params(timespan: T.nilable(::Integer), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetBandwidthStatisticsResponse) }
|
225
|
+
def get_bandwidth_statistics(timespan = nil, timeout_ms = nil)
|
123
226
|
# get_bandwidth_statistics - Get Bandwidth Statistics
|
124
227
|
# This will return the bandwidth statistics for the server
|
125
228
|
request = ::PlexRubySDK::Operations::GetBandwidthStatisticsRequest.new(
|
@@ -134,11 +237,61 @@ module PlexRubySDK
|
|
134
237
|
headers['Accept'] = 'application/json'
|
135
238
|
headers['user-agent'] = @sdk_configuration.user_agent
|
136
239
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
240
|
+
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
|
241
|
+
|
242
|
+
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
|
243
|
+
timeout ||= @sdk_configuration.timeout
|
244
|
+
|
245
|
+
connection = @sdk_configuration.client
|
246
|
+
|
247
|
+
hook_ctx = SDKHooks::HookContext.new(
|
248
|
+
base_url: base_url,
|
249
|
+
oauth2_scopes: nil,
|
250
|
+
operation_id: 'getBandwidthStatistics',
|
251
|
+
security_source: @sdk_configuration.security_source
|
252
|
+
)
|
253
|
+
|
254
|
+
error = T.let(nil, T.nilable(StandardError))
|
255
|
+
r = T.let(nil, T.nilable(Faraday::Response))
|
256
|
+
|
257
|
+
begin
|
258
|
+
r = connection.get(url) do |req|
|
259
|
+
req.headers.merge!(headers)
|
260
|
+
req.options.timeout = timeout unless timeout.nil?
|
261
|
+
req.params = query_params
|
262
|
+
Utils.configure_request_security(req, security)
|
263
|
+
|
264
|
+
@sdk_configuration.hooks.before_request(
|
265
|
+
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
|
266
|
+
hook_ctx: hook_ctx
|
267
|
+
),
|
268
|
+
request: req
|
269
|
+
)
|
270
|
+
end
|
271
|
+
rescue StandardError => e
|
272
|
+
error = e
|
273
|
+
ensure
|
274
|
+
if r.nil? || Utils.error_status?(r.status)
|
275
|
+
r = @sdk_configuration.hooks.after_error(
|
276
|
+
error: error,
|
277
|
+
hook_ctx: SDKHooks::AfterErrorHookContext.new(
|
278
|
+
hook_ctx: hook_ctx
|
279
|
+
),
|
280
|
+
response: r
|
281
|
+
)
|
282
|
+
else
|
283
|
+
r = @sdk_configuration.hooks.after_success(
|
284
|
+
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
|
285
|
+
hook_ctx: hook_ctx
|
286
|
+
),
|
287
|
+
response: r
|
288
|
+
)
|
289
|
+
end
|
290
|
+
|
291
|
+
if r.nil?
|
292
|
+
raise error if !error.nil?
|
293
|
+
raise 'no response'
|
294
|
+
end
|
142
295
|
end
|
143
296
|
|
144
297
|
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
|