plex_ruby_sdk 0.7.7 → 0.8.0

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.
@@ -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::GetButlerTasksResponse) }
24
- def get_butler_tasks
26
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetButlerTasksResponse) }
27
+ def get_butler_tasks(timeout_ms = nil)
25
28
  # get_butler_tasks - Get Butler tasks
26
29
  # Returns a list of butler tasks
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: 'getButlerTasks',
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::StartAllTasksResponse) }
67
- def start_all_tasks
119
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::StartAllTasksResponse) }
120
+ def start_all_tasks(timeout_ms = nil)
68
121
  # start_all_tasks - Start all Butler tasks
69
122
  # This endpoint will attempt to start all Butler tasks that are enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
70
123
  # 1. Any tasks not scheduled to run on the current day will be skipped.
@@ -79,10 +132,60 @@ module PlexRubySDK
79
132
  headers['Accept'] = 'application/json'
80
133
  headers['user-agent'] = @sdk_configuration.user_agent
81
134
 
82
- r = @sdk_configuration.client.post(url) do |req|
83
- req.headers = headers
84
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
85
- Utils.configure_request_security(req, security) if !security.nil?
135
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
136
+
137
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
138
+ timeout ||= @sdk_configuration.timeout
139
+
140
+ connection = @sdk_configuration.client
141
+
142
+ hook_ctx = SDKHooks::HookContext.new(
143
+ base_url: base_url,
144
+ oauth2_scopes: nil,
145
+ operation_id: 'startAllTasks',
146
+ security_source: @sdk_configuration.security_source
147
+ )
148
+
149
+ error = T.let(nil, T.nilable(StandardError))
150
+ r = T.let(nil, T.nilable(Faraday::Response))
151
+
152
+ begin
153
+ r = connection.post(url) do |req|
154
+ req.headers.merge!(headers)
155
+ req.options.timeout = timeout unless timeout.nil?
156
+ Utils.configure_request_security(req, security)
157
+
158
+ @sdk_configuration.hooks.before_request(
159
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
160
+ hook_ctx: hook_ctx
161
+ ),
162
+ request: req
163
+ )
164
+ end
165
+ rescue StandardError => e
166
+ error = e
167
+ ensure
168
+ if r.nil? || Utils.error_status?(r.status)
169
+ r = @sdk_configuration.hooks.after_error(
170
+ error: error,
171
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
172
+ hook_ctx: hook_ctx
173
+ ),
174
+ response: r
175
+ )
176
+ else
177
+ r = @sdk_configuration.hooks.after_success(
178
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
179
+ hook_ctx: hook_ctx
180
+ ),
181
+ response: r
182
+ )
183
+ end
184
+
185
+ if r.nil?
186
+ raise error if !error.nil?
187
+ raise 'no response'
188
+ end
86
189
  end
87
190
 
88
191
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -107,8 +210,8 @@ module PlexRubySDK
107
210
  end
108
211
 
109
212
 
110
- sig { returns(::PlexRubySDK::Operations::StopAllTasksResponse) }
111
- def stop_all_tasks
213
+ sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::StopAllTasksResponse) }
214
+ def stop_all_tasks(timeout_ms = nil)
112
215
  # stop_all_tasks - Stop all Butler tasks
113
216
  # This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
114
217
  #
@@ -119,10 +222,60 @@ module PlexRubySDK
119
222
  headers['Accept'] = 'application/json'
120
223
  headers['user-agent'] = @sdk_configuration.user_agent
121
224
 
