plex-api-client 0.2.0__tar.gz → 0.3.0__tar.gz

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 (158) hide show
  1. {plex-api-client-0.2.0/src/plex_api_client.egg-info → plex-api-client-0.3.0}/PKG-INFO +5 -7
  2. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/README.md +4 -6
  3. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/setup.py +6 -4
  4. plex-api-client-0.3.0/src/plex_api/_hooks/__init__.py +4 -0
  5. plex-api-client-0.3.0/src/plex_api/_hooks/sdkhooks.py +55 -0
  6. plex-api-client-0.3.0/src/plex_api/_hooks/types.py +70 -0
  7. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/activities.py +46 -2
  8. plex-api-client-0.2.0/src/plex_api/security.py → plex-api-client-0.3.0/src/plex_api/authentication.py +48 -4
  9. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/butler.py +112 -5
  10. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/hubs.py +46 -2
  11. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/library.py +244 -11
  12. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/log.py +69 -4
  13. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/media.py +68 -3
  14. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/playlists.py +200 -9
  15. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/plex.py +46 -8
  16. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/sdk.py +15 -4
  17. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/sdkconfiguration.py +9 -3
  18. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/search.py +68 -3
  19. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/server.py +178 -8
  20. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/sessions.py +90 -4
  21. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/statistics.py +24 -1
  22. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/updater.py +68 -3
  23. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/utils/utils.py +30 -14
  24. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/video.py +46 -2
  25. {plex-api-client-0.2.0 → plex-api-client-0.3.0/src/plex_api_client.egg-info}/PKG-INFO +5 -7
  26. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api_client.egg-info/SOURCES.txt +4 -1
  27. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api_client.egg-info/requires.txt +1 -1
  28. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/LICENSE.md +0 -0
  29. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/setup.cfg +0 -0
  30. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/__init__.py +0 -0
  31. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/__init__.py +0 -0
  32. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/components/__init__.py +0 -0
  33. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/components/security.py +0 -0
  34. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/__init__.py +0 -0
  35. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/addplaylistcontents.py +0 -0
  36. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/applyupdates.py +0 -0
  37. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/cancelserveractivities.py +0 -0
  38. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/checkforupdates.py +0 -0
  39. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/clearplaylistcontents.py +0 -0
  40. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/createplaylist.py +0 -0
  41. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/deletelibrary.py +0 -0
  42. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/deleteplaylist.py +0 -0
  43. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/enablepapertrail.py +0 -0
  44. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getavailableclients.py +0 -0
  45. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getbutlertasks.py +0 -0
  46. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getdevices.py +0 -0
  47. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getfilehash.py +0 -0
  48. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getglobalhubs.py +0 -0
  49. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getlibraries.py +0 -0
  50. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getlibrary.py +0 -0
  51. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getlibraryhubs.py +0 -0
  52. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getmetadata.py +0 -0
  53. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getmetadatachildren.py +0 -0
  54. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getmyplexaccount.py +0 -0
  55. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getondeck.py +0 -0
  56. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getpin.py +0 -0
  57. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getplaylist.py +0 -0
  58. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getplaylistcontents.py +0 -0
  59. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getplaylists.py +0 -0
  60. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getrecentlyadded.py +0 -0
  61. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getresizedphoto.py +0 -0
  62. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getsearchresults.py +0 -0
  63. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getserveractivities.py +0 -0
  64. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getservercapabilities.py +0 -0
  65. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getserveridentity.py +0 -0
  66. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getserverlist.py +0 -0
  67. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getserverpreferences.py +0 -0
  68. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getsessionhistory.py +0 -0
  69. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getsessions.py +0 -0
  70. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getsourceconnectioninformation.py +0 -0
  71. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getstatistics.py +0 -0
  72. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/gettimeline.py +0 -0
  73. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/gettoken.py +0 -0
  74. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/gettranscodesessions.py +0 -0
  75. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/gettransienttoken.py +0 -0
  76. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/getupdatestatus.py +0 -0
  77. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/logline.py +0 -0
  78. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/logmultiline.py +0 -0
  79. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/markplayed.py +0 -0
  80. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/markunplayed.py +0 -0
  81. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/performsearch.py +0 -0
  82. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/performvoicesearch.py +0 -0
  83. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/refreshlibrary.py +0 -0
  84. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/sdkerror.py +0 -0
  85. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/startalltasks.py +0 -0
  86. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/starttask.py +0 -0
  87. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/startuniversaltranscode.py +0 -0
  88. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/stopalltasks.py +0 -0
  89. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/stoptask.py +0 -0
  90. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/stoptranscodesession.py +0 -0
  91. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/updateplaylist.py +0 -0
  92. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/updateplayprogress.py +0 -0
  93. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/errors/uploadplaylist.py +0 -0
  94. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/__init__.py +0 -0
  95. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/addplaylistcontents.py +0 -0
  96. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/applyupdates.py +0 -0
  97. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/cancelserveractivities.py +0 -0
  98. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/checkforupdates.py +0 -0
  99. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/clearplaylistcontents.py +0 -0
  100. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/createplaylist.py +0 -0
  101. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/deletelibrary.py +0 -0
  102. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/deleteplaylist.py +0 -0
  103. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/enablepapertrail.py +0 -0
  104. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getavailableclients.py +0 -0
  105. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getbutlertasks.py +0 -0
  106. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getdevices.py +0 -0
  107. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getfilehash.py +0 -0
  108. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getglobalhubs.py +0 -0
  109. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getlibraries.py +0 -0
  110. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getlibrary.py +0 -0
  111. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getlibraryhubs.py +0 -0
  112. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getlibraryitems.py +0 -0
  113. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getmetadata.py +0 -0
  114. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getmetadatachildren.py +0 -0
  115. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getmyplexaccount.py +0 -0
  116. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getondeck.py +0 -0
  117. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getpin.py +0 -0
  118. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getplaylist.py +0 -0
  119. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getplaylistcontents.py +0 -0
  120. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getplaylists.py +0 -0
  121. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getrecentlyadded.py +0 -0
  122. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getresizedphoto.py +0 -0
  123. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getsearchresults.py +0 -0
  124. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getserveractivities.py +0 -0
  125. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getservercapabilities.py +0 -0
  126. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getserveridentity.py +0 -0
  127. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getserverlist.py +0 -0
  128. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getserverpreferences.py +0 -0
  129. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getsessionhistory.py +0 -0
  130. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getsessions.py +0 -0
  131. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getsourceconnectioninformation.py +0 -0
  132. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getstatistics.py +0 -0
  133. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/gettimeline.py +0 -0
  134. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/gettoken.py +0 -0
  135. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/gettranscodesessions.py +0 -0
  136. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/gettransienttoken.py +0 -0
  137. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/getupdatestatus.py +0 -0
  138. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/logline.py +0 -0
  139. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/logmultiline.py +0 -0
  140. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/markplayed.py +0 -0
  141. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/markunplayed.py +0 -0
  142. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/performsearch.py +0 -0
  143. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/performvoicesearch.py +0 -0
  144. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/refreshlibrary.py +0 -0
  145. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/searchlibrary.py +0 -0
  146. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/startalltasks.py +0 -0
  147. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/starttask.py +0 -0
  148. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/startuniversaltranscode.py +0 -0
  149. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/stopalltasks.py +0 -0
  150. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/stoptask.py +0 -0
  151. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/stoptranscodesession.py +0 -0
  152. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/updateplaylist.py +0 -0
  153. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/updateplayprogress.py +0 -0
  154. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/models/operations/uploadplaylist.py +0 -0
  155. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/utils/__init__.py +0 -0
  156. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api/utils/retries.py +0 -0
  157. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api_client.egg-info/dependency_links.txt +0 -0
  158. {plex-api-client-0.2.0 → plex-api-client-0.3.0}/src/plex_api_client.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: plex-api-client
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Python Client SDK Generated by Speakeasy
5
5
  Home-page: UNKNOWN
