Browse Source

more updates for api docs

LukePulverenti 12 years ago
parent
commit
34cc4eee9d

+ 19 - 0
MediaBrowser.Api/Images/ImageRequest.cs

@@ -1,4 +1,5 @@
 using MediaBrowser.Model.Entities;
 using MediaBrowser.Model.Entities;
+using ServiceStack.ServiceHost;
 
 
 namespace MediaBrowser.Api.Images
 namespace MediaBrowser.Api.Images
 {
 {
@@ -10,28 +11,39 @@ namespace MediaBrowser.Api.Images
         /// <summary>
         /// <summary>
         /// The max width
         /// The max width
         /// </summary>
         /// </summary>
+        [ApiMember(Name = "MaxWidth", Description = "The maximum image width to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? MaxWidth { get; set; }
         public int? MaxWidth { get; set; }
+
         /// <summary>
         /// <summary>
         /// The max height
         /// The max height
         /// </summary>
         /// </summary>
+        [ApiMember(Name = "MaxHeight", Description = "The maximum image height to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? MaxHeight { get; set; }
         public int? MaxHeight { get; set; }
+
         /// <summary>
         /// <summary>
         /// The width
         /// The width
         /// </summary>
         /// </summary>
+        [ApiMember(Name = "Width", Description = "The fixed image width to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? Width { get; set; }
         public int? Width { get; set; }
+
         /// <summary>
         /// <summary>
         /// The height
         /// The height
         /// </summary>
         /// </summary>
+        [ApiMember(Name = "Height", Description = "The fixed image height to return.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? Height { get; set; }
         public int? Height { get; set; }
+
         /// <summary>
         /// <summary>
         /// Gets or sets the quality.
         /// Gets or sets the quality.
         /// </summary>
         /// </summary>
         /// <value>The quality.</value>
         /// <value>The quality.</value>
+        [ApiMember(Name = "Quality", Description = "Optional quality setting, from 0-100. Defaults to 90 and should suffice in most cases.", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
         public int? Quality { get; set; }
         public int? Quality { get; set; }
+
         /// <summary>
         /// <summary>
         /// Gets or sets the tag.
         /// Gets or sets the tag.
         /// </summary>
         /// </summary>
         /// <value>The tag.</value>
         /// <value>The tag.</value>
+        [ApiMember(Name = "Tag", Description = "Optional. Supply the cache tag from the item object to receive strong caching headers.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
         public string Tag { get; set; }
         public string Tag { get; set; }
     }
     }
 
 
@@ -44,11 +56,18 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the type of the image.
         /// Gets or sets the type of the image.
         /// </summary>
         /// </summary>
         /// <value>The type of the image.</value>
         /// <value>The type of the image.</value>
+        [ApiMember(Name = "Type", Description = "Image Type", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
+        [ApiMember(Name = "Type", Description = "Image Type", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
+        [ApiMember(Name = "Type", Description = "Image Type", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
         public ImageType Type { get; set; }
         public ImageType Type { get; set; }
+
         /// <summary>
         /// <summary>
         /// Gets or sets the index.
         /// Gets or sets the index.
         /// </summary>
         /// </summary>
         /// <value>The index.</value>
         /// <value>The index.</value>
+        [ApiMember(Name = "Index", Description = "Image Index", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")]
+        [ApiMember(Name = "Index", Description = "Image Index", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "POST")]
+        [ApiMember(Name = "Index", Description = "Image Index", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "DELETE")]
         public int? Index { get; set; }
         public int? Index { get; set; }
     }
     }
 }
 }

+ 9 - 2
MediaBrowser.Api/Images/ImageService.cs

@@ -28,6 +28,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the id.
         /// Gets or sets the id.
         /// </summary>
         /// </summary>
         /// <value>The id.</value>
         /// <value>The id.</value>
+        [ApiMember(Name = "Id", Description = "Item Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public string Id { get; set; }
         public string Id { get; set; }
     }
     }
 
 
@@ -43,6 +44,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the name.
         /// Gets or sets the name.
         /// </summary>
         /// </summary>
         /// <value>The name.</value>
         /// <value>The name.</value>
+        [ApiMember(Name = "Name", Description = "Person name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public string Name { get; set; }
         public string Name { get; set; }
     }
     }
 
 
@@ -58,6 +60,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the name.
         /// Gets or sets the name.
         /// </summary>
         /// </summary>
         /// <value>The name.</value>
         /// <value>The name.</value>
+        [ApiMember(Name = "Name", Description = "Studio name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public string Name { get; set; }
         public string Name { get; set; }
     }
     }
 
 
@@ -73,6 +76,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the name.
         /// Gets or sets the name.
         /// </summary>
         /// </summary>
         /// <value>The name.</value>
         /// <value>The name.</value>
+        [ApiMember(Name = "Name", Description = "Genre name", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public string Name { get; set; }
         public string Name { get; set; }
     }
     }
 
 
@@ -88,6 +92,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the year.
         /// Gets or sets the year.
         /// </summary>
         /// </summary>
         /// <value>The year.</value>
         /// <value>The year.</value>
+        [ApiMember(Name = "Year", Description = "Year", IsRequired = true, DataType = "int", ParameterType = "path", Verb = "GET")]
         public int Year { get; set; }
         public int Year { get; set; }
     }
     }
 
 
@@ -103,6 +108,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the id.
         /// Gets or sets the id.
         /// </summary>
         /// </summary>
         /// <value>The id.</value>
         /// <value>The id.</value>
+        [ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "GET")]
         public Guid Id { get; set; }
         public Guid Id { get; set; }
     }
     }
 
 
@@ -118,6 +124,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the id.
         /// Gets or sets the id.
         /// </summary>
         /// </summary>
         /// <value>The id.</value>
         /// <value>The id.</value>
+        [ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")]
         public Guid Id { get; set; }
         public Guid Id { get; set; }
     }
     }
 
 
@@ -130,6 +137,7 @@ namespace MediaBrowser.Api.Images
         /// Gets or sets the id.
         /// Gets or sets the id.
         /// </summary>
         /// </summary>
         /// <value>The id.</value>
         /// <value>The id.</value>
+        [ApiMember(Name = "Id", Description = "User Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "POST")]
         public Guid Id { get; set; }
         public Guid Id { get; set; }
 
 
         /// <summary>
         /// <summary>
@@ -316,8 +324,7 @@ namespace MediaBrowser.Api.Images
                 Item = item,
                 Item = item,
                 Request = request,
                 Request = request,
                 CropWhiteSpace = request.Type == ImageType.Logo || request.Type == ImageType.Art,
                 CropWhiteSpace = request.Type == ImageType.Logo || request.Type == ImageType.Art,
-                OriginalImageDateModified = originalFileImageDateModified,
-                ContentType = contentType
+                OriginalImageDateModified = originalFileImageDateModified
 
 
             }, contentType);
             }, contentType);
         }
         }

+ 1 - 23
MediaBrowser.Api/Images/ImageWriter.cs

@@ -1,9 +1,7 @@
 using MediaBrowser.Controller;
 using MediaBrowser.Controller;
 using MediaBrowser.Controller.Entities;
 using MediaBrowser.Controller.Entities;
 using ServiceStack.Service;
 using ServiceStack.Service;
-using ServiceStack.ServiceHost;
 using System;
 using System;
-using System.Collections.Generic;
 using System.IO;
 using System.IO;
 using System.Threading.Tasks;
 using System.Threading.Tasks;
 
 
@@ -12,7 +10,7 @@ namespace MediaBrowser.Api.Images
     /// <summary>
     /// <summary>
     /// Class ImageWriter
     /// Class ImageWriter
     /// </summary>
     /// </summary>
-    public class ImageWriter : IStreamWriter, IHasOptions
+    public class ImageWriter : IStreamWriter
     {
     {
         /// <summary>
         /// <summary>
         /// Gets or sets the request.
         /// Gets or sets the request.
@@ -33,11 +31,6 @@ namespace MediaBrowser.Api.Images
         /// The original image date modified
         /// The original image date modified
         /// </summary>
         /// </summary>
         public DateTime OriginalImageDateModified;
         public DateTime OriginalImageDateModified;
-        /// <summary>
-        /// Gets or sets the type of the content.
-        /// </summary>
-        /// <value>The type of the content.</value>
-        public string ContentType { get; set; }
 
 
         /// <summary>
         /// <summary>
         /// Writes to.
         /// Writes to.
@@ -45,8 +38,6 @@ namespace MediaBrowser.Api.Images
         /// <param name="responseStream">The response stream.</param>
         /// <param name="responseStream">The response stream.</param>
         public void WriteTo(Stream responseStream)
         public void WriteTo(Stream responseStream)
         {
         {
-            Options["Content-Type"] = ContentType;
-
             var task = WriteToAsync(responseStream);
             var task = WriteToAsync(responseStream);
 
 
             Task.WaitAll(task);
             Task.WaitAll(task);
@@ -63,18 +54,5 @@ namespace MediaBrowser.Api.Images
                                                     OriginalImageDateModified, responseStream, Request.Width, Request.Height, Request.MaxWidth,
                                                     OriginalImageDateModified, responseStream, Request.Width, Request.Height, Request.MaxWidth,
                                                     Request.MaxHeight, Request.Quality);
                                                     Request.MaxHeight, Request.Quality);
         }
         }
-
-        /// <summary>
-        /// The _options
-        /// </summary>
-        private readonly IDictionary<string, string> _options = new Dictionary<string, string> { };
-        /// <summary>
-        /// Gets the options.
-        /// </summary>
-        /// <value>The options.</value>
-        public IDictionary<string, string> Options
-        {
-            get { return _options; }
-        }
     }
     }
 }
 }

+ 8 - 10
MediaBrowser.Server.Implementations/HttpServer/BaseRestService.cs

@@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
 
 
             var key = cacheKey.ToString("N");
             var key = cacheKey.ToString("N");
 
 
-            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration, string.Empty);
+            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration);
 
 
             if (result != null)
             if (result != null)
             {
             {
@@ -117,9 +117,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                 throw new ArgumentNullException("factoryFn");
                 throw new ArgumentNullException("factoryFn");
             }
             }
 
 
