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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plex_ruby_sdk/activities.rb +115 -12
  3. data/lib/plex_ruby_sdk/authentication.rb +233 -29
  4. data/lib/plex_ruby_sdk/butler.rb +283 -30
  5. data/lib/plex_ruby_sdk/hubs.rb +174 -21
  6. data/lib/plex_ruby_sdk/library.rb +1307 -110
  7. data/lib/plex_ruby_sdk/log.rb +179 -24
  8. data/lib/plex_ruby_sdk/media.rb +288 -35
  9. data/lib/plex_ruby_sdk/models/operations/get_media_arts_mediacontainer.rb +36 -0
  10. data/lib/plex_ruby_sdk/models/operations/get_media_arts_metadata.rb +36 -0
  11. data/lib/plex_ruby_sdk/models/operations/get_media_arts_request.rb +24 -0
  12. data/lib/plex_ruby_sdk/models/operations/get_media_arts_response.rb +33 -0
  13. data/lib/plex_ruby_sdk/models/operations/get_media_arts_responsebody.rb +24 -0
  14. data/lib/plex_ruby_sdk/models/operations/get_media_posters_mediacontainer.rb +36 -0
  15. data/lib/plex_ruby_sdk/models/operations/get_media_posters_metadata.rb +36 -0
  16. data/lib/plex_ruby_sdk/models/operations/get_media_posters_request.rb +24 -0
  17. data/lib/plex_ruby_sdk/models/operations/get_media_posters_response.rb +33 -0
  18. data/lib/plex_ruby_sdk/models/operations/get_media_posters_responsebody.rb +24 -0
  19. data/lib/plex_ruby_sdk/models/operations/post_media_arts_request.rb +30 -0
  20. data/lib/plex_ruby_sdk/models/operations/post_media_arts_response.rb +30 -0
  21. data/lib/plex_ruby_sdk/models/operations/post_media_poster_request.rb +30 -0
  22. data/lib/plex_ruby_sdk/models/operations/post_media_poster_response.rb +30 -0
  23. data/lib/plex_ruby_sdk/models/operations.rb +14 -0
  24. data/lib/plex_ruby_sdk/playlists.rb +513 -60
  25. data/lib/plex_ruby_sdk/plex.rb +388 -38
  26. data/lib/plex_ruby_sdk/plex_api.rb +29 -10
  27. data/lib/plex_ruby_sdk/sdk_hooks/hooks.rb +103 -0
  28. data/lib/plex_ruby_sdk/sdk_hooks/registration.rb +35 -0
  29. data/lib/plex_ruby_sdk/sdk_hooks/types.rb +152 -0
  30. data/lib/plex_ruby_sdk/sdkconfiguration.rb +26 -7
  31. data/lib/plex_ruby_sdk/search.rb +174 -21
  32. data/lib/plex_ruby_sdk/server.rb +505 -53
  33. data/lib/plex_ruby_sdk/sessions.rb +228 -25
  34. data/lib/plex_ruby_sdk/statistics.rb +174 -21
  35. data/lib/plex_ruby_sdk/updater.rb +173 -20
  36. data/lib/plex_ruby_sdk/users.rb +56 -4
  37. data/lib/plex_ruby_sdk/utils/retries.rb +95 -0
  38. data/lib/plex_ruby_sdk/utils/utils.rb +10 -0
  39. data/lib/plex_ruby_sdk/video.rb +117 -14
  40. data/lib/plex_ruby_sdk/watchlist.rb +60 -7
  41. 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::GetServerCapabilitiesResponse) }
24
- def get_server_capabilities
26
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerCapabilitiesResponse) }
27
+ def get_server_capabilities(timeout_ms = nil)
25
28
  # get_server_capabilities - Get Server Capabilities
26
29
  # Get Server Capabilities
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
- r = @sdk_configuration.client.get(url) do |req|
35
- req.headers = headers
36
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
37
- Utils.configure_request_security(req, security) if !security.nil?
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: 'getServerCapabilities',
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 { returns(::PlexRubySDK::Operations::GetServerPreferencesResponse) }
67
- def get_server_preferences
119
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerPreferencesResponse) }
120
+ def get_server_preferences(timeout_ms = nil)
68
121
  # get_server_preferences - Get Server Preferences
