| | 1 | | // <auto-generated> |
| | 2 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 3 | | // Licensed under the MIT License. See License.txt in the project root for |
| | 4 | | // license information. |
| | 5 | | // |
| | 6 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 7 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 8 | | // regenerated. |
| | 9 | | // </auto-generated> |
| | 10 | |
|
| | 11 | | namespace Microsoft.Azure.Search.Models |
| | 12 | | { |
| | 13 | | using Microsoft.Rest; |
| | 14 | | using Newtonsoft.Json; |
| | 15 | | using System.Collections; |
| | 16 | | using System.Collections.Generic; |
| | 17 | | using System.Linq; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// Defines options to control Cross-Origin Resource Sharing (CORS) for an |
| | 21 | | /// index. |
| | 22 | | /// <see |
| | 23 | | /// href="https://docs.microsoft.com/rest/api/searchservice/Create-Index" |
| | 24 | | /// /> |
| | 25 | | /// </summary> |
| | 26 | | public partial class CorsOptions |
| | 27 | | { |
| | 28 | | /// <summary> |
| | 29 | | /// Initializes a new instance of the CorsOptions class. |
| | 30 | | /// </summary> |
| 188 | 31 | | public CorsOptions() |
| | 32 | | { |
| | 33 | | CustomInit(); |
| 188 | 34 | | } |
| | 35 | |
|
| | 36 | | /// <summary> |
| | 37 | | /// Initializes a new instance of the CorsOptions class. |
| | 38 | | /// </summary> |
| | 39 | | /// <param name="allowedOrigins">The list of origins from which |
| | 40 | | /// JavaScript code will be granted access to your index. Can contain a |
| | 41 | | /// list of hosts of the form |
| | 42 | | /// {protocol}://{fully-qualified-domain-name}[:{port#}], or a single |
| | 43 | | /// '*' to allow all origins (not recommended).</param> |
| | 44 | | /// <param name="maxAgeInSeconds">The duration for which browsers |
| | 45 | | /// should cache CORS preflight responses. Defaults to 5 |
| | 46 | | /// minutes.</param> |
| 0 | 47 | | public CorsOptions(IList<string> allowedOrigins, long? maxAgeInSeconds = default(long?)) |
| | 48 | | { |
| 0 | 49 | | AllowedOrigins = allowedOrigins; |
| 0 | 50 | | MaxAgeInSeconds = maxAgeInSeconds; |
| | 51 | | CustomInit(); |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | | /// <summary> |
| | 55 | | /// An initialization method that performs custom operations like setting defaults |
| | 56 | | /// </summary> |
| | 57 | | partial void CustomInit(); |
| | 58 | |
|
| | 59 | | /// <summary> |
| | 60 | | /// Gets or sets the list of origins from which JavaScript code will be |
| | 61 | | /// granted access to your index. Can contain a list of hosts of the |
| | 62 | | /// form {protocol}://{fully-qualified-domain-name}[:{port#}], or a |
| | 63 | | /// single '*' to allow all origins (not recommended). |
| | 64 | | /// </summary> |
| | 65 | | [JsonProperty(PropertyName = "allowedOrigins")] |
| 504 | 66 | | public IList<string> AllowedOrigins { get; set; } |
| | 67 | |
|
| | 68 | | /// <summary> |
| | 69 | | /// Gets or sets the duration for which browsers should cache CORS |
| | 70 | | /// preflight responses. Defaults to 5 minutes. |
| | 71 | | /// </summary> |
| | 72 | | [JsonProperty(PropertyName = "maxAgeInSeconds")] |
| 300 | 73 | | public long? MaxAgeInSeconds { get; set; } |
| | 74 | |
|
| | 75 | | /// <summary> |
| | 76 | | /// Validate the object. |
| | 77 | | /// </summary> |
| | 78 | | /// <exception cref="ValidationException"> |
| | 79 | | /// Thrown if validation fails |
| | 80 | | /// </exception> |
| | 81 | | public virtual void Validate() |
| | 82 | | { |
| 94 | 83 | | if (AllowedOrigins == null) |
| | 84 | | { |
| 0 | 85 | | throw new ValidationException(ValidationRules.CannotBeNull, "AllowedOrigins"); |
| | 86 | | } |
| 94 | 87 | | } |
| | 88 | | } |
| | 89 | | } |