| | | 1 | | // <auto-generated> |
| | | 2 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | | 3 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | | 4 | | // regenerated. |
| | | 5 | | // </auto-generated> |
| | | 6 | | |
| | | 7 | | namespace Microsoft.Azure.CognitiveServices.Search.VisualSearch |
| | | 8 | | { |
| | | 9 | | using Microsoft.Rest; |
| | | 10 | | using Microsoft.Rest.Serialization; |
| | | 11 | | using Models; |
| | | 12 | | using Newtonsoft.Json; |
| | | 13 | | using System.Collections; |
| | | 14 | | using System.Collections.Generic; |
| | | 15 | | using System.Net; |
| | | 16 | | using System.Net.Http; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// Visual Search API lets you discover insights about an image such as |
| | | 20 | | /// visually similar images, shopping sources, and related searches. The |
| | | 21 | | /// API can also perform text recognition, identify entities (people, |
| | | 22 | | /// places, things), return other topical content for the user to explore, |
| | | 23 | | /// and more. For more information, see [Visual Search |
| | | 24 | | /// Overview](https://docs.microsoft.com/azure/cognitive-services/bing-visual-search/overview). |
| | | 25 | | /// </summary> |
| | | 26 | | public partial class VisualSearchClient : ServiceClient<VisualSearchClient>, IVisualSearchClient |
| | | 27 | | { |
| | | 28 | | /// <summary> |
| | | 29 | | /// The base URI of the service. |
| | | 30 | | /// </summary> |
| | 16 | 31 | | internal string BaseUri {get; set;} |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets or sets json serialization settings. |
| | | 35 | | /// </summary> |
| | 24 | 36 | | public JsonSerializerSettings SerializationSettings { get; private set; } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets or sets json deserialization settings. |
| | | 40 | | /// </summary> |
| | 32 | 41 | | public JsonSerializerSettings DeserializationSettings { get; private set; } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Supported Cognitive Services endpoints (protocol and hostname, for example: |
| | | 45 | | /// "https://westus.api.cognitive.microsoft.com", |
| | | 46 | | /// "https://api.cognitive.microsoft.com"). |
| | | 47 | | /// </summary> |
| | 24 | 48 | | public string Endpoint { get; set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Subscription credentials which uniquely identify client subscription. |
| | | 52 | | /// </summary> |
| | 40 | 53 | | public ServiceClientCredentials Credentials { get; private set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// Gets the IImages. |
| | | 57 | | /// </summary> |
| | 16 | 58 | | public virtual IImages Images { get; private set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 62 | | /// </summary> |
| | | 63 | | /// <param name='httpClient'> |
| | | 64 | | /// HttpClient to be used |
| | | 65 | | /// </param> |
| | | 66 | | /// <param name='disposeHttpClient'> |
| | | 67 | | /// True: will dispose the provided httpClient on calling VisualSearchClient.Dispose(). False: will not dispose |
| | 0 | 68 | | protected VisualSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient |
| | | 69 | | { |
| | 0 | 70 | | Initialize(); |
| | 0 | 71 | | } |
| | | 72 | | |
| | | 73 | | /// <summary> |
| | | 74 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 75 | | /// </summary> |
| | | 76 | | /// <param name='handlers'> |
| | | 77 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | | 78 | | /// </param> |
| | 8 | 79 | | protected VisualSearchClient(params DelegatingHandler[] handlers) : base(handlers) |
| | | 80 | | { |
| | 8 | 81 | | Initialize(); |
| | 8 | 82 | | } |
| | | 83 | | |
| | | 84 | | /// <summary> |
| | | 85 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 86 | | /// </summary> |
| | | 87 | | /// <param name='rootHandler'> |
| | | 88 | | /// Optional. The http client handler used to handle http transport. |
| | | 89 | | /// </param> |
| | | 90 | | /// <param name='handlers'> |
| | | 91 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | | 92 | | /// </param> |
| | 0 | 93 | | protected VisualSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHand |
| | | 94 | | { |
| | 0 | 95 | | Initialize(); |
| | 0 | 96 | | } |
| | | 97 | | |
| | | 98 | | /// <summary> |
| | | 99 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 100 | | /// </summary> |
| | | 101 | | /// <param name='credentials'> |
| | | 102 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | | 103 | | /// </param> |
| | | 104 | | /// <param name='handlers'> |
| | | 105 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | | 106 | | /// </param> |
| | | 107 | | /// <exception cref="System.ArgumentNullException"> |
| | | 108 | | /// Thrown when a required parameter is null |
| | | 109 | | /// </exception> |
| | 8 | 110 | | public VisualSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(hand |
| | | 111 | | { |
| | 8 | 112 | | if (credentials == null) |
| | | 113 | | { |
| | 0 | 114 | | throw new System.ArgumentNullException("credentials"); |
| | | 115 | | } |
| | 8 | 116 | | Credentials = credentials; |
| | 8 | 117 | | if (Credentials != null) |
| | | 118 | | { |
| | 8 | 119 | | Credentials.InitializeServiceClient(this); |
| | | 120 | | } |
| | 8 | 121 | | } |
| | | 122 | | |
| | | 123 | | /// <summary> |
| | | 124 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 125 | | /// </summary> |
| | | 126 | | /// <param name='credentials'> |
| | | 127 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | | 128 | | /// </param> |
| | | 129 | | /// <param name='httpClient'> |
| | | 130 | | /// HttpClient to be used |
| | | 131 | | /// </param> |
| | | 132 | | /// <param name='disposeHttpClient'> |
| | | 133 | | /// True: will dispose the provided httpClient on calling VisualSearchClient.Dispose(). False: will not dispose |
| | | 134 | | /// <exception cref="System.ArgumentNullException"> |
| | | 135 | | /// Thrown when a required parameter is null |
| | | 136 | | /// </exception> |
| | 0 | 137 | | public VisualSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : |
| | | 138 | | { |
| | 0 | 139 | | if (credentials == null) |
| | | 140 | | { |
| | 0 | 141 | | throw new System.ArgumentNullException("credentials"); |
| | | 142 | | } |
| | 0 | 143 | | Credentials = credentials; |
| | 0 | 144 | | if (Credentials != null) |
| | | 145 | | { |
| | 0 | 146 | | Credentials.InitializeServiceClient(this); |
| | | 147 | | } |
| | 0 | 148 | | } |
| | | 149 | | |
| | | 150 | | /// <summary> |
| | | 151 | | /// Initializes a new instance of the VisualSearchClient class. |
| | | 152 | | /// </summary> |
| | | 153 | | /// <param name='credentials'> |
| | | 154 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | | 155 | | /// </param> |
| | | 156 | | /// <param name='rootHandler'> |
| | | 157 | | /// Optional. The http client handler used to handle http transport. |
| | | 158 | | /// </param> |
| | | 159 | | /// <param name='handlers'> |
| | | 160 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | | 161 | | /// </param> |
| | | 162 | | /// <exception cref="System.ArgumentNullException"> |
| | | 163 | | /// Thrown when a required parameter is null |
| | | 164 | | /// </exception> |
| | 0 | 165 | | public VisualSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params Delegating |
| | | 166 | | { |
| | 0 | 167 | | if (credentials == null) |
| | | 168 | | { |
| | 0 | 169 | | throw new System.ArgumentNullException("credentials"); |
| | | 170 | | } |
| | 0 | 171 | | Credentials = credentials; |
| | 0 | 172 | | if (Credentials != null) |
| | | 173 | | { |
| | 0 | 174 | | Credentials.InitializeServiceClient(this); |
| | | 175 | | } |
| | 0 | 176 | | } |
| | | 177 | | |
| | | 178 | | /// <summary> |
| | | 179 | | /// An optional partial-method to perform custom initialization. |
| | | 180 | | ///</summary> |
| | | 181 | | partial void CustomInitialize(); |
| | | 182 | | /// <summary> |
| | | 183 | | /// Initializes client properties. |
| | | 184 | | /// </summary> |
| | | 185 | | private void Initialize() |
| | | 186 | | { |
| | 8 | 187 | | Images = new Images(this); |
| | 8 | 188 | | BaseUri = "{Endpoint}/bing/v7.0"; |
| | 8 | 189 | | Endpoint = "https://api.cognitive.microsoft.com"; |
| | 8 | 190 | | SerializationSettings = new JsonSerializerSettings |
| | 8 | 191 | | { |
| | 8 | 192 | | Formatting = Newtonsoft.Json.Formatting.Indented, |
| | 8 | 193 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| | 8 | 194 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| | 8 | 195 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| | 8 | 196 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| | 8 | 197 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| | 8 | 198 | | Converters = new List<JsonConverter> |
| | 8 | 199 | | { |
| | 8 | 200 | | new Iso8601TimeSpanConverter() |
| | 8 | 201 | | } |
| | 8 | 202 | | }; |
| | 8 | 203 | | DeserializationSettings = new JsonSerializerSettings |
| | 8 | 204 | | { |
| | 8 | 205 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| | 8 | 206 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| | 8 | 207 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| | 8 | 208 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| | 8 | 209 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| | 8 | 210 | | Converters = new List<JsonConverter> |
| | 8 | 211 | | { |
| | 8 | 212 | | new Iso8601TimeSpanConverter() |
| | 8 | 213 | | } |
| | 8 | 214 | | }; |
| | 8 | 215 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type")); |
| | 8 | 216 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<ResponseBase>("_type")); |
| | 8 | 217 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<PropertiesItem>("_type")); |
| | 8 | 218 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<PropertiesItem>("_type")); |
| | | 219 | | CustomInitialize(); |
| | 8 | 220 | | } |
| | | 221 | | } |
| | | 222 | | } |