6
6
  Author: LukeHagar
@@ -129,10 +129,10 @@ Description: # plexpy
129
129
  * [add_playlist_contents](docs/sdks/playlists/README.md#add_playlist_contents) - Adding to a Playlist
130
130
  * [upload_playlist](docs/sdks/playlists/README.md#upload_playlist) - Upload Playlist
131
131
 
132
- ### [security](docs/sdks/security/README.md)
132
+ ### [authentication](docs/sdks/authentication/README.md)
133
133
 
134
- * [get_transient_token](docs/sdks/security/README.md#get_transient_token) - Get a Transient Token.
135
- * [get_source_connection_information](docs/sdks/security/README.md#get_source_connection_information) - Get Source Connection Information
134
+ * [get_transient_token](docs/sdks/authentication/README.md#get_transient_token) - Get a Transient Token.
135
+ * [get_source_connection_information](docs/sdks/authentication/README.md#get_source_connection_information) - Get Source Connection Information
136
136
 
137
137
  ### [statistics](docs/sdks/statistics/README.md)
138
138
 
@@ -250,9 +250,7 @@ Description: # plexpy
250
250
  ```python
251
251
  import plex_api
252
252
 
253
- s = plex_api.PlexAPI(
254
- access_token="<YOUR_API_KEY_HERE>",
255
- )
253
+ s = plex_api.PlexAPI()
256
254
 
257
255
 
258
256
  res = s.plex.get_pin(server_url="https://plex.tv/api/v2", x_plex_client_identifier='<value>', strong=False)
@@ -122,10 +122,10 @@ if res.object is not None:
122
122
  * [add_playlist_contents](docs/sdks/playlists/README.md#add_playlist_contents) - Adding to a Playlist
123
123
  * [upload_playlist](docs/sdks/playlists/README.md#upload_playlist) - Upload Playlist
124
124
 
125
- ### [security](docs/sdks/security/README.md)
125
+ ### [authentication](docs/sdks/authentication/README.md)
126
126
 
127
- * [get_transient_token](docs/sdks/security/README.md#get_transient_token) - Get a Transient Token.
128
- * [get_source_connection_information](docs/sdks/security/README.md#get_source_connection_information) - Get Source Connection Information
127
+ * [get_transient_token](docs/sdks/authentication/README.md#get_transient_token) - Get a Transient Token.
128
+ * [get_source_connection_information](docs/sdks/authentication/README.md#get_source_connection_information) - Get Source Connection Information
129
129
 
130
130
  ### [statistics](docs/sdks/statistics/README.md)
131
131
 
@@ -243,9 +243,7 @@ The server URL can also be overridden on a per-operation basis, provided a serve
243
243
  ```python
244
244
  import plex_api
245
245
 
246
- s = plex_api.PlexAPI(
247
- access_token="<YOUR_API_KEY_HERE>",
248
- )
246
+ s = plex_api.PlexAPI()
249
247
 
250
248
 
251
249
  res = s.plex.get_pin(server_url="https://plex.tv/api/v2", x_plex_client_identifier='<value>', strong=False)
@@ -10,7 +10,7 @@ except FileNotFoundError:
10
10
 
11
11
  setuptools.setup(
12
12
  name="plex-api-client",
13
- version="0.2.0",
13
+ version="0.3.0",
14
14
  author="LukeHagar",
15
15
  description="Python Client SDK Generated by Speakeasy",
16
16
  long_description=long_description,
@@ -19,9 +19,9 @@ setuptools.setup(
19
19
  install_requires=[
20
20
  "certifi>=2023.7.22",
21
21
  "charset-normalizer>=3.2.0",
22
- "dataclasses-json-speakeasy>=0.5.11",
22
+ "dataclasses-json>=0.6.4",
23
23
  "idna>=3.4",
24
- "jsonpath-python>=1.0.6 ",
24
+ "jsonpath-python>=1.0.6",
25
25
  "marshmallow>=3.19.0",
26
26
  "mypy-extensions>=1.0.0",
27
27
  "packaging>=23.1",
@@ -33,7 +33,9 @@ setuptools.setup(
33
33
  "urllib3>=1.26.18",
34
34
  ],
35
35
  extras_require={
36
- "dev":["pylint==2.16.2"]
36
+ "dev": [
37
+ "pylint==2.16.2",
38
+ ],
37
39
  },
38
40
  package_dir={'': 'src'},
39
41
  python_requires='>=3.8',
@@ -0,0 +1,4 @@
1
+ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
+
3
+ from .sdkhooks import *
4
+ from .types import *
@@ -0,0 +1,55 @@
1
+ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
+
3
+ import requests
4
+ from .types import SDKInitHook, BeforeRequestContext, BeforeRequestHook, AfterSuccessContext, AfterSuccessHook, AfterErrorContext, AfterErrorHook, Hooks
5
+ from typing import List, Optional, Tuple, Union
6
+
7
+
8
+ class SDKHooks(Hooks):
9
+ sdk_init_hooks: List[SDKInitHook] = []
10
+ before_request_hooks: List[BeforeRequestHook] = []
11
+ after_success_hooks: List[AfterSuccessHook] = []
12
+ after_error_hooks: List[AfterErrorHook] = []
13
+
14
+ def __init__(self):
15
+ pass
16
+
17
+ def register_sdk_init_hook(self, hook: SDKInitHook) -> None:
18
+ self.sdk_init_hooks.append(hook)
19
+
20
+ def register_before_request_hook(self, hook: BeforeRequestHook) -> None:
21
+ self.before_request_hooks.append(hook)
22
+
23
+ def register_after_success_hook(self, hook: AfterSuccessHook) -> None:
24
+ self.after_success_hooks.append(hook)
25
+
26
+ def register_after_error_hook(self, hook: AfterErrorHook) -> None:
27
+ self.after_error_hooks.append(hook)
28
+
29
+ def sdk_init(self, base_url: str, client: requests.Session) -> Tuple[str, requests.Session]:
30
+ for hook in self.sdk_init_hooks:
31
+ base_url, client = hook.sdk_init(base_url, client)
32
+ return base_url, client
33
+
34
+ def before_request(self, hook_ctx: BeforeRequestContext, request: requests.PreparedRequest) -> Union[requests.PreparedRequest, Exception]:
35
+ for hook in self.before_request_hooks:
36
+ request = hook.before_request(hook_ctx, request)
37
+ if isinstance(request, Exception):
38
+ raise request
39
+
40
+ return request
41
+
42
+ def after_success(self, hook_ctx: AfterSuccessContext, response: requests.Response) -> requests.Response:
43
+ for hook in self.after_success_hooks:
44
+ response = hook.after_success(hook_ctx, response)
45
+ if isinstance(response, Exception):
46
+ raise response
47
+ return response
48
+
49
+ def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests.Response], error: Optional[Exception]) -> Tuple[Optional[requests.Response], Optional[Exception]]:
50
+ for hook in self.after_error_hooks:
51
+ result = hook.after_error(hook_ctx, response, error)
52
+ if isinstance(result, Exception):
53
+ raise result
54
+ response, error = result
55
+ return response, error
@@ -0,0 +1,70 @@
1
+ """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
+
3
+ import requests as requests_http
4
+ from abc import ABC, abstractmethod
5
+ from typing import Any, Callable, List, Optional, Tuple, Union
6
+
7
+
8
+ class HookContext:
9
+ operation_id: str
10
+ oauth2_scopes: Optional[List[str]] = None
11
+ security_source: Optional[Union[Any, Callable[[], Any]]] = None
12
+
13
+ def __init__(self, operation_id: str, oauth2_scopes: Optional[List[str]], security_source: Optional[Union[Any, Callable[[], Any]]]):
14
+ self.operation_id = operation_id
15
+ self.oauth2_scopes = oauth2_scopes
16
+ self.security_source = security_source
17
+
18
+
19
+ class BeforeRequestContext(HookContext):
20
+ pass
21
+
22
+
23
+ class AfterSuccessContext(HookContext):
24
+ pass
25
+
26
+
27
+ class AfterErrorContext(HookContext):
28
+ pass
29
+
30
+
31
+ class SDKInitHook(ABC):
32
+ @abstractmethod
33
+ def sdk_init(self, base_url: str, client: requests_http.Session) -> Tuple[str, requests_http.Session]:
34
+ pass
35
+
36
+
37
+ class BeforeRequestHook(ABC):
38
+ @abstractmethod
39
+ def before_request(self, hook_ctx: BeforeRequestContext, request: requests_http.PreparedRequest) -> Union[requests_http.PreparedRequest, Exception]:
40
+ pass
41
+
42
+
43
+ class AfterSuccessHook(ABC):
44
+ @abstractmethod
45
+ def after_success(self, hook_ctx: AfterSuccessContext, response: requests_http.Response) -> Union[requests_http.PreparedRequest, Exception]:
46
+ pass
47
+
48
+
49
+ class AfterErrorHook(ABC):
50
+ @abstractmethod
51
+ def after_error(self, hook_ctx: AfterErrorContext, response: Optional[requests_http.Response], error: Optional[Exception]) -> Union[Tuple[Optional[requests_http.PreparedRequest], Optional[Exception]], Exception]:
52
+ pass
53
+
54
+
55
+ class Hooks(ABC):
56
+ @abstractmethod
57
+ def register_sdk_init_hook(self, hook: SDKInitHook):
58
+ pass
59
+
60
+ @abstractmethod
61
+ def register_before_request_hook(self, hook: BeforeRequestHook):
62
+ pass
63
+
64
+ @abstractmethod
65
+ def register_after_success_hook(self, hook: AfterSuccessHook):
66
+ pass
67
+
68
+ @abstractmethod
69
+ def register_after_error_hook(self, hook: AfterErrorHook):
70
+ pass
@@ -1,7 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
2
 
3
+ import requests as requests_http
3
4
  from .sdkconfiguration import SDKConfiguration
4
5
  from plex_api import utils
6
+ from plex_api._hooks import HookContext
5
7
  from plex_api.models import errors, operations
6
8
  from typing import Optional
7
9
 
@@ -25,6 +27,7 @@ class Activities:
25
27
  r"""Get Server Activities
26
28
  Get Server Activities
27
29
  """
30
+ hook_ctx = HookContext(operation_id='getServerActivities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
28
31
  base_url = utils.template_url(*self.sdk_configuration.get_server_details())
29
32
 
30
33
  url = base_url + '/activities'
@@ -37,7 +40,27 @@ class Activities:
37
40
  else:
38
41
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
39
42
 
40
- http_res = client.request('GET', url, headers=headers)
43
+
44
+ try:
45
+ req = self.sdk_configuration.get_hooks().before_request(
46
+ hook_ctx,
47
+ requests_http.Request('GET', url, headers=headers).prepare(),
48
+ )
49
+ http_res = client.send(req)
50
+ except Exception as e:
51
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
52
+ raise e
53
+
54
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
55
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
56
+ if e:
57
+ raise e
58
+ else:
59
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
60
+ if isinstance(result, Exception):
61
+ raise result
62
+ http_res = result
63
+
41
64
  content_type = http_res.headers.get('Content-Type')
42
65
 
43
66
  res = operations.GetServerActivitiesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -66,6 +89,7 @@ class Activities:
66
89
  r"""Cancel Server Activities
67
90
  Cancel Server Activities
68
91
  """
92
+ hook_ctx = HookContext(operation_id='cancelServerActivities', oauth2_scopes=[], security_source=self.sdk_configuration.security)
69
93
  request = operations.CancelServerActivitiesRequest(
70
94
  activity_uuid=activity_uuid,
71
95
  )
@@ -82,7 +106,27 @@ class Activities:
82
106
  else:
83
107
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
84
108
 
85
- http_res = client.request('DELETE', url, headers=headers)
109
+
110
+ try:
111
+ req = self.sdk_configuration.get_hooks().before_request(
112
+ hook_ctx,
113
+ requests_http.Request('DELETE', url, headers=headers).prepare(),
114
+ )
115
+ http_res = client.send(req)
116
+ except Exception as e:
117
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
118
+ raise e
119
+
120
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
121
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
122
+ if e:
123
+ raise e
124
+ else:
125
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
126
+ if isinstance(result, Exception):
127
+ raise result
128
+ http_res = result
129
+
86
130
  content_type = http_res.headers.get('Content-Type')
87
131
 
88
132
  res = operations.CancelServerActivitiesResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -1,11 +1,13 @@
1
1
  """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
2
 
3
+ import requests as requests_http
3
4
  from .sdkconfiguration import SDKConfiguration
4
5
  from plex_api import utils
6
+ from plex_api._hooks import HookContext
5
7
  from plex_api.models import errors, operations
6
8
 
7
- class Security:
8
- r"""API Calls against Security for Plex Media Server"""
9
+ class Authentication:
10
+ r"""API Calls regarding authentication for Plex Media Server"""
9
11
  sdk_configuration: SDKConfiguration
10
12
 
11
13
  def __init__(self, sdk_config: SDKConfiguration) -> None:
@@ -17,6 +19,7 @@ class Security:
17
19
  r"""Get a Transient Token.
18
20
  This endpoint provides the caller with a temporary token with the same access level as the caller's token. These tokens are valid for up to 48 hours and are destroyed if the server instance is restarted.
19
21
  """
22
+ hook_ctx = HookContext(operation_id='getTransientToken', oauth2_scopes=[], security_source=self.sdk_configuration.security)
20
23
  request = operations.GetTransientTokenRequest(
21
24
  type=type_,
22
25
  scope=scope,
@@ -35,7 +38,27 @@ class Security:
35
38
  else:
36
39
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
37
40
 
38
- http_res = client.request('GET', url, params=query_params, headers=headers)
41
+
42
+ try:
43
+ req = self.sdk_configuration.get_hooks().before_request(
44
+ hook_ctx,
45
+ requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
46
+ )
47
+ http_res = client.send(req)
48
+ except Exception as e:
49
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
50
+ raise e
51
+
52
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
53
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
54
+ if e:
55
+ raise e
56
+ else:
57
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
58
+ if isinstance(result, Exception):
59
+ raise result
60
+ http_res = result
61
+
39
62
  content_type = http_res.headers.get('Content-Type')
40
63
 
41
64
  res = operations.GetTransientTokenResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -61,6 +84,7 @@ class Security:
61
84
  If a caller requires connection details and a transient token for a source that is known to the server, for example a cloud media provider or shared PMS, then this endpoint can be called. This endpoint is only accessible with either an admin token or a valid transient token generated from an admin token.
62
85
  Note: requires Plex Media Server >= 1.15.4.
63
86
  """
87
+ hook_ctx = HookContext(operation_id='getSourceConnectionInformation', oauth2_scopes=[], security_source=self.sdk_configuration.security)
64
88
  request = operations.GetSourceConnectionInformationRequest(
65
89
  source=source,
66
90
  )
@@ -78,7 +102,27 @@ class Security:
78
102
  else:
79
103
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
80
104
 
81
- http_res = client.request('GET', url, params=query_params, headers=headers)
105
+
106
+ try:
107
+ req = self.sdk_configuration.get_hooks().before_request(
108
+ hook_ctx,
109
+ requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
110
+ )
111
+ http_res = client.send(req)
112
+ except Exception as e:
113
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
114
+ raise e
115
+
116
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
117
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
118
+ if e:
119
+ raise e
120
+ else:
121
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
122
+ if isinstance(result, Exception):
123
+ raise result
124
+ http_res = result
125
+
82
126
  content_type = http_res.headers.get('Content-Type')
83
127
 
84
128
  res = operations.GetSourceConnectionInformationResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -1,7 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
2
 
3
+ import requests as requests_http
3
4
  from .sdkconfiguration import SDKConfiguration
4
5
  from plex_api import utils
6
+ from plex_api._hooks import HookContext
5
7
  from plex_api.models import errors, operations
6
8
  from typing import Optional
7
9
 
@@ -18,6 +20,7 @@ class Butler:
18
20
  r"""Get Butler tasks
19
21
  Returns a list of butler tasks
20
22
  """
23
+ hook_ctx = HookContext(operation_id='getButlerTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
21
24
  base_url = utils.template_url(*self.sdk_configuration.get_server_details())
22
25
 
23
26
  url = base_url + '/butler'
@@ -30,7 +33,27 @@ class Butler:
30
33
  else:
31
34
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
32
35
 
33
- http_res = client.request('GET', url, headers=headers)
36
+
37
+ try:
38
+ req = self.sdk_configuration.get_hooks().before_request(
39
+ hook_ctx,
40
+ requests_http.Request('GET', url, headers=headers).prepare(),
41
+ )
42
+ http_res = client.send(req)
43
+ except Exception as e:
44
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
45
+ raise e
46
+
47
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
48
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
49
+ if e:
50
+ raise e
51
+ else:
52
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
53
+ if isinstance(result, Exception):
54
+ raise result
55
+ http_res = result
56
+
34
57
  content_type = http_res.headers.get('Content-Type')
35
58
 
36
59
  res = operations.GetButlerTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -63,6 +86,7 @@ class Butler:
63
86
  3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
64
87
  4. If we are outside the configured window, the task will start immediately.
65
88
  """
89
+ hook_ctx = HookContext(operation_id='startAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
66
90
  base_url = utils.template_url(*self.sdk_configuration.get_server_details())
67
91
 
68
92
  url = base_url + '/butler'
@@ -75,7 +99,27 @@ class Butler:
75
99
  else:
76
100
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
77
101
 
78
- http_res = client.request('POST', url, headers=headers)
102
+
103
+ try:
104
+ req = self.sdk_configuration.get_hooks().before_request(
105
+ hook_ctx,
106
+ requests_http.Request('POST', url, headers=headers).prepare(),
107
+ )
108
+ http_res = client.send(req)
109
+ except Exception as e:
110
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
111
+ raise e
112
+
113
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
114
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
115
+ if e:
116
+ raise e
117
+ else:
118
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
119
+ if isinstance(result, Exception):
120
+ raise result
121
+ http_res = result
122
+
79
123
  content_type = http_res.headers.get('Content-Type')
80
124
 
81
125
  res = operations.StartAllTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -100,6 +144,7 @@ class Butler:
100
144
  r"""Stop all Butler tasks
101
145
  This endpoint will stop all currently running tasks and remove any scheduled tasks from the queue.
102
146
  """
147
+ hook_ctx = HookContext(operation_id='stopAllTasks', oauth2_scopes=[], security_source=self.sdk_configuration.security)
103
148
  base_url = utils.template_url(*self.sdk_configuration.get_server_details())
104
149
 
105
150
  url = base_url + '/butler'
@@ -112,7 +157,27 @@ class Butler:
112
157
  else:
113
158
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
114
159
 
115
- http_res = client.request('DELETE', url, headers=headers)
160
+
161
+ try:
162
+ req = self.sdk_configuration.get_hooks().before_request(
163
+ hook_ctx,
164
+ requests_http.Request('DELETE', url, headers=headers).prepare(),
165
+ )
166
+ http_res = client.send(req)
167
+ except Exception as e:
168
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
169
+ raise e
170
+
171
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
172
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
173
+ if e:
174
+ raise e
175
+ else:
176
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
177
+ if isinstance(result, Exception):
178
+ raise result
179
+ http_res = result
180
+
116
181
  content_type = http_res.headers.get('Content-Type')
117
182
 
118
183
  res = operations.StopAllTasksResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -141,6 +206,7 @@ class Butler:
141
206
  3. If a task is configured to run at a random time during the configured window and we are within that window, the task will be scheduled at a random time within the window.
142
207
  4. If we are outside the configured window, the task will start immediately.
143
208
  """
209
+ hook_ctx = HookContext(operation_id='startTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
144
210
  request = operations.StartTaskRequest(
145
211
  task_name=task_name,
146
212
  )
@@ -157,7 +223,27 @@ class Butler:
157
223
  else:
158
224
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
159
225
 
160
- http_res = client.request('POST', url, headers=headers)
226
+
227
+ try:
228
+ req = self.sdk_configuration.get_hooks().before_request(
229
+ hook_ctx,
230
+ requests_http.Request('POST', url, headers=headers).prepare(),
231
+ )
232
+ http_res = client.send(req)
233
+ except Exception as e:
234
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
235
+ raise e
236
+
237
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
238
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
239
+ if e:
240
+ raise e
241
+ else:
242
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
243
+ if isinstance(result, Exception):
244
+ raise result
245
+ http_res = result
246
+
161
247
  content_type = http_res.headers.get('Content-Type')
162
248
 
163
249
  res = operations.StartTaskResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -182,6 +268,7 @@ class Butler:
182
268
  r"""Stop a single Butler task
183
269
  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.
184
270
  """
271
+ hook_ctx = HookContext(operation_id='stopTask', oauth2_scopes=[], security_source=self.sdk_configuration.security)
185
272
  request = operations.StopTaskRequest(
186
273
  task_name=task_name,
187
274
  )
@@ -198,7 +285,27 @@ class Butler:
198
285
  else:
199
286
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
200
287
 
201
- http_res = client.request('DELETE', url, headers=headers)
288
+
289
+ try:
290
+ req = self.sdk_configuration.get_hooks().before_request(
291
+ hook_ctx,
292
+ requests_http.Request('DELETE', url, headers=headers).prepare(),
293
+ )
294
+ http_res = client.send(req)
295
+ except Exception as e:
296
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
297
+ raise e
298
+
299
+ if utils.match_status_codes(['400','401','404','4XX','5XX'], http_res.status_code):
300
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
301
+ if e:
302
+ raise e
303
+ else:
304
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
305
+ if isinstance(result, Exception):
306
+ raise result
307
+ http_res = result
308
+
202
309
  content_type = http_res.headers.get('Content-Type')
203
310
 
204
311
  res = operations.StopTaskResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -1,7 +1,9 @@
1
1
  """Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""
2
2
 
3
+ import requests as requests_http
3
4
  from .sdkconfiguration import SDKConfiguration
4
5
  from plex_api import utils
6
+ from plex_api._hooks import HookContext
5
7
  from plex_api.models import errors, operations
6
8
  from typing import Optional
7
9
 
@@ -18,6 +20,7 @@ class Hubs:
18
20
  r"""Get Global Hubs
19
21
  Get Global Hubs filtered by the parameters provided.
20
22
  """
23
+ hook_ctx = HookContext(operation_id='getGlobalHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
21
24
  request = operations.GetGlobalHubsRequest(
22
25
  count=count,
23
26
  only_transient=only_transient,
@@ -36,7 +39,27 @@ class Hubs:
36
39
  else:
37
40
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
38
41
 
39
- http_res = client.request('GET', url, params=query_params, headers=headers)
42
+
43
+ try:
44
+ req = self.sdk_configuration.get_hooks().before_request(
45
+ hook_ctx,
46
+ requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
47
+ )
48
+ http_res = client.send(req)
49
+ except Exception as e:
50
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
51
+ raise e
52
+
53
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
54
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
55
+ if e:
56
+ raise e
57
+ else:
58
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
59
+ if isinstance(result, Exception):
60
+ raise result
61
+ http_res = result
62
+
40
63
  content_type = http_res.headers.get('Content-Type')
41
64
 
42
65
  res = operations.GetGlobalHubsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)
@@ -65,6 +88,7 @@ class Hubs:
65
88
  r"""Get library specific hubs
66
89
  This endpoint will return a list of library specific hubs
67
90
  """
91
+ hook_ctx = HookContext(operation_id='getLibraryHubs', oauth2_scopes=[], security_source=self.sdk_configuration.security)
68
92
  request = operations.GetLibraryHubsRequest(
69
93
  section_id=section_id,
70
94
  count=count,
@@ -84,7 +108,27 @@ class Hubs:
84
108
  else:
85
109
  client = utils.configure_security_client(self.sdk_configuration.client, self.sdk_configuration.security)
86
110
 
87
- http_res = client.request('GET', url, params=query_params, headers=headers)
111
+
112
+ try:
113
+ req = self.sdk_configuration.get_hooks().before_request(
114
+ hook_ctx,
115
+ requests_http.Request('GET', url, params=query_params, headers=headers).prepare(),
116
+ )
117
+ http_res = client.send(req)
118
+ except Exception as e:
119
+ _, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, None, e)
120
+ raise e
121
+
122
+ if utils.match_status_codes(['400','401','4XX','5XX'], http_res.status_code):
123
+ http_res, e = self.sdk_configuration.get_hooks().after_error(hook_ctx, http_res, None)
124
+ if e:
125
+ raise e
126
+ else:
127
+ result = self.sdk_configuration.get_hooks().after_success(hook_ctx, http_res)
128
+ if isinstance(result, Exception):
129
+ raise result
130
+ http_res = result
131
+
88
132
  content_type = http_res.headers.get('Content-Type')
89
133
 
90
134
  res = operations.GetLibraryHubsResponse(status_code=http_res.status_code, content_type=content_type, raw_response=http_res)