+            Response.ContentType = contentType;
+            
             var key = cacheKey.ToString("N");
             var key = cacheKey.ToString("N");
 
 
-            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration, contentType);
+            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration);
 
 
             if (result != null)
             if (result != null)
             {
             {
@@ -183,7 +185,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
 
 
             var key = cacheKey.ToString("N");
             var key = cacheKey.ToString("N");
 
 
-            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration, contentType);
+            Response.ContentType = contentType;
+            
+            var result = PreProcessCachedResult(cacheKey, key, lastDateModified, cacheDuration);
 
 
             if (result != null)
             if (result != null)
             {
             {
@@ -278,9 +282,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
         /// <param name="cacheKeyString">The cache key string.</param>
         /// <param name="cacheKeyString">The cache key string.</param>
         /// <param name="lastDateModified">The last date modified.</param>
         /// <param name="lastDateModified">The last date modified.</param>
         /// <param name="cacheDuration">Duration of the cache.</param>
         /// <param name="cacheDuration">Duration of the cache.</param>
-        /// <param name="contentType">Type of the content.</param>
         /// <returns>System.Object.</returns>
         /// <returns>System.Object.</returns>
-        private object PreProcessCachedResult(Guid cacheKey, string cacheKeyString, DateTime? lastDateModified, TimeSpan? cacheDuration, string contentType)
+        private object PreProcessCachedResult(Guid cacheKey, string cacheKeyString, DateTime? lastDateModified, TimeSpan? cacheDuration)
         {
         {
             Response.AddHeader("ETag", cacheKeyString);
             Response.AddHeader("ETag", cacheKeyString);
 
 
@@ -290,11 +293,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
                 AddExpiresHeader(cacheKeyString, cacheDuration);
                 AddExpiresHeader(cacheKeyString, cacheDuration);
                 //ctx.Response.SendChunked = false;
                 //ctx.Response.SendChunked = false;
 
 
-                if (!string.IsNullOrEmpty(contentType))
-                {
-                    Response.ContentType = contentType;
-                }
-
                 Response.StatusCode = 304;
                 Response.StatusCode = 304;
 
 
                 return new byte[]{};
                 return new byte[]{};