69
122
  # Get Server Preferences
70
123
  url, params = @sdk_configuration.get_server_details
@@ -74,10 +127,60 @@ module PlexRubySDK
74
127
  headers['Accept'] = 'application/json'
75
128
  headers['user-agent'] = @sdk_configuration.user_agent
76
129
 
77
- r = @sdk_configuration.client.get(url) do |req|
78
- req.headers = headers
79
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
80
- Utils.configure_request_security(req, security) if !security.nil?
130
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
131
+
132
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
133
+ timeout ||= @sdk_configuration.timeout
134
+
135
+ connection = @sdk_configuration.client
136
+
137
+ hook_ctx = SDKHooks::HookContext.new(
138
+ base_url: base_url,
139
+ oauth2_scopes: nil,
140
+ operation_id: 'getServerPreferences',
141
+ security_source: @sdk_configuration.security_source
142
+ )
143
+
144
+ error = T.let(nil, T.nilable(StandardError))
145
+ r = T.let(nil, T.nilable(Faraday::Response))
146
+
147
+ begin
148
+ r = connection.get(url) do |req|
149
+ req.headers.merge!(headers)
150
+ req.options.timeout = timeout unless timeout.nil?
151
+ Utils.configure_request_security(req, security)
152
+
153
+ @sdk_configuration.hooks.before_request(
154
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
155
+ hook_ctx: hook_ctx
156
+ ),
157
+ request: req
158
+ )
159
+ end
160
+ rescue StandardError => e
161
+ error = e
162
+ ensure
163
+ if r.nil? || Utils.error_status?(r.status)
164
+ r = @sdk_configuration.hooks.after_error(
165
+ error: error,
166
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
167
+ hook_ctx: hook_ctx
168
+ ),
169
+ response: r
170
+ )
171
+ else
172
+ r = @sdk_configuration.hooks.after_success(
173
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
174
+ hook_ctx: hook_ctx
175
+ ),
176
+ response: r
177
+ )
178
+ end
179
+
180
+ if r.nil?
181
+ raise error if !error.nil?
182
+ raise 'no response'
183
+ end
81
184
  end
82
185
 
83
186
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -106,8 +209,8 @@ module PlexRubySDK
106
209
  end
107
210
 
108
211
 
109
- sig { returns(::PlexRubySDK::Operations::GetAvailableClientsResponse) }
110
- def get_available_clients
212
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetAvailableClientsResponse) }
213
+ def get_available_clients(timeout_ms = nil)
111
214
  # get_available_clients - Get Available Clients
112
215
  # Get Available Clients
113
216
  url, params = @sdk_configuration.get_server_details
@@ -117,10 +220,60 @@ module PlexRubySDK
117
220
  headers['Accept'] = 'application/json'
118
221
  headers['user-agent'] = @sdk_configuration.user_agent
119
222
 
120
- r = @sdk_configuration.client.get(url) do |req|
121
- req.headers = headers
122
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
123
- Utils.configure_request_security(req, security) if !security.nil?
223
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
224
+
225
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
226
+ timeout ||= @sdk_configuration.timeout
227
+
228
+ connection = @sdk_configuration.client
229
+
230
+ hook_ctx = SDKHooks::HookContext.new(
231
+ base_url: base_url,
232
+ oauth2_scopes: nil,
233
+ operation_id: 'getAvailableClients',
234
+ security_source: @sdk_configuration.security_source
235
+ )
236
+
237
+ error = T.let(nil, T.nilable(StandardError))
238
+ r = T.let(nil, T.nilable(Faraday::Response))
239
+
240
+ begin
241
+ r = connection.get(url) do |req|
242
+ req.headers.merge!(headers)
243
+ req.options.timeout = timeout unless timeout.nil?
244
+ Utils.configure_request_security(req, security)
245
+
246
+ @sdk_configuration.hooks.before_request(
247
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
248
+ hook_ctx: hook_ctx
249
+ ),
250
+ request: req
251
+ )
252
+ end
253
+ rescue StandardError => e
254
+ error = e
255
+ ensure
256
+ if r.nil? || Utils.error_status?(r.status)
257
+ r = @sdk_configuration.hooks.after_error(
258
+ error: error,
259
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
260
+ hook_ctx: hook_ctx
261
+ ),
262
+ response: r
263
+ )
264
+ else
265
+ r = @sdk_configuration.hooks.after_success(
266
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
267
+ hook_ctx: hook_ctx
268
+ ),
269
+ response: r
270
+ )
271
+ end
272
+
273
+ if r.nil?
274
+ raise error if !error.nil?
275
+ raise 'no response'
276
+ end
124
277
  end