122
- r = @sdk_configuration.client.delete(url) do |req|
123
- req.headers = headers
124
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
125
- Utils.configure_request_security(req, security) if !security.nil?
225
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
226
+
227
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
228
+ timeout ||= @sdk_configuration.timeout
229
+
230
+ connection = @sdk_configuration.client
231
+
232
+ hook_ctx = SDKHooks::HookContext.new(
233
+ base_url: base_url,
234
+ oauth2_scopes: nil,
235
+ operation_id: 'stopAllTasks',
236
+ security_source: @sdk_configuration.security_source
237
+ )
238
+
239
+ error = T.let(nil, T.nilable(StandardError))
240
+ r = T.let(nil, T.nilable(Faraday::Response))
241
+
242
+ begin
243
+ r = connection.delete(url) do |req|
244
+ req.headers.merge!(headers)
245
+ req.options.timeout = timeout unless timeout.nil?
246
+ Utils.configure_request_security(req, security)
247
+
248
+ @sdk_configuration.hooks.before_request(
249
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
250
+ hook_ctx: hook_ctx
251
+ ),
252
+ request: req
253
+ )
254
+ end
255
+ rescue StandardError => e
256
+ error = e
257
+ ensure
258
+ if r.nil? || Utils.error_status?(r.status)
259
+ r = @sdk_configuration.hooks.after_error(
260
+ error: error,
261
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
262
+ hook_ctx: hook_ctx
263
+ ),
264
+ response: r
265
+ )
266
+ else
267
+ r = @sdk_configuration.hooks.after_success(
268
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
269
+ hook_ctx: hook_ctx
270
+ ),
271
+ response: r
272
+ )
273
+ end
274
+
275
+ if r.nil?
276
+ raise error if !error.nil?
277
+ raise 'no response'
278
+ end
126
279
  end
127
280
 
128
281
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -147,8 +300,8 @@ module PlexRubySDK
147
300
  end
148
301
 
149
302
 
150
- sig { params(task_name: ::PlexRubySDK::Operations::TaskName).returns(::PlexRubySDK::Operations::StartTaskResponse) }
151
- def start_task(task_name)
303
+ sig { params(task_name: ::PlexRubySDK::Operations::TaskName, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::StartTaskResponse) }
304
+ def start_task(task_name, timeout_ms = nil)
152
305
  # start_task - Start a single Butler task
153
306
  # This endpoint will attempt to start a single Butler task that is enabled in the settings. Butler tasks normally run automatically during a time window configured on the server's Settings page but can be manually started using this endpoint. Tasks will run with the following criteria:
154
307
  # 1. Any tasks not scheduled to run on the current day will be skipped.
@@ -172,10 +325,60 @@ module PlexRubySDK
172
325
  headers['Accept'] = 'application/json'
173
326
  headers['user-agent'] = @sdk_configuration.user_agent
174
327
 
175
- r = @sdk_configuration.client.post(url) do |req|
176
- req.headers = headers
177
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
178
- Utils.configure_request_security(req, security) if !security.nil?
328
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
329
+
330
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
331
+ timeout ||= @sdk_configuration.timeout
332
+
333
+ connection = @sdk_configuration.client
334
+
335
+ hook_ctx = SDKHooks::HookContext.new(
336
+ base_url: base_url,
337
+ oauth2_scopes: nil,
338
+ operation_id: 'startTask',
339
+ security_source: @sdk_configuration.security_source
340
+ )
341
+
342
+ error = T.let(nil, T.nilable(StandardError))
343
+ r = T.let(nil, T.nilable(Faraday::Response))
344
+
345
+ begin
346
+ r = connection.post(url) do |req|
347
+ req.headers.merge!(headers)
348
+ req.options.timeout = timeout unless timeout.nil?
349
+ Utils.configure_request_security(req, security)
350
+
351
+ @sdk_configuration.hooks.before_request(
352
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
353
+ hook_ctx: hook_ctx
354
+ ),
355
+ request: req
356
+ )
357
+ end
358
+ rescue StandardError => e
359
+ error = e
360
+ ensure
361
+ if r.nil? || Utils.error_status?(r.status)
362
+ r = @sdk_configuration.hooks.after_error(
363
+ error: error,
364
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
365
+ hook_ctx: hook_ctx
366
+ ),
367
+ response: r
368
+ )
369
+ else
370
+ r = @sdk_configuration.hooks.after_success(
371
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
372
+ hook_ctx: hook_ctx
373
+ ),
374
+ response: r
375
+ )
376
+ end
377
+
378
+ if r.nil?
379
+ raise error if !error.nil?
380
+ raise 'no response'
381
+ end
179
382
  end
