Class: PlexRubySDK::Library

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/plex_ruby_sdk/library.rb

Instance Method Summary collapse

Constructor Details

#initialize(sdk_config) ⇒ Library

Returns a new instance of Library.



18
19
20
# File 'lib/plex_ruby_sdk/library.rb', line 18

def initialize(sdk_config)
  @sdk_configuration = sdk_config
end

Instance Method Details

#delete_library(section_key) ⇒ Object



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/plex_ruby_sdk/library.rb', line 257

def delete_library(section_key)
  # delete_library - Delete Library Section
  # Delete a library using a specific section id
  request = ::PlexRubySDK::Operations::DeleteLibraryRequest.new(
    
    section_key: section_key
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::DeleteLibraryRequest,
    base_url,
    '/library/sections/{sectionKey}',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.delete(url) do |req|
    req.headers = headers
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::DeleteLibraryResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::DeleteLibraryBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::DeleteLibraryUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_all_librariesObject



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/plex_ruby_sdk/library.rb', line 117

def get_all_libraries
  # get_all_libraries - Get All Libraries
  # A library section (commonly referred to as just a library) is a collection of media. 
  # Libraries are typed, and depending on their type provide either a flat or a hierarchical view of the media. 
  # For example, a music library has an artist > albums > tracks structure, whereas a movie library is flat.
  # 
  # Libraries have features beyond just being a collection of media; for starters, they include information about supported types, filters and sorts. 
  # This allows a client to provide a rich interface around the media (e.g. allow sorting movies by release year).
  # 
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = "#{base_url}/library/sections"
  headers = {}
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetAllLibrariesResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetAllLibrariesResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetAllLibrariesBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetAllLibrariesUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_file_hash(url, type = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/plex_ruby_sdk/library.rb', line 24

def get_file_hash(url, type = nil)
  # get_file_hash - Get Hash Value
  # This resource returns hash values for local files
  request = ::PlexRubySDK::Operations::GetFileHashRequest.new(
    
    url: url,
    type: type
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = "#{base_url}/library/hashes"
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetFileHashRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetFileHashResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetFileHashBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetFileHashUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_library_details(section_key, include_details = nil) ⇒ Object



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/plex_ruby_sdk/library.rb', line 164

def get_library_details(section_key, include_details = nil)
  # get_library_details - Get Library Details
  # ## Library Details Endpoint
  # 
  # This endpoint provides comprehensive details about the library, focusing on organizational aspects rather than the content itself.   
  # 
  # The details include:
  # 
  # ### Directories
  # Organized into three categories:
  # 
  # - **Primary Directories**: 
  #   - Used in some clients for quick access to media subsets (e.g., "All", "On Deck").
  #   - Most can be replicated via media queries.
  #   - Customizable by users.
  # 
  # - **Secondary Directories**:
  #   - Marked with `secondary="1"`.
  #   - Used in older clients for structured navigation.
  # 
  # - **Special Directories**:
  #   - Includes a "By Folder" entry for filesystem-based browsing.
  #   - Contains an obsolete `search="1"` entry for on-the-fly search dialog creation.
  # 
  # ### Types
  # Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
  # 
  # - **Type Object Attributes**:
  #   - `key`: Endpoint for the media list of this type.
  #   - `type`: Metadata type (if standard Plex type).
  #   - `title`: Title for this content type (e.g., "Movies").
  # 
  # - **Filter Objects**:
  #   - Subset of the media query language.
  #   - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
  # 
  # - **Sort Objects**:
  #   - Description of sort fields.
  #   - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
  # 
  # > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
  # 
  request = ::PlexRubySDK::Operations::GetLibraryDetailsRequest.new(
    
    section_key: section_key,
    include_details: include_details
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetLibraryDetailsRequest,
    base_url,
    '/library/sections/{sectionKey}',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetLibraryDetailsRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetLibraryDetailsResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryDetailsResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryDetailsBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryDetailsUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_library_items(request) ⇒ Object



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# File 'lib/plex_ruby_sdk/library.rb', line 304

def get_library_items(request)
  # get_library_items - Get Library Items
  # Fetches details from a specific section of the library identified by a section key and a tag. The tag parameter accepts the following values:
  # - `all`: All items in the section.
  # - `unwatched`: Items that have not been played.
  # - `newest`: Items that are recently released.
  # - `recentlyAdded`: Items that are recently added to the library.
  # - `recentlyViewed`: Items that were recently viewed.
  # - `onDeck`: Items to continue watching.
  # - `collection`: Items categorized by collection.
  # - `edition`: Items categorized by edition.
  # - `genre`: Items categorized by genre.
  # - `year`: Items categorized by year of release.
  # - `decade`: Items categorized by decade.
  # - `director`: Items categorized by director.
  # - `actor`: Items categorized by starring actor.
  # - `country`: Items categorized by country of origin.
  # - `contentRating`: Items categorized by content rating.
  # - `rating`: Items categorized by rating.
  # - `resolution`: Items categorized by resolution.
  # - `firstCharacter`: Items categorized by the first letter.
  # - `folder`: Items categorized by folder.
  # 
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetLibraryItemsRequest,
    base_url,
    '/library/sections/{sectionKey}/{tag}',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetLibraryItemsRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetLibraryItemsResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryItemsResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryItemsBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetLibraryItemsUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_meta_data_by_rating_key(rating_key) ⇒ Object



496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/plex_ruby_sdk/library.rb', line 496

def (rating_key)
  # get_meta_data_by_rating_key - Get Metadata by RatingKey
  # This endpoint will return the metadata of a library item specified with the ratingKey.
  # 
  request = ::PlexRubySDK::Operations::GetMetaDataByRatingKeyRequest.new(
    
    rating_key: rating_key
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetMetaDataByRatingKeyRequest,
    base_url,
    '/library/metadata/{ratingKey}',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetMetaDataByRatingKeyResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetaDataByRatingKeyResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetaDataByRatingKeyBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetaDataByRatingKeyUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_metadata_children(rating_key, include_elements = nil) ⇒ Object



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
# File 'lib/plex_ruby_sdk/library.rb', line 548

def (rating_key, include_elements = nil)
  # get_metadata_children - Get Items Children
  # This endpoint will return the children of of a library item specified with the ratingKey.
  # 
  request = ::PlexRubySDK::Operations::GetMetadataChildrenRequest.new(
    
    rating_key: rating_key,
    include_elements: include_elements
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetMetadataChildrenRequest,
    base_url,
    '/library/metadata/{ratingKey}/children',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetMetadataChildrenRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetMetadataChildrenResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetadataChildrenResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetadataChildrenBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetMetadataChildrenUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_on_deckObject



652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
# File 'lib/plex_ruby_sdk/library.rb', line 652

def get_on_deck
  # get_on_deck - Get On Deck
  # This endpoint will return the on deck content.
  # 
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = "#{base_url}/library/onDeck"
  headers = {}
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetOnDeckResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetOnDeckResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetOnDeckBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetOnDeckUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_recently_added(x_plex_container_start = nil, x_plex_container_size = nil) ⇒ Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/plex_ruby_sdk/library.rb', line 68

def get_recently_added(x_plex_container_start = nil, x_plex_container_size = nil)
  # get_recently_added - Get Recently Added
  # This endpoint will return the recently added content.
  # 
  request = ::PlexRubySDK::Operations::GetRecentlyAddedRequest.new(
    
    x_plex_container_start: x_plex_container_start,
    x_plex_container_size: x_plex_container_size
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = "#{base_url}/library/recentlyAdded"
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetRecentlyAddedRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetRecentlyAddedResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetRecentlyAddedResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetRecentlyAddedBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetRecentlyAddedUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_refresh_library_metadata(section_key, force = nil) ⇒ Object



373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/plex_ruby_sdk/library.rb', line 373

def (section_key, force = nil)
  # get_refresh_library_metadata - Refresh Metadata Of The Library
  # This endpoint Refreshes all the Metadata of the library.
  # 
  request = ::PlexRubySDK::Operations::GetRefreshLibraryMetadataRequest.new(
    
    section_key: section_key,
    force: force
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetRefreshLibraryMetadataRequest,
    base_url,
    '/library/sections/{sectionKey}/refresh',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetRefreshLibraryMetadataRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetRefreshLibraryMetadataResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetRefreshLibraryMetadataBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetRefreshLibraryMetadataUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_search_library(section_key, type) ⇒ Object



424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/plex_ruby_sdk/library.rb', line 424

def get_search_library(section_key, type)
  # get_search_library - Search Library
  # Search for content within a specific section of the library.
  # 
  # ### Types
  # Each type in the library comes with a set of filters and sorts, aiding in building dynamic media controls:
  # 
  # - **Type Object Attributes**:
  #   - `type`: Metadata type (if standard Plex type).  
  #   - `title`: Title for this content type (e.g., "Movies").
  # 
  # - **Filter Objects**:
  #   - Subset of the media query language.
  #   - Attributes include `filter` (name), `filterType` (data type), `key` (endpoint for value range), and `title`.
  # 
  # - **Sort Objects**:
  #   - Description of sort fields.
  #   - Attributes include `defaultDirection` (asc/desc), `descKey` and `key` (sort parameters), and `title`.
  # 
  # > **Note**: Filters and sorts are optional; without them, no filtering controls are rendered.
  # 
  request = ::PlexRubySDK::Operations::GetSearchLibraryRequest.new(
    
    section_key: section_key,
    type: type
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = Utils.generate_url(
    ::PlexRubySDK::Operations::GetSearchLibraryRequest,
    base_url,
    '/library/sections/{sectionKey}/search',
    request,
    @sdk_configuration.globals
  )
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetSearchLibraryRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetSearchLibraryResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetSearchLibraryResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetSearchLibraryBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetSearchLibraryUnauthorized)
      res.unauthorized = out
    end
  end
  res
end

#get_top_watched_content(type, include_guids = nil) ⇒ Object



603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
# File 'lib/plex_ruby_sdk/library.rb', line 603

def get_top_watched_content(type, include_guids = nil)
  # get_top_watched_content - Get Top Watched Content
  # This endpoint will return the top watched content from libraries of a certain type
  # 
  request = ::PlexRubySDK::Operations::GetTopWatchedContentRequest.new(
    
    type: type,
    include_guids: include_guids
  )
  url, params = @sdk_configuration.get_server_details
  base_url = Utils.template_url(url, params)
  url = "#{base_url}/library/all/top"
  headers = {}
  query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetTopWatchedContentRequest, request, @sdk_configuration.globals)
  headers['Accept'] = 'application/json'
  headers['user-agent'] = @sdk_configuration.user_agent

  r = @sdk_configuration.client.get(url) do |req|
    req.headers = headers
    req.params = query_params
    Utils.configure_request_security(req, @sdk_configuration.security) if !@sdk_configuration.nil? && !@sdk_configuration.security.nil?
  end

  content_type = r.headers.fetch('Content-Type', 'application/octet-stream')

  res = ::PlexRubySDK::Operations::GetTopWatchedContentResponse.new(
    status_code: r.status, content_type: content_type, raw_response: r
  )
  if r.status == 200
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetTopWatchedContentResponseBody)
      res.object = out
    end
  elsif r.status == 400
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetTopWatchedContentBadRequest)
      res.bad_request = out
    end
  elsif r.status == 401
    if Utils.match_content_type(content_type, 'application/json')
      out = Utils.unmarshal_complex(r.env.response_body, ::PlexRubySDK::Operations::GetTopWatchedContentUnauthorized)
      res.unauthorized = out
    end
  end
  res
end