125
278
 
126
279
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -149,8 +302,8 @@ module PlexRubySDK
149
302
  end
150
303
 
151
304
 
152
- sig { returns(::PlexRubySDK::Operations::GetDevicesResponse) }
153
- def get_devices
305
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetDevicesResponse) }
306
+ def get_devices(timeout_ms = nil)
154
307
  # get_devices - Get Devices
155
308
  # Get Devices
156
309
  url, params = @sdk_configuration.get_server_details
@@ -160,10 +313,60 @@ module PlexRubySDK
160
313
  headers['Accept'] = 'application/json'
161
314
  headers['user-agent'] = @sdk_configuration.user_agent
162
315
 
163
- r = @sdk_configuration.client.get(url) do |req|
164
- req.headers = headers
165
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
166
- Utils.configure_request_security(req, security) if !security.nil?
316
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
317
+
318
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
319
+ timeout ||= @sdk_configuration.timeout
320
+
321
+ connection = @sdk_configuration.client
322
+
323
+ hook_ctx = SDKHooks::HookContext.new(
324
+ base_url: base_url,
325
+ oauth2_scopes: nil,
326
+ operation_id: 'getDevices',
327
+ security_source: @sdk_configuration.security_source
328
+ )
329
+
330
+ error = T.let(nil, T.nilable(StandardError))
331
+ r = T.let(nil, T.nilable(Faraday::Response))
332
+
333
+ begin
334
+ r = connection.get(url) do |req|
335
+ req.headers.merge!(headers)
336
+ req.options.timeout = timeout unless timeout.nil?
337
+ Utils.configure_request_security(req, security)
338
+
339
+ @sdk_configuration.hooks.before_request(
340
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
341
+ hook_ctx: hook_ctx
342
+ ),
343
+ request: req
344
+ )
345
+ end
346
+ rescue StandardError => e
347
+ error = e
348
+ ensure
349
+ if r.nil? || Utils.error_status?(r.status)
350
+ r = @sdk_configuration.hooks.after_error(
351
+ error: error,
352
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
353
+ hook_ctx: hook_ctx
354
+ ),
355
+ response: r
356
+ )
357
+ else
358
+ r = @sdk_configuration.hooks.after_success(
359
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
360
+ hook_ctx: hook_ctx
361
+ ),
362
+ response: r
363
+ )
364
+ end
365
+
366
+ if r.nil?
367
+ raise error if !error.nil?
368
+ raise 'no response'
369
+ end
167
370
  end
168
371
 
169
372
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -192,8 +395,8 @@ module PlexRubySDK
192
395
  end
193
396
 
194
397
 
195
- sig { returns(::PlexRubySDK::Operations::GetServerIdentityResponse) }
196
- def get_server_identity
398
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerIdentityResponse) }
399
+ def get_server_identity(timeout_ms = nil)
197
400
  # get_server_identity - Get Server Identity
198
401
  # This request is useful to determine if the server is online or offline
199
402
  url, params = @sdk_configuration.get_server_details
@@ -203,8 +406,57 @@ module PlexRubySDK
203
406
  headers['Accept'] = 'application/json'
204
407
  headers['user-agent'] = @sdk_configuration.user_agent
205
408
 
