IApiClient.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. using MediaBrowser.Model.Configuration;
  2. using MediaBrowser.Model.Dto;
  3. using MediaBrowser.Model.Entities;
  4. using MediaBrowser.Model.Globalization;
  5. using MediaBrowser.Model.Notifications;
  6. using MediaBrowser.Model.Plugins;
  7. using MediaBrowser.Model.Querying;
  8. using MediaBrowser.Model.Search;
  9. using MediaBrowser.Model.Serialization;
  10. using MediaBrowser.Model.Session;
  11. using MediaBrowser.Model.System;
  12. using MediaBrowser.Model.Tasks;
  13. using MediaBrowser.Model.Users;
  14. using System;
  15. using System.Collections.Generic;
  16. using System.IO;
  17. using System.Threading;
  18. using System.Threading.Tasks;
  19. namespace MediaBrowser.Model.ApiClient
  20. {
  21. /// <summary>
  22. /// Interface IApiClient
  23. /// </summary>
  24. public interface IApiClient : IDisposable
  25. {
  26. /// <summary>
  27. /// Occurs when [server location changed].
  28. /// </summary>
  29. event EventHandler ServerLocationChanged;
  30. /// <summary>
  31. /// Occurs when [HTTP response received].
  32. /// </summary>
  33. event EventHandler<HttpResponseEventArgs> HttpResponseReceived;
  34. string GetApiUrl(string handler);
  35. /// <summary>
  36. /// Gets the async.
  37. /// </summary>
  38. /// <typeparam name="T"></typeparam>
  39. /// <param name="url">The URL.</param>
  40. /// <param name="cancellationToken">The cancellation token.</param>
  41. /// <returns>Task{``0}.</returns>
  42. Task<T> GetAsync<T>(string url, CancellationToken cancellationToken)
  43. where T : class;
  44. /// <summary>
  45. /// Gets the critic reviews.
  46. /// </summary>
  47. /// <param name="itemId">The item id.</param>
  48. /// <param name="cancellationToken">The cancellation token.</param>
  49. /// <param name="startIndex">The start index.</param>
  50. /// <param name="limit">The limit.</param>
  51. /// <returns>Task{ItemReviewsResult}.</returns>
  52. Task<ItemReviewsResult> GetCriticReviews(string itemId, CancellationToken cancellationToken, int? startIndex = null, int? limit = null);
  53. /// <summary>
  54. /// Gets the theme songs async.
  55. /// </summary>
  56. /// <param name="userId">The user id.</param>
  57. /// <param name="itemId">The item id.</param>
  58. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  59. /// <param name="cancellationToken">The cancellation token.</param>
  60. /// <returns>Task{ThemeMediaResult}.</returns>
  61. Task<ThemeMediaResult> GetThemeSongsAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  62. /// <summary>
  63. /// Gets the search hints async.
  64. /// </summary>
  65. /// <param name="userId">The user id.</param>
  66. /// <param name="searchTerm">The search term.</param>
  67. /// <param name="startIndex">The start index.</param>
  68. /// <param name="limit">The limit.</param>
  69. /// <returns>Task{SearchHintResult}.</returns>
  70. Task<SearchHintResult> GetSearchHintsAsync(string userId, string searchTerm, int? startIndex = null,
  71. int? limit = null);
  72. /// <summary>
  73. /// Gets the theme videos async.
  74. /// </summary>
  75. /// <param name="userId">The user id.</param>
  76. /// <param name="itemId">The item id.</param>
  77. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  78. /// <param name="cancellationToken">The cancellation token.</param>
  79. /// <returns>Task{ThemeMediaResult}.</returns>
  80. Task<ThemeMediaResult> GetThemeVideosAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  81. /// <summary>
  82. /// Gets all theme media async.
  83. /// </summary>
  84. /// <param name="userId">The user id.</param>
  85. /// <param name="itemId">The item id.</param>
  86. /// <param name="inheritFromParents">if set to <c>true</c> [inherit from parents].</param>
  87. /// <param name="cancellationToken">The cancellation token.</param>
  88. /// <returns>Task{AllThemeMediaResult}.</returns>
  89. Task<AllThemeMediaResult> GetAllThemeMediaAsync(string userId, string itemId, bool inheritFromParents, CancellationToken cancellationToken);
  90. /// <summary>
  91. /// Marks the notifications read.
  92. /// </summary>
  93. /// <param name="userId">The user id.</param>
  94. /// <param name="notificationIdList">The notification id list.</param>
  95. /// <param name="isRead">if set to <c>true</c> [is read].</param>
  96. /// <returns>Task.</returns>
  97. Task MarkNotificationsRead(string userId, IEnumerable<Guid> notificationIdList, bool isRead);
  98. /// <summary>
  99. /// Updates the notification.
  100. /// </summary>
  101. /// <param name="notification">The notification.</param>
  102. /// <returns>Task.</returns>
  103. Task UpdateNotification(Notification notification);
  104. /// <summary>
  105. /// Adds the notification.
  106. /// </summary>
  107. /// <param name="notification">The notification.</param>
  108. /// <returns>Task{Notification}.</returns>
  109. Task<Notification> AddNotification(Notification notification);
  110. /// <summary>
  111. /// Gets the notifications summary.
  112. /// </summary>
  113. /// <param name="userId">The user id.</param>
  114. /// <returns>Task{NotificationsSummary}.</returns>
  115. Task<NotificationsSummary> GetNotificationsSummary(string userId);
  116. /// <summary>
  117. /// Gets the notifications async.
  118. /// </summary>
  119. /// <param name="query">The query.</param>
  120. /// <returns>Task{NotificationResult}.</returns>
  121. Task<NotificationResult> GetNotificationsAsync(NotificationQuery query);
  122. /// <summary>
  123. /// Gets an image stream based on a url
  124. /// </summary>
  125. /// <param name="url">The URL.</param>
  126. /// <param name="cancellationToken">The cancellation token.</param>
  127. /// <returns>Task{Stream}.</returns>
  128. /// <exception cref="ArgumentNullException">url</exception>
  129. Task<Stream> GetImageStreamAsync(string url, CancellationToken cancellationToken);
  130. /// <summary>
  131. /// Gets a BaseItem
  132. /// </summary>
  133. /// <param name="id">The id.</param>
  134. /// <param name="userId">The user id.</param>
  135. /// <returns>Task{BaseItemDto}.</returns>
  136. /// <exception cref="ArgumentNullException">id</exception>
  137. Task<BaseItemDto> GetItemAsync(string id, string userId);
  138. /// <summary>
  139. /// Gets the intros async.
  140. /// </summary>
  141. /// <param name="itemId">The item id.</param>
  142. /// <param name="userId">The user id.</param>
  143. /// <returns>Task{System.String[]}.</returns>
  144. /// <exception cref="ArgumentNullException">id</exception>
  145. Task<string[]> GetIntrosAsync(string itemId, string userId);
  146. /// <summary>
  147. /// Gets a BaseItem
  148. /// </summary>
  149. /// <param name="userId">The user id.</param>
  150. /// <returns>Task{BaseItemDto}.</returns>
  151. /// <exception cref="ArgumentNullException">userId</exception>
  152. Task<BaseItemDto> GetRootFolderAsync(string userId);
  153. /// <summary>
  154. /// Gets the users async.
  155. /// </summary>
  156. /// <param name="query">The query.</param>
  157. /// <returns>Task{UserDto[]}.</returns>
  158. Task<UserDto[]> GetUsersAsync(UserQuery query);
  159. /// <summary>
  160. /// Gets the public users async.
  161. /// </summary>
  162. /// <param name="cancellationToken">The cancellation token.</param>
  163. /// <returns>Task{UserDto[]}.</returns>
  164. Task<UserDto[]> GetPublicUsersAsync(CancellationToken cancellationToken);
  165. /// <summary>
  166. /// Gets active client sessions.
  167. /// </summary>
  168. /// <returns>Task{SessionInfoDto[]}.</returns>
  169. Task<SessionInfoDto[]> GetClientSessionsAsync(SessionQuery query);
  170. /// <summary>
  171. /// Gets the item counts async.
  172. /// </summary>
  173. /// <param name="userId">The user id.</param>
  174. /// <returns>Task{ItemCounts}.</returns>
  175. Task<ItemCounts> GetItemCountsAsync(string userId);
  176. /// <summary>
  177. /// Queries for items
  178. /// </summary>
  179. /// <param name="query">The query.</param>
  180. /// <returns>Task{ItemsResult}.</returns>
  181. /// <exception cref="ArgumentNullException">query</exception>
  182. Task<ItemsResult> GetItemsAsync(ItemQuery query);
  183. /// <summary>
  184. /// Gets the instant mix from song async.
  185. /// </summary>
  186. /// <param name="query">The query.</param>
  187. /// <returns>Task{ItemsResult}.</returns>
  188. Task<ItemsResult> GetInstantMixFromSongAsync(SimilarItemsQuery query);
  189. /// <summary>
  190. /// Gets the instant mix from album async.
  191. /// </summary>
  192. /// <param name="query">The query.</param>
  193. /// <returns>Task{ItemsResult}.</returns>
  194. Task<ItemsResult> GetInstantMixFromAlbumAsync(SimilarItemsQuery query);
  195. /// <summary>
  196. /// Gets the instant mix from artist async.
  197. /// </summary>
  198. /// <param name="query">The query.</param>
  199. /// <returns>Task{ItemsResult}.</returns>
  200. Task<ItemsResult> GetInstantMixFromArtistAsync(SimilarItemsByNameQuery query);
  201. /// <summary>
  202. /// Gets the instant mix from music genre async.
  203. /// </summary>
  204. /// <param name="query">The query.</param>
  205. /// <returns>Task{ItemsResult}.</returns>
  206. Task<ItemsResult> GetInstantMixFromMusicGenreAsync(SimilarItemsByNameQuery query);
  207. /// <summary>
  208. /// Gets the similar movies async.
  209. /// </summary>
  210. /// <param name="query">The query.</param>
  211. /// <returns>Task{ItemsResult}.</returns>
  212. Task<ItemsResult> GetSimilarMoviesAsync(SimilarItemsQuery query);
  213. /// <summary>
  214. /// Gets the similar trailers async.
  215. /// </summary>
  216. /// <param name="query">The query.</param>
  217. /// <returns>Task{ItemsResult}.</returns>
  218. Task<ItemsResult> GetSimilarTrailersAsync(SimilarItemsQuery query);
  219. /// <summary>
  220. /// Gets the similar series async.
  221. /// </summary>
  222. /// <param name="query">The query.</param>
  223. /// <returns>Task{ItemsResult}.</returns>
  224. Task<ItemsResult> GetSimilarSeriesAsync(SimilarItemsQuery query);
  225. /// <summary>
  226. /// Gets the similar albums async.
  227. /// </summary>
  228. /// <param name="query">The query.</param>
  229. /// <returns>Task{ItemsResult}.</returns>
  230. Task<ItemsResult> GetSimilarAlbumsAsync(SimilarItemsQuery query);
  231. /// <summary>
  232. /// Gets the similar games async.
  233. /// </summary>
  234. /// <param name="query">The query.</param>
  235. /// <returns>Task{ItemsResult}.</returns>
  236. Task<ItemsResult> GetSimilarGamesAsync(SimilarItemsQuery query);
  237. /// <summary>
  238. /// Gets the people async.
  239. /// </summary>
  240. /// <param name="query">The query.</param>
  241. /// <returns>Task{ItemsResult}.</returns>
  242. /// <exception cref="ArgumentNullException">userId</exception>
  243. Task<ItemsResult> GetPeopleAsync(PersonsQuery query);
  244. /// <summary>
  245. /// Gets the artists.
  246. /// </summary>
  247. /// <param name="query">The query.</param>
  248. /// <returns>Task{ItemsResult}.</returns>
  249. /// <exception cref="ArgumentNullException">userId</exception>
  250. Task<ItemsResult> GetArtistsAsync(ArtistsQuery query);
  251. /// <summary>
  252. /// Gets a studio
  253. /// </summary>
  254. /// <param name="name">The name.</param>
  255. /// <param name="userId">The user id.</param>
  256. /// <returns>Task{BaseItemDto}.</returns>
  257. /// <exception cref="ArgumentNullException">userId</exception>
  258. Task<BaseItemDto> GetStudioAsync(string name, string userId);
  259. /// <summary>
  260. /// Gets the next up async.
  261. /// </summary>
  262. /// <param name="query">The query.</param>
  263. /// <returns>Task{ItemsResult}.</returns>
  264. Task<ItemsResult> GetNextUpAsync(NextUpQuery query);
  265. /// <summary>
  266. /// Gets a genre
  267. /// </summary>
  268. /// <param name="name">The name.</param>
  269. /// <param name="userId">The user id.</param>
  270. /// <returns>Task{BaseItemDto}.</returns>
  271. /// <exception cref="ArgumentNullException">userId</exception>
  272. Task<BaseItemDto> GetGenreAsync(string name, string userId);
  273. /// <summary>
  274. /// Gets the genres async.
  275. /// </summary>
  276. /// <param name="query">The query.</param>
  277. /// <returns>Task{ItemsResult}.</returns>
  278. Task<ItemsResult> GetGenresAsync(ItemsByNameQuery query);
  279. /// <summary>
  280. /// Gets the music genres async.
  281. /// </summary>
  282. /// <param name="query">The query.</param>
  283. /// <returns>Task{ItemsResult}.</returns>
  284. Task<ItemsResult> GetMusicGenresAsync(ItemsByNameQuery query);
  285. /// <summary>
  286. /// Gets the game genres async.
  287. /// </summary>
  288. /// <param name="query">The query.</param>
  289. /// <returns>Task{ItemsResult}.</returns>
  290. Task<ItemsResult> GetGameGenresAsync(ItemsByNameQuery query);
  291. /// <summary>
  292. /// Gets the studios async.
  293. /// </summary>
  294. /// <param name="query">The query.</param>
  295. /// <returns>Task{ItemsResult}.</returns>
  296. Task<ItemsResult> GetStudiosAsync(ItemsByNameQuery query);
  297. /// <summary>
  298. /// Gets the music genre async.
  299. /// </summary>
  300. /// <param name="name">The name.</param>
  301. /// <param name="userId">The user id.</param>
  302. /// <returns>Task{BaseItemDto}.</returns>
  303. Task<BaseItemDto> GetMusicGenreAsync(string name, string userId);
  304. /// <summary>
  305. /// Gets the game genre async.
  306. /// </summary>
  307. /// <param name="name">The name.</param>
  308. /// <param name="userId">The user id.</param>
  309. /// <returns>Task{BaseItemDto}.</returns>
  310. Task<BaseItemDto> GetGameGenreAsync(string name, string userId);
  311. /// <summary>
  312. /// Gets the artist async.
  313. /// </summary>
  314. /// <param name="name">The name.</param>
  315. /// <param name="userId">The user id.</param>
  316. /// <returns>Task{BaseItemDto}.</returns>
  317. /// <exception cref="ArgumentNullException">name</exception>
  318. Task<BaseItemDto> GetArtistAsync(string name, string userId);
  319. /// <summary>
  320. /// Restarts the server.
  321. /// </summary>
  322. /// <returns>Task.</returns>
  323. Task RestartServerAsync();
  324. /// <summary>
  325. /// Gets the system status async.
  326. /// </summary>
  327. /// <returns>Task{SystemInfo}.</returns>
  328. Task<SystemInfo> GetSystemInfoAsync();
  329. /// <summary>
  330. /// Gets a person
  331. /// </summary>
  332. /// <param name="name">The name.</param>
  333. /// <param name="userId">The user id.</param>
  334. /// <returns>Task{BaseItemDto}.</returns>
  335. /// <exception cref="ArgumentNullException">userId</exception>
  336. Task<BaseItemDto> GetPersonAsync(string name, string userId);
  337. /// <summary>
  338. /// Gets a list of plugins installed on the server
  339. /// </summary>
  340. /// <returns>Task{PluginInfo[]}.</returns>
  341. Task<PluginInfo[]> GetInstalledPluginsAsync();
  342. /// <summary>
  343. /// Gets the current server configuration
  344. /// </summary>
  345. /// <returns>Task{ServerConfiguration}.</returns>
  346. Task<ServerConfiguration> GetServerConfigurationAsync();
  347. /// <summary>
  348. /// Gets the scheduled tasks.
  349. /// </summary>
  350. /// <returns>Task{TaskInfo[]}.</returns>
  351. Task<TaskInfo[]> GetScheduledTasksAsync();
  352. /// <summary>
  353. /// Gets the scheduled task async.
  354. /// </summary>
  355. /// <param name="id">The id.</param>
  356. /// <returns>Task{TaskInfo}.</returns>
  357. /// <exception cref="ArgumentNullException">id</exception>
  358. Task<TaskInfo> GetScheduledTaskAsync(Guid id);
  359. /// <summary>
  360. /// Gets a user by id
  361. /// </summary>
  362. /// <param name="id">The id.</param>
  363. /// <returns>Task{UserDto}.</returns>
  364. /// <exception cref="ArgumentNullException">id</exception>
  365. Task<UserDto> GetUserAsync(string id);
  366. /// <summary>
  367. /// Gets the parental ratings async.
  368. /// </summary>
  369. /// <returns>Task{List{ParentalRating}}.</returns>
  370. Task<List<ParentalRating>> GetParentalRatingsAsync();
  371. /// <summary>
  372. /// Gets local trailers for an item
  373. /// </summary>
  374. /// <param name="userId">The user id.</param>
  375. /// <param name="itemId">The item id.</param>
  376. /// <returns>Task{ItemsResult}.</returns>
  377. /// <exception cref="ArgumentNullException">query</exception>
  378. Task<BaseItemDto[]> GetLocalTrailersAsync(string userId, string itemId);
  379. /// <summary>
  380. /// Gets special features for an item
  381. /// </summary>
  382. /// <param name="userId">The user id.</param>
  383. /// <param name="itemId">The item id.</param>
  384. /// <returns>Task{BaseItemDto[]}.</returns>
  385. /// <exception cref="ArgumentNullException">userId</exception>
  386. Task<BaseItemDto[]> GetSpecialFeaturesAsync(string userId, string itemId);
  387. /// <summary>
  388. /// Gets the cultures async.
  389. /// </summary>
  390. /// <returns>Task{CultureDto[]}.</returns>
  391. Task<CultureDto[]> GetCulturesAsync();
  392. /// <summary>
  393. /// Gets the countries async.
  394. /// </summary>
  395. /// <returns>Task{CountryInfo[]}.</returns>
  396. Task<CountryInfo[]> GetCountriesAsync();
  397. /// <summary>
  398. /// Marks an item as played or unplayed.
  399. /// This should not be used to update playstate following playback.
  400. /// There are separate playstate check-in methods for that. This should be used for a
  401. /// separate option to reset playstate.
  402. /// </summary>
  403. /// <param name="itemId">The item id.</param>
  404. /// <param name="userId">The user id.</param>
  405. /// <param name="wasPlayed">if set to <c>true</c> [was played].</param>
  406. /// <returns>Task.</returns>
  407. /// <exception cref="ArgumentNullException">itemId</exception>
  408. Task<UserItemDataDto> UpdatePlayedStatusAsync(string itemId, string userId, bool wasPlayed);
  409. /// <summary>
  410. /// Updates the favorite status async.
  411. /// </summary>
  412. /// <param name="itemId">The item id.</param>
  413. /// <param name="userId">The user id.</param>
  414. /// <param name="isFavorite">if set to <c>true</c> [is favorite].</param>
  415. /// <returns>Task.</returns>
  416. /// <exception cref="ArgumentNullException">itemId</exception>
  417. Task<UserItemDataDto> UpdateFavoriteStatusAsync(string itemId, string userId, bool isFavorite);
  418. /// <summary>
  419. /// Reports to the server that the user has begun playing an item
  420. /// </summary>
  421. /// <param name="itemId">The item id.</param>
  422. /// <param name="userId">The user id.</param>
  423. /// <returns>Task{UserItemDataDto}.</returns>
  424. /// <exception cref="ArgumentNullException">itemId</exception>
  425. Task ReportPlaybackStartAsync(string itemId, string userId);
  426. /// <summary>
  427. /// Reports playback progress to the server
  428. /// </summary>
  429. /// <param name="itemId">The item id.</param>
  430. /// <param name="userId">The user id.</param>
  431. /// <param name="positionTicks">The position ticks.</param>
  432. /// <param name="isPaused">if set to <c>true</c> [is paused].</param>
  433. /// <param name="isMuted">if set to <c>true</c> [is muted].</param>
  434. /// <returns>Task{UserItemDataDto}.</returns>
  435. /// <exception cref="ArgumentNullException">itemId</exception>
  436. Task ReportPlaybackProgressAsync(string itemId, string userId, long? positionTicks, bool isPaused, bool isMuted);
  437. /// <summary>
  438. /// Reports to the server that the user has stopped playing an item
  439. /// </summary>
  440. /// <param name="itemId">The item id.</param>
  441. /// <param name="userId">The user id.</param>
  442. /// <param name="positionTicks">The position ticks.</param>
  443. /// <returns>Task{UserItemDataDto}.</returns>
  444. /// <exception cref="ArgumentNullException">itemId</exception>
  445. Task ReportPlaybackStoppedAsync(string itemId, string userId, long? positionTicks);
  446. /// <summary>
  447. /// Instructs antoher client to browse to a library item.
  448. /// </summary>
  449. /// <param name="sessionId">The session id.</param>
  450. /// <param name="itemId">The id of the item to browse to.</param>
  451. /// <param name="itemName">The name of the item to browse to.</param>
  452. /// <param name="itemType">The type of the item to browse to.</param>
  453. /// <param name="context">Optional ui context (movies, music, tv, games, etc). The client is free to ignore this.</param>
  454. /// <returns>Task.</returns>
  455. Task SendBrowseCommandAsync(string sessionId, string itemId, string itemName, string itemType, string context);
  456. /// <summary>
  457. /// Sends the playstate command async.
  458. /// </summary>
  459. /// <param name="sessionId">The session id.</param>
  460. /// <param name="request">The request.</param>
  461. /// <returns>Task.</returns>
  462. Task SendPlaystateCommandAsync(string sessionId, PlaystateRequest request);
  463. /// <summary>
  464. /// Sends the play command async.
  465. /// </summary>
  466. /// <param name="sessionId">The session id.</param>
  467. /// <param name="request">The request.</param>
  468. /// <returns>Task.</returns>
  469. /// <exception cref="ArgumentNullException">sessionId
  470. /// or
  471. /// request</exception>
  472. Task SendPlayCommandAsync(string sessionId, PlayRequest request);
  473. /// <summary>
  474. /// Sends a system command to the client
  475. /// </summary>
  476. /// <param name="sessionId">The session id.</param>
  477. /// <param name="command">The command.</param>
  478. /// <returns>Task.</returns>
  479. Task SendSystemCommandAsync(string sessionId, SystemCommand command);
  480. /// <summary>
  481. /// Instructs the client to display a message to the user
  482. /// </summary>
  483. /// <param name="sessionId">The session id.</param>
  484. /// <param name="command">The command.</param>
  485. /// <returns>Task.</returns>
  486. Task SendMessageCommandAsync(string sessionId, MessageCommand command);
  487. /// <summary>
  488. /// Clears a user's rating for an item
  489. /// </summary>
  490. /// <param name="itemId">The item id.</param>
  491. /// <param name="userId">The user id.</param>
  492. /// <returns>Task{UserItemDataDto}.</returns>
  493. /// <exception cref="ArgumentNullException">itemId</exception>
  494. Task<UserItemDataDto> ClearUserItemRatingAsync(string itemId, string userId);
  495. /// <summary>
  496. /// Updates a user's rating for an item, based on likes or dislikes
  497. /// </summary>
  498. /// <param name="itemId">The item id.</param>
  499. /// <param name="userId">The user id.</param>
  500. /// <param name="likes">if set to <c>true</c> [likes].</param>
  501. /// <returns>Task.</returns>
  502. /// <exception cref="ArgumentNullException">itemId</exception>
  503. Task<UserItemDataDto> UpdateUserItemRatingAsync(string itemId, string userId, bool likes);
  504. /// <summary>
  505. /// Authenticates a user and returns the result
  506. /// </summary>
  507. /// <param name="username">The username.</param>
  508. /// <param name="sha1Hash">The sha1 hash.</param>
  509. /// <returns>Task.</returns>
  510. /// <exception cref="ArgumentNullException">userId</exception>
  511. Task<AuthenticationResult> AuthenticateUserAsync(string username, byte[] sha1Hash);
  512. /// <summary>
  513. /// Updates the server configuration async.
  514. /// </summary>
  515. /// <param name="configuration">The configuration.</param>
  516. /// <returns>Task.</returns>
  517. /// <exception cref="ArgumentNullException">configuration</exception>
  518. Task UpdateServerConfigurationAsync(ServerConfiguration configuration);
  519. /// <summary>
  520. /// Updates the scheduled task triggers.
  521. /// </summary>
  522. /// <param name="id">The id.</param>
  523. /// <param name="triggers">The triggers.</param>
  524. /// <returns>Task{RequestResult}.</returns>
  525. /// <exception cref="ArgumentNullException">id</exception>
  526. Task UpdateScheduledTaskTriggersAsync(Guid id, TaskTriggerInfo[] triggers);
  527. /// <summary>
  528. /// Gets the display preferences.
  529. /// </summary>
  530. /// <param name="id">The id.</param>
  531. /// <param name="userId">The user id.</param>
  532. /// <param name="client">The client.</param>
  533. /// <param name="cancellationToken">The cancellation token.</param>
  534. /// <returns>Task{BaseItemDto}.</returns>
  535. Task<DisplayPreferences> GetDisplayPreferencesAsync(string id, string userId, string client, CancellationToken cancellationToken);
  536. /// <summary>
  537. /// Updates display preferences for a user
  538. /// </summary>
  539. /// <param name="displayPreferences">The display preferences.</param>
  540. /// <param name="userId">The user id.</param>
  541. /// <param name="client">The client.</param>
  542. /// <param name="cancellationToken">The cancellation token.</param>
  543. /// <returns>Task{DisplayPreferences}.</returns>
  544. /// <exception cref="System.ArgumentNullException">userId</exception>
  545. Task UpdateDisplayPreferencesAsync(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken);
  546. /// <summary>
  547. /// Posts a set of data to a url, and deserializes the return stream into T
  548. /// </summary>
  549. /// <typeparam name="T"></typeparam>
  550. /// <param name="url">The URL.</param>
  551. /// <param name="args">The args.</param>
  552. /// <returns>Task{``0}.</returns>
  553. Task<T> PostAsync<T>(string url, Dictionary<string, string> args)
  554. where T : class;
  555. /// <summary>
  556. /// This is a helper around getting a stream from the server that contains serialized data
  557. /// </summary>
  558. /// <param name="url">The URL.</param>
  559. /// <returns>Task{Stream}.</returns>
  560. Task<Stream> GetSerializedStreamAsync(string url);
  561. /// <summary>
  562. /// Gets the json serializer.
  563. /// </summary>
  564. /// <value>The json serializer.</value>
  565. IJsonSerializer JsonSerializer { get; set; }
  566. /// <summary>
  567. /// Gets or sets the server host name (myserver or 192.168.x.x)
  568. /// </summary>
  569. /// <value>The name of the server host.</value>
  570. string ServerHostName { get; set; }
  571. /// <summary>
  572. /// Gets or sets the port number used by the API
  573. /// </summary>
  574. /// <value>The server API port.</value>
  575. int ServerApiPort { get; set; }
  576. /// <summary>
  577. /// Gets or sets the type of the client.
  578. /// </summary>
  579. /// <value>The type of the client.</value>
  580. string ClientName { get; set; }
  581. /// <summary>
  582. /// Gets or sets the name of the device.
  583. /// </summary>
  584. /// <value>The name of the device.</value>
  585. string DeviceName { get; set; }
  586. /// <summary>
  587. /// Gets or sets the device id.
  588. /// </summary>
  589. /// <value>The device id.</value>
  590. string DeviceId { get; set; }
  591. /// <summary>
  592. /// Gets or sets the current user id.
  593. /// </summary>
  594. /// <value>The current user id.</value>
  595. string CurrentUserId { get; set; }
  596. /// <summary>
  597. /// Gets the image URL.
  598. /// </summary>
  599. /// <param name="item">The item.</param>
  600. /// <param name="options">The options.</param>
  601. /// <returns>System.String.</returns>
  602. /// <exception cref="ArgumentNullException">item</exception>
  603. string GetImageUrl(BaseItemDto item, ImageOptions options);
  604. /// <summary>
  605. /// Gets an image url that can be used to download an image from the api
  606. /// </summary>
  607. /// <param name="itemId">The Id of the item</param>
  608. /// <param name="options">The options.</param>
  609. /// <returns>System.String.</returns>
  610. /// <exception cref="ArgumentNullException">itemId</exception>
  611. string GetImageUrl(string itemId, ImageOptions options);
  612. /// <summary>
  613. /// Gets the user image URL.
  614. /// </summary>
  615. /// <param name="user">The user.</param>
  616. /// <param name="options">The options.</param>
  617. /// <returns>System.String.</returns>
  618. /// <exception cref="ArgumentNullException">user</exception>
  619. string GetUserImageUrl(UserDto user, ImageOptions options);
  620. /// <summary>
  621. /// Gets an image url that can be used to download an image from the api
  622. /// </summary>
  623. /// <param name="userId">The Id of the user</param>
  624. /// <param name="options">The options.</param>
  625. /// <returns>System.String.</returns>
  626. /// <exception cref="ArgumentNullException">userId</exception>
  627. string GetUserImageUrl(string userId, ImageOptions options);
  628. /// <summary>
  629. /// Gets the person image URL.
  630. /// </summary>
  631. /// <param name="item">The item.</param>
  632. /// <param name="options">The options.</param>
  633. /// <returns>System.String.</returns>
  634. /// <exception cref="ArgumentNullException">item</exception>
  635. string GetPersonImageUrl(BaseItemPerson item, ImageOptions options);
  636. /// <summary>
  637. /// Gets an image url that can be used to download an image from the api
  638. /// </summary>
  639. /// <param name="name">The name of the person</param>
  640. /// <param name="options">The options.</param>
  641. /// <returns>System.String.</returns>
  642. /// <exception cref="ArgumentNullException">name</exception>
  643. string GetPersonImageUrl(string name, ImageOptions options);
  644. /// <summary>
  645. /// Gets the year image URL.
  646. /// </summary>
  647. /// <param name="item">The item.</param>
  648. /// <param name="options">The options.</param>
  649. /// <returns>System.String.</returns>
  650. /// <exception cref="ArgumentNullException">item</exception>
  651. string GetYearImageUrl(BaseItemDto item, ImageOptions options);
  652. /// <summary>
  653. /// Gets an image url that can be used to download an image from the api
  654. /// </summary>
  655. /// <param name="year">The year.</param>
  656. /// <param name="options">The options.</param>
  657. /// <returns>System.String.</returns>
  658. string GetYearImageUrl(int year, ImageOptions options);
  659. /// <summary>
  660. /// Gets an image url that can be used to download an image from the api
  661. /// </summary>
  662. /// <param name="name">The name.</param>
  663. /// <param name="options">The options.</param>
  664. /// <returns>System.String.</returns>
  665. /// <exception cref="ArgumentNullException">name</exception>
  666. string GetGenreImageUrl(string name, ImageOptions options);
  667. /// <summary>
  668. /// Gets the music genre image URL.
  669. /// </summary>
  670. /// <param name="name">The name.</param>
  671. /// <param name="options">The options.</param>
  672. /// <returns>System.String.</returns>
  673. string GetMusicGenreImageUrl(string name, ImageOptions options);
  674. /// <summary>
  675. /// Gets the game genre image URL.
  676. /// </summary>
  677. /// <param name="name">The name.</param>
  678. /// <param name="options">The options.</param>
  679. /// <returns>System.String.</returns>
  680. string GetGameGenreImageUrl(string name, ImageOptions options);
  681. /// <summary>
  682. /// Gets an image url that can be used to download an image from the api
  683. /// </summary>
  684. /// <param name="name">The name.</param>
  685. /// <param name="options">The options.</param>
  686. /// <returns>System.String.</returns>
  687. /// <exception cref="ArgumentNullException">name</exception>
  688. string GetStudioImageUrl(string name, ImageOptions options);
  689. /// <summary>
  690. /// Gets the artist image URL.
  691. /// </summary>
  692. /// <param name="name">The name.</param>
  693. /// <param name="options">The options.</param>
  694. /// <returns>System.String.</returns>
  695. /// <exception cref="ArgumentNullException">name</exception>
  696. string GetArtistImageUrl(string name, ImageOptions options);
  697. /// <summary>
  698. /// This is a helper to get a list of backdrop url's from a given ApiBaseItemWrapper. If the actual item does not have any backdrops it will return backdrops from the first parent that does.
  699. /// </summary>
  700. /// <param name="item">A given item.</param>
  701. /// <param name="options">The options.</param>
  702. /// <returns>System.String[][].</returns>
  703. /// <exception cref="ArgumentNullException">item</exception>
  704. string[] GetBackdropImageUrls(BaseItemDto item, ImageOptions options);
  705. /// <summary>
  706. /// This is a helper to get the logo image url from a given ApiBaseItemWrapper. If the actual item does not have a logo, it will return the logo from the first parent that does, or null.
  707. /// </summary>
  708. /// <param name="item">A given item.</param>
  709. /// <param name="options">The options.</param>
  710. /// <returns>System.String.</returns>
  711. /// <exception cref="ArgumentNullException">item</exception>
  712. string GetLogoImageUrl(BaseItemDto item, ImageOptions options);
  713. /// <summary>
  714. /// Gets the art image URL.
  715. /// </summary>
  716. /// <param name="item">The item.</param>
  717. /// <param name="options">The options.</param>
  718. /// <returns>System.String.</returns>
  719. string GetArtImageUrl(BaseItemDto item, ImageOptions options);
  720. /// <summary>
  721. /// Gets the url needed to stream an audio file
  722. /// </summary>
  723. /// <param name="options">The options.</param>
  724. /// <returns>System.String.</returns>
  725. /// <exception cref="ArgumentNullException">options</exception>
  726. string GetAudioStreamUrl(StreamOptions options);
  727. /// <summary>
  728. /// Gets the url needed to stream a video file
  729. /// </summary>
  730. /// <param name="options">The options.</param>
  731. /// <returns>System.String.</returns>
  732. /// <exception cref="ArgumentNullException">options</exception>
  733. string GetVideoStreamUrl(VideoStreamOptions options);
  734. /// <summary>
  735. /// Formulates a url for streaming audio using the HLS protocol
  736. /// </summary>
  737. /// <param name="options">The options.</param>
  738. /// <returns>System.String.</returns>
  739. /// <exception cref="ArgumentNullException">options</exception>
  740. string GetHlsAudioStreamUrl(StreamOptions options);
  741. /// <summary>
  742. /// Formulates a url for streaming video using the HLS protocol
  743. /// </summary>
  744. /// <param name="options">The options.</param>
  745. /// <returns>System.String.</returns>
  746. /// <exception cref="ArgumentNullException">options</exception>
  747. string GetHlsVideoStreamUrl(VideoStreamOptions options);
  748. }
  749. }