180
383
 
181
384
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -200,8 +403,8 @@ module PlexRubySDK
200
403
  end
201
404
 
202
405
 
203
- sig { params(task_name: ::PlexRubySDK::Operations::PathParamTaskName).returns(::PlexRubySDK::Operations::StopTaskResponse) }
204
- def stop_task(task_name)
406
+ sig { params(task_name: ::PlexRubySDK::Operations::PathParamTaskName, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::StopTaskResponse) }
407
+ def stop_task(task_name, timeout_ms = nil)
205
408
  # stop_task - Stop a single Butler task
206
409
  # This endpoint will stop a currently running task by name, or remove it from the list of scheduled tasks if it exists. See the section above for a list of task names for this endpoint.
207
410
  #
@@ -221,10 +424,60 @@ module PlexRubySDK
221
424
  headers['Accept'] = 'application/json'
222
425
  headers['user-agent'] = @sdk_configuration.user_agent
223
426
 
224
- r = @sdk_configuration.client.delete(url) do |req|
225
- req.headers = headers
226
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
227
- Utils.configure_request_security(req, security) if !security.nil?
427
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
428
+
429
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
430
+ timeout ||= @sdk_configuration.timeout
431
+
432
+ connection = @sdk_configuration.client
433
+
434
+ hook_ctx = SDKHooks::HookContext.new(
435
+ base_url: base_url,
436
+ oauth2_scopes: nil,
437
+ operation_id: 'stopTask',
438
+ security_source: @sdk_configuration.security_source
439
+ )
440
+
441
+ error = T.let(nil, T.nilable(StandardError))
442
+ r = T.let(nil, T.nilable(Faraday::Response))
443
+
444
+ begin
445
+ r = connection.delete(url) do |req|
446
+ req.headers.merge!(headers)
447
+ req.options.timeout = timeout unless timeout.nil?
448
+ Utils.configure_request_security(req, security)
449
+
450
+ @sdk_configuration.hooks.before_request(
451
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
452
+ hook_ctx: hook_ctx
453
+ ),
454
+ request: req
455
+ )
456
+ end
457
+ rescue StandardError => e
458
+ error = e
459
+ ensure
460
+ if r.nil? || Utils.error_status?(r.status)
461
+ r = @sdk_configuration.hooks.after_error(
462
+ error: error,
463
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
464
+ hook_ctx: hook_ctx
465
+ ),
466
+ response: r
467
+ )
468
+ else
469
+ r = @sdk_configuration.hooks.after_success(
470
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
471
+ hook_ctx: hook_ctx
472
+ ),
473
+ response: r
474
+ )
475
+ end
476
+
477
+ if r.nil?
478
+ raise error if !error.nil?
479
+ raise 'no response'
480
+ end
228
481
  end
229
482
 
230
483
  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(count: T.nilable(::Float), only_transient: T.nilable(::PlexRubySDK::Operations::OnlyTransient)).returns(::PlexRubySDK::Operations::GetGlobalHubsResponse) }
24
- def get_global_hubs(count = nil, only_transient = nil)
26
+ sig { params(count: T.nilable(::Float), only_transient: T.nilable(::PlexRubySDK::Operations::OnlyTransient), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetGlobalHubsResponse) }
27
+ def get_global_hubs(count = nil, only_transient = nil, timeout_ms = nil)
25
28
  # get_global_hubs - Get Global Hubs
26
29
  # Get Global Hubs filtered by the parameters provided.