206
- r = @sdk_configuration.client.get(url) do |req|
207
- req.headers = headers
409
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
410
+ timeout ||= @sdk_configuration.timeout
411
+
412
+ connection = @sdk_configuration.client
413
+
414
+ hook_ctx = SDKHooks::HookContext.new(
415
+ base_url: base_url,
416
+ oauth2_scopes: nil,
417
+ operation_id: 'get-server-identity',
418
+ security_source: nil
419
+ )
420
+
421
+ error = T.let(nil, T.nilable(StandardError))
422
+ r = T.let(nil, T.nilable(Faraday::Response))
423
+
424
+ begin
425
+ r = connection.get(url) do |req|
426
+ req.headers.merge!(headers)
427
+ req.options.timeout = timeout unless timeout.nil?
428
+
429
+ @sdk_configuration.hooks.before_request(
430
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
431
+ hook_ctx: hook_ctx
432
+ ),
433
+ request: req
434
+ )
435
+ end
436
+ rescue StandardError => e
437
+ error = e
438
+ ensure
439
+ if r.nil? || Utils.error_status?(r.status)
440
+ r = @sdk_configuration.hooks.after_error(
441
+ error: error,
442
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
443
+ hook_ctx: hook_ctx
444
+ ),
445
+ response: r
446
+ )
447
+ else
448
+ r = @sdk_configuration.hooks.after_success(
449
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
450
+ hook_ctx: hook_ctx
451
+ ),
452
+ response: r
453
+ )
454
+ end
455
+
456
+ if r.nil?
457
+ raise error if !error.nil?
458
+ raise 'no response'
459
+ end
208
460
  end
209
461
 
210
462
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -228,8 +480,8 @@ module PlexRubySDK
228
480
  end
229
481
 
230
482
 
231
- sig { returns(::PlexRubySDK::Operations::GetMyPlexAccountResponse) }
232
- def get_my_plex_account
483
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetMyPlexAccountResponse) }
484
+ def get_my_plex_account(timeout_ms = nil)
233
485
  # get_my_plex_account - Get MyPlex Account
234
486
  # Returns MyPlex Account Information
235
487
  url, params = @sdk_configuration.get_server_details
@@ -239,10 +491,60 @@ module PlexRubySDK
239
491
  headers['Accept'] = 'application/json'
240
492
  headers['user-agent'] = @sdk_configuration.user_agent
241
493
 
242
- r = @sdk_configuration.client.get(url) do |req|
243
- req.headers = headers
244
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
245
- Utils.configure_request_security(req, security) if !security.nil?
494
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
495
+
496
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
497
+ timeout ||= @sdk_configuration.timeout
498
+
499
+ connection = @sdk_configuration.client
500
+
501
+ hook_ctx = SDKHooks::HookContext.new(
502
+ base_url: base_url,
503
+ oauth2_scopes: nil,
504
+ operation_id: 'getMyPlexAccount',
505
+ security_source: @sdk_configuration.security_source
506
+ )
507
+
508
+ error = T.let(nil, T.nilable(StandardError))
509
+ r = T.let(nil, T.nilable(Faraday::Response))
510
+
511
+ begin
512
+ r = connection.get(url) do |req|
513
+ req.headers.merge!(headers)
514
+ req.options.timeout = timeout unless timeout.nil?
515
+ Utils.configure_request_security(req, security)
516
+
517
+ @sdk_configuration.hooks.before_request(
518
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
519
+ hook_ctx: hook_ctx
520
+ ),
521
+ request: req
522
+ )
523
+ end
524
+ rescue StandardError => e
525
+ error = e
526
+ ensure
527
+ if r.nil? || Utils.error_status?(r.status)
528
+ r = @sdk_configuration.hooks.after_error(
529
+ error: error,
530
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
531
+ hook_ctx: hook_ctx
532
+ ),
533
+ response: r
534
+ )
535
+ else
536
+ r = @sdk_configuration.hooks.after_success(
537
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
538
+ hook_ctx: hook_ctx
539
+ ),
540
+ response: r
541
+ )
542
+ end
543
+
544
+ if r.nil?
545
+ raise error if !error.nil?
546
+ raise 'no response'
547
+ end
246
548
  end
