ReportRequests.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. using MediaBrowser.Api.UserLibrary;
  2. using MediaBrowser.Model.Entities;
  3. using ServiceStack;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace MediaBrowser.Api.Reports
  8. {
  9. public interface IReportsDownload : IReportsQuery
  10. {
  11. /// <summary> Gets or sets the minimum date. </summary>
  12. /// <value> The minimum date. </value>
  13. string MinDate { get; set; }
  14. }
  15. /// <summary> Interface for reports query. </summary>
  16. public interface IReportsQuery : IReportsHeader
  17. {
  18. /// <summary>
  19. /// Gets or sets a value indicating whether this MediaBrowser.Api.Reports.GetActivityLogs has
  20. /// query limit. </summary>
  21. /// <value>
  22. /// true if this MediaBrowser.Api.Reports.GetActivityLogs has query limit, false if not. </value>
  23. bool HasQueryLimit { get; set; }
  24. /// <summary> Gets or sets who group this MediaBrowser.Api.Reports.GetActivityLogs. </summary>
  25. /// <value> Describes who group this MediaBrowser.Api.Reports.GetActivityLogs. </value>
  26. string GroupBy { get; set; }
  27. /// <summary>
  28. /// Skips over a given number of items within the results. Use for paging.
  29. /// </summary>
  30. /// <value>The start index.</value>
  31. int? StartIndex { get; set; }
  32. /// <summary>
  33. /// The maximum number of items to return
  34. /// </summary>
  35. /// <value>The limit.</value>
  36. int? Limit { get; set; }
  37. }
  38. public interface IReportsHeader
  39. {
  40. /// <summary> Gets or sets the report view. </summary>
  41. /// <value> The report view. </value>
  42. string ReportView { get; set; }
  43. /// <summary> Gets or sets the report columns. </summary>
  44. /// <value> The report columns. </value>
  45. string ReportColumns { get; set; }
  46. /// <summary> Gets or sets a list of types of the include items. </summary>
  47. /// <value> A list of types of the include items. </value>
  48. string IncludeItemTypes { get; set; }
  49. /// <summary> Gets or sets a list of types of the displays. </summary>
  50. /// <value> A list of types of the displays. </value>
  51. string DisplayType { get; set; }
  52. }
  53. public class BaseReportRequest : BaseItemsRequest, IReportsQuery
  54. {
  55. /// <summary> Gets or sets the report view. </summary>
  56. /// <value> The report view. </value>
  57. [ApiMember(Name = "ReportView", Description = "The report view. Values (ReportData, ReportStatistics, ReportActivities)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  58. public string ReportView { get; set; }
  59. /// <summary> Gets or sets the report view. </summary>
  60. /// <value> The report view. </value>
  61. [ApiMember(Name = "DisplayType", Description = "The report display type. Values (None, Screen, Export, ScreenExport)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  62. public string DisplayType { get; set; }
  63. /// <summary>
  64. /// Gets or sets a value indicating whether this MediaBrowser.Api.Reports.BaseReportRequest has
  65. /// query limit. </summary>
  66. /// <value>
  67. /// true if this MediaBrowser.Api.Reports.BaseReportRequest has query limit, false if not. </value>
  68. [ApiMember(Name = "HasQueryLimit", Description = "Optional. If specified, results will include all records.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  69. public bool HasQueryLimit { get; set; }
  70. /// <summary>
  71. /// Gets or sets who group this MediaBrowser.Api.Reports.BaseReportRequest. </summary>
  72. /// <value> Describes who group this MediaBrowser.Api.Reports.BaseReportRequest. </value>
  73. [ApiMember(Name = "GroupBy", Description = "Optional. If specified, results will include grouped records.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  74. public string GroupBy { get; set; }
  75. /// <summary> Gets or sets the report columns. </summary>
  76. /// <value> The report columns. </value>
  77. [ApiMember(Name = "ReportColumns", Description = "Optional. The columns to show.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  78. public string ReportColumns { get; set; }
  79. }
  80. [Route("/Reports/Items", "GET", Summary = "Gets reports based on library items")]
  81. public class GetItemReport : BaseReportRequest, IReturn<ReportResult>
  82. {
  83. }
  84. [Route("/Reports/Headers", "GET", Summary = "Gets reports headers based on library items")]
  85. public class GetReportHeaders : IReturn<List<ReportHeader>>, IReportsHeader
  86. {
  87. /// <summary> Gets or sets the report view. </summary>
  88. /// <value> The report view. </value>
  89. [ApiMember(Name = "ReportView", Description = "The report view. Values (ReportData, ReportStatistics, ReportActivities)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  90. public string ReportView { get; set; }
  91. /// <summary> Gets or sets the report view. </summary>
  92. /// <value> The report view. </value>
  93. [ApiMember(Name = "DisplayType", Description = "The report display type. Values (None, Screen, Export, ScreenExport)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  94. public string DisplayType { get; set; }
  95. /// <summary> Gets or sets a list of types of the include items. </summary>
  96. /// <value> A list of types of the include items. </value>
  97. [ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  98. public string IncludeItemTypes { get; set; }
  99. /// <summary> Gets or sets the report columns. </summary>
  100. /// <value> The report columns. </value>
  101. [ApiMember(Name = "ReportColumns", Description = "Optional. The columns to show.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  102. public string ReportColumns { get; set; }
  103. }
  104. [Route("/Reports/Statistics", "GET", Summary = "Gets reports statistics based on library items")]
  105. public class GetReportStatistics : BaseReportRequest, IReturn<ReportStatResult>
  106. {
  107. public int? TopItems { get; set; }
  108. }
  109. [Route("/Reports/Items/Download", "GET", Summary = "Downloads report")]
  110. public class GetReportDownload : BaseReportRequest, IReportsDownload
  111. {
  112. public GetReportDownload()
  113. {
  114. ExportType = ReportExportType.CSV;
  115. }
  116. public ReportExportType ExportType { get; set; }
  117. /// <summary> Gets or sets the minimum date. </summary>
  118. /// <value> The minimum date. </value>
  119. [ApiMember(Name = "MinDate", Description = "Optional. The minimum date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
  120. public string MinDate { get; set; }
  121. }
  122. [Route("/Reports/Activities", "GET", Summary = "Gets activities entries")]
  123. public class GetActivityLogs : IReturn<ReportResult>, IReportsQuery, IReportsDownload
  124. {
  125. /// <summary> Gets or sets the report view. </summary>
  126. /// <value> The report view. </value>
  127. [ApiMember(Name = "ReportView", Description = "The report view. Values (ReportData, ReportStatistics, ReportActivities)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  128. public string ReportView { get; set; }
  129. /// <summary> Gets or sets the report view. </summary>
  130. /// <value> The report view. </value>
  131. [ApiMember(Name = "DisplayType", Description = "The report display type. Values (None, Screen, Export, ScreenExport)", IsRequired = true, DataType = "string", ParameterType = "query", Verb = "GET")]
  132. public string DisplayType { get; set; }
  133. /// <summary>
  134. /// Gets or sets a value indicating whether this MediaBrowser.Api.Reports.GetActivityLogs has
  135. /// query limit. </summary>
  136. /// <value>
  137. /// true if this MediaBrowser.Api.Reports.GetActivityLogs has query limit, false if not. </value>
  138. [ApiMember(Name = "HasQueryLimit", Description = "Optional. If specified, results will include all records.", IsRequired = false, DataType = "bool", ParameterType = "query", Verb = "GET")]
  139. public bool HasQueryLimit { get; set; }
  140. /// <summary> Gets or sets who group this MediaBrowser.Api.Reports.GetActivityLogs. </summary>
  141. /// <value> Describes who group this MediaBrowser.Api.Reports.GetActivityLogs. </value>
  142. [ApiMember(Name = "GroupBy", Description = "Optional. If specified, results will include grouped records.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  143. public string GroupBy { get; set; }
  144. /// <summary> Gets or sets the report columns. </summary>
  145. /// <value> The report columns. </value>
  146. [ApiMember(Name = "ReportColumns", Description = "Optional. The columns to show.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
  147. public string ReportColumns { get; set; }
  148. /// <summary>
  149. /// Skips over a given number of items within the results. Use for paging.
  150. /// </summary>
  151. /// <value>The start index.</value>
  152. [ApiMember(Name = "StartIndex", Description = "Optional. The record index to start at. All items with a lower index will be dropped from the results.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  153. public int? StartIndex { get; set; }
  154. /// <summary>
  155. /// The maximum number of items to return
  156. /// </summary>
  157. /// <value>The limit.</value>
  158. [ApiMember(Name = "Limit", Description = "Optional. The maximum number of records to return", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
  159. public int? Limit { get; set; }
  160. /// <summary> Gets or sets the minimum date. </summary>
  161. /// <value> The minimum date. </value>
  162. [ApiMember(Name = "MinDate", Description = "Optional. The minimum date. Format = ISO", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "POST")]
  163. public string MinDate { get; set; }
  164. [ApiMember(Name = "IncludeItemTypes", Description = "Optional. If specified, results will be filtered based on item type. This allows multiple, comma delimeted.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
  165. public string IncludeItemTypes { get; set; }
  166. }
  167. }