27
30
  request = ::PlexRubySDK::Operations::GetGlobalHubsRequest.new(
@@ -37,11 +40,61 @@ module PlexRubySDK
37
40
  headers['Accept'] = 'application/json'
38
41
  headers['user-agent'] = @sdk_configuration.user_agent
39
42
 
40
- r = @sdk_configuration.client.get(url) do |req|
41
- req.headers = headers
42
- req.params = query_params
43
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
44
- Utils.configure_request_security(req, security) if !security.nil?
43
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
44
+
45
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
46
+ timeout ||= @sdk_configuration.timeout
47
+
48
+ connection = @sdk_configuration.client
49
+
50
+ hook_ctx = SDKHooks::HookContext.new(
51
+ base_url: base_url,
52
+ oauth2_scopes: nil,
53
+ operation_id: 'getGlobalHubs',
54
+ security_source: @sdk_configuration.security_source
55
+ )
56
+
57
+ error = T.let(nil, T.nilable(StandardError))
58
+ r = T.let(nil, T.nilable(Faraday::Response))
59
+
60
+ begin
61
+ r = connection.get(url) do |req|
62
+ req.headers.merge!(headers)
63
+ req.options.timeout = timeout unless timeout.nil?
64
+ req.params = query_params
65
+ Utils.configure_request_security(req, security)
66
+
67
+ @sdk_configuration.hooks.before_request(
68
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
69
+ hook_ctx: hook_ctx
70
+ ),
71
+ request: req
72
+ )
73
+ end
74
+ rescue StandardError => e
75
+ error = e
76
+ ensure
77
+ if r.nil? || Utils.error_status?(r.status)
78
+ r = @sdk_configuration.hooks.after_error(
79
+ error: error,
80
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
81
+ hook_ctx: hook_ctx
82
+ ),
83
+ response: r
84
+ )
85
+ else
86
+ r = @sdk_configuration.hooks.after_success(
87
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
88
+ hook_ctx: hook_ctx
89
+ ),
90
+ response: r
91
+ )
92
+ end
93
+
94
+ if r.nil?
95
+ raise error if !error.nil?
96
+ raise 'no response'
97
+ end
45
98
  end
46
99
 
47
100
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -70,8 +123,8 @@ module PlexRubySDK
70
123
  end
71
124
 
72
125
 
73
- sig { params(request: T.nilable(::PlexRubySDK::Operations::GetRecentlyAddedRequest)).returns(::PlexRubySDK::Operations::GetRecentlyAddedResponse) }
74
- def get_recently_added(request)
126
+ sig { params(request: T.nilable(::PlexRubySDK::Operations::GetRecentlyAddedRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetRecentlyAddedResponse) }
127
+ def get_recently_added(request, timeout_ms = nil)
75
128
  # get_recently_added - Get Recently Added
76
129
  # This endpoint will return the recently added content.
77
130
  #
@@ -83,11 +136,61 @@ module PlexRubySDK
83
136
  headers['Accept'] = 'application/json'
84
137
  headers['user-agent'] = @sdk_configuration.user_agent
85
138
 
86
- r = @sdk_configuration.client.get(url) do |req|
87
- req.headers = headers
88
- req.params = query_params
89
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
90
- Utils.configure_request_security(req, security) if !security.nil?
139
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
140
+
141
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
142
+ timeout ||= @sdk_configuration.timeout
143
+
144
+ connection = @sdk_configuration.client
145
+
146
+ hook_ctx = SDKHooks::HookContext.new(
147
+ base_url: base_url,
148
+ oauth2_scopes: nil,
149
+ operation_id: 'get-recently-added',
150
+ security_source: @sdk_configuration.security_source
151
+ )
152
+
153
+ error = T.let(nil, T.nilable(StandardError))
154
+ r = T.let(nil, T.nilable(Faraday::Response))
155
+
156
+ begin
157
+ r = connection.get(url) do |req|
158
+ req.headers.merge!(headers)
159
+ req.options.timeout = timeout unless timeout.nil?
160
+ req.params = query_params
161
+ Utils.configure_request_security(req, security)
162
+
163
+ @sdk_configuration.hooks.before_request(
164
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
165
+ hook_ctx: hook_ctx
166
+ ),
167
+ request: req
168
+ )
169
+ end
170
+ rescue StandardError => e
171
+ error = e
172
+ ensure
173
+ if r.nil? || Utils.error_status?(r.status)
174
+ r = @sdk_configuration.hooks.after_error(
175
+ error: error,
176
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
177
+ hook_ctx: hook_ctx
178
+ ),
179
+ response: r
180
+ )
181
+ else
182
+ r = @sdk_configuration.hooks.after_success(
183
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
184
+ hook_ctx: hook_ctx
185
+ ),
186
+ response: r
187
+ )
188
+ end
189
+
190
+ if r.nil?
191
+ raise error if !error.nil?
192
+ raise 'no response'
193
+ end
91
194
  end