247
549
 
248
550
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -271,8 +573,8 @@ module PlexRubySDK
271
573
  end
272
574
 
273
575
 
274
- sig { params(request: T.nilable(::PlexRubySDK::Operations::GetResizedPhotoRequest)).returns(::PlexRubySDK::Operations::GetResizedPhotoResponse) }
275
- def get_resized_photo(request)
576
+ sig { params(request: T.nilable(::PlexRubySDK::Operations::GetResizedPhotoRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetResizedPhotoResponse) }
577
+ def get_resized_photo(request, timeout_ms = nil)
276
578
  # get_resized_photo - Get a Resized Photo
277
579
  # Plex's Photo transcoder is used throughout the service to serve images at specified sizes.
278
580
  #
@@ -284,11 +586,61 @@ module PlexRubySDK
284
586
  headers['Accept'] = 'application/json'
285
587
  headers['user-agent'] = @sdk_configuration.user_agent
286
588
 
287
- r = @sdk_configuration.client.get(url) do |req|
288
- req.headers = headers
289
- req.params = query_params
290
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
291
- Utils.configure_request_security(req, security) if !security.nil?
589
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
590
+
591
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
592
+ timeout ||= @sdk_configuration.timeout
593
+
594
+ connection = @sdk_configuration.client
595
+
596
+ hook_ctx = SDKHooks::HookContext.new(
597
+ base_url: base_url,
598
+ oauth2_scopes: nil,
599
+ operation_id: 'getResizedPhoto',
600
+ security_source: @sdk_configuration.security_source
601
+ )
602
+
603
+ error = T.let(nil, T.nilable(StandardError))
604
+ r = T.let(nil, T.nilable(Faraday::Response))
605
+
606
+ begin
607
+ r = connection.get(url) do |req|
608
+ req.headers.merge!(headers)
609
+ req.options.timeout = timeout unless timeout.nil?
610
+ req.params = query_params
611
+ Utils.configure_request_security(req, security)
612
+
613
+ @sdk_configuration.hooks.before_request(
614
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
615
+ hook_ctx: hook_ctx
616
+ ),
617
+ request: req
618
+ )
619
+ end
620
+ rescue StandardError => e
621
+ error = e
622
+ ensure
623
+ if r.nil? || Utils.error_status?(r.status)
624
+ r = @sdk_configuration.hooks.after_error(
625
+ error: error,
626
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
627
+ hook_ctx: hook_ctx
628
+ ),
629
+ response: r
630
+ )
631
+ else
632
+ r = @sdk_configuration.hooks.after_success(
633
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
634
+ hook_ctx: hook_ctx
635
+ ),
636
+ response: r
637
+ )
638
+ end
639
+
640
+ if r.nil?
641
+ raise error if !error.nil?
642
+ raise 'no response'
643
+ end
292
644
  end
293
645
 
294
646
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -313,8 +665,8 @@ module PlexRubySDK
313
665
  end
314
666
 
315
667
 
316
- sig { params(x_plex_token: ::String).returns(::PlexRubySDK::Operations::GetMediaProvidersResponse) }
317
- def get_media_providers(x_plex_token)
668
+ sig { params(x_plex_token: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetMediaProvidersResponse) }
669
+ def get_media_providers(x_plex_token, timeout_ms = nil)
318
670
  # get_media_providers - Get Media Providers
319
671
  # Retrieves media providers and their features from the Plex server.
320
672
  request = ::PlexRubySDK::Operations::GetMediaProvidersRequest.new(
@@ -328,10 +680,60 @@ module PlexRubySDK
328
680
  headers['Accept'] = 'application/json'
329
681
  headers['user-agent'] = @sdk_configuration.user_agent
330
682
 
331
- r = @sdk_configuration.client.get(url) do |req|
332
- req.headers = headers
333
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
334
- Utils.configure_request_security(req, security) if !security.nil?
683
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
684
+
685
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
686
+ timeout ||= @sdk_configuration.timeout
687
+
688
+ connection = @sdk_configuration.client
689
+
690
+ hook_ctx = SDKHooks::HookContext.new(
691
+ base_url: base_url,
692
+ oauth2_scopes: nil,
693
+ operation_id: 'get-media-providers',
694
+ security_source: @sdk_configuration.security_source
695
+ )
696
+
697
+ error = T.let(nil, T.nilable(StandardError))
698
+ r = T.let(nil, T.nilable(Faraday::Response))
699
+
700
+ begin
701
+ r = connection.get(url) do |req|
702
+ req.headers.merge!(headers)
703
+ req.options.timeout = timeout unless timeout.nil?
704
+ Utils.configure_request_security(req, security)
705
+
706
+ @sdk_configuration.hooks.before_request(
707
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
708
+ hook_ctx: hook_ctx
709
+ ),
710
+ request: req
711
+ )
712
+ end
713
+ rescue StandardError => e
714
+ error = e
715
+ ensure
716
+ if r.nil? || Utils.error_status?(r.status)
717
+ r = @sdk_configuration.hooks.after_error(
718
+ error: error,
719
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
720
+ hook_ctx: hook_ctx
721
+ ),
722
+ response: r
723
+ )
724
+ else
725
+ r = @sdk_configuration.hooks.after_success(
726
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
727
+ hook_ctx: hook_ctx
728
+ ),
729
+ response: r
730
+ )
731
+ end
732
+
733
+ if r.nil?
734
+ raise error if !error.nil?
735
+ raise 'no response'
736
+ end
335
737
  end
336
738
 
337
739
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -360,8 +762,8 @@ module PlexRubySDK
360
762
  end
361
763
 
362
764
 
363
- sig { returns(::PlexRubySDK::Operations::GetServerListResponse) }
364
- def get_server_list
765
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerListResponse) }
766
+ def get_server_list(timeout_ms = nil)
365
767
  # get_server_list - Get Server List
366
768
  # Get Server List
367
769
  url, params = @sdk_configuration.get_server_details
@@ -371,10 +773,60 @@ module PlexRubySDK
371
773
  headers['Accept'] = 'application/json'
372
774
  headers['user-agent'] = @sdk_configuration.user_agent
373
775
 
374
- r = @sdk_configuration.client.get(url) do |req|
375
- req.headers = headers
376
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
377
- Utils.configure_request_security(req, security) if !security.nil?
776
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
777
+
778
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
779
+ timeout ||= @sdk_configuration.timeout
780
+
781
+ connection = @sdk_configuration.client
782
+
783
+ hook_ctx = SDKHooks::HookContext.new(
784
+ base_url: base_url,
785
+ oauth2_scopes: nil,
786
+ operation_id: 'getServerList',
787
+ security_source: @sdk_configuration.security_source
788
+ )
789
+
790
+ error = T.let(nil, T.nilable(StandardError))
791
+ r = T.let(nil, T.nilable(Faraday::Response))
792
+
793
+ begin
794
+ r = connection.get(url) do |req|
795
+ req.headers.merge!(headers)
796
+ req.options.timeout = timeout unless timeout.nil?
797
+ Utils.configure_request_security(req, security)
798
+
799
+ @sdk_configuration.hooks.before_request(
800
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
801
+ hook_ctx: hook_ctx
802
+ ),
803
+ request: req
804
+ )
805
+ end
806
+ rescue StandardError => e
807
+ error = e
808
+ ensure
809
+ if r.nil? || Utils.error_status?(r.status)
810
+ r = @sdk_configuration.hooks.after_error(
811
+ error: error,
812
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
813
+ hook_ctx: hook_ctx
814
+ ),
815
+ response: r
816
+ )
817
+ else
818
+ r = @sdk_configuration.hooks.after_success(
819
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
820
+ hook_ctx: hook_ctx
821
+ ),
822
+ response: r
823
+ )
824
+ end
825
+
826
+ if r.nil?
827
+ raise error if !error.nil?
828
+ raise 'no response'
829
+ end
378
830
  end
379
831
 
380
832
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')