92
195
 
93
196
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
@@ -107,8 +210,8 @@ module PlexRubySDK
107
210
  end
108
211
 
109
212
 
110
- sig { params(section_id: ::Float, count: T.nilable(::Float), only_transient: T.nilable(::PlexRubySDK::Operations::QueryParamOnlyTransient)).returns(::PlexRubySDK::Operations::GetLibraryHubsResponse) }
111
- def get_library_hubs(section_id, count = nil, only_transient = nil)
213
+ sig { params(section_id: ::Float, count: T.nilable(::Float), only_transient: T.nilable(::PlexRubySDK::Operations::QueryParamOnlyTransient), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetLibraryHubsResponse) }
214
+ def get_library_hubs(section_id, count = nil, only_transient = nil, timeout_ms = nil)
112
215
  # get_library_hubs - Get library specific hubs
113
216
  # This endpoint will return a list of library specific hubs
114
217
  #
@@ -131,11 +234,61 @@ module PlexRubySDK
131
234
  headers['Accept'] = 'application/json'
132
235
  headers['user-agent'] = @sdk_configuration.user_agent
133
236
 
134
- r = @sdk_configuration.client.get(url) do |req|
135
- req.headers = headers
136
- req.params = query_params
137
- security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
138
- Utils.configure_request_security(req, security) if !security.nil?
237
+ security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
238
+
239
+ timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
240
+ timeout ||= @sdk_configuration.timeout
241
+
242
+ connection = @sdk_configuration.client
243
+
244
+ hook_ctx = SDKHooks::HookContext.new(
245
+ base_url: base_url,
246
+ oauth2_scopes: nil,
247
+ operation_id: 'getLibraryHubs',
248
+ security_source: @sdk_configuration.security_source
249
+ )
250
+
251
+ error = T.let(nil, T.nilable(StandardError))
252
+ r = T.let(nil, T.nilable(Faraday::Response))
253
+
254
+ begin
255
+ r = connection.get(url) do |req|
256
+ req.headers.merge!(headers)
257
+ req.options.timeout = timeout unless timeout.nil?
258
+ req.params = query_params
259
+ Utils.configure_request_security(req, security)
260
+
261
+ @sdk_configuration.hooks.before_request(
262
+ hook_ctx: SDKHooks::BeforeRequestHookContext.new(
263
+ hook_ctx: hook_ctx
264
+ ),
265
+ request: req
266
+ )
267
+ end
268
+ rescue StandardError => e
269
+ error = e
270
+ ensure
271
+ if r.nil? || Utils.error_status?(r.status)
272
+ r = @sdk_configuration.hooks.after_error(
273
+ error: error,
274
+ hook_ctx: SDKHooks::AfterErrorHookContext.new(
275
+ hook_ctx: hook_ctx
276
+ ),
277
+ response: r
278
+ )
279
+ else
280
+ r = @sdk_configuration.hooks.after_success(
281
+ hook_ctx: SDKHooks::AfterSuccessHookContext.new(
282
+ hook_ctx: hook_ctx
283
+ ),
284
+ response: r
285
+ )
286
+ end
287
+
288
+ if r.nil?
289
+ raise error if !error.nil?
290
+ raise 'no response'
291
+ end
139
292
  end
140
293
 
141
294
  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')