| | 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.ImageSearch |
| | 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 | | /// The Image Search API lets you send a search query to Bing and get back |
| | 20 | | /// a list of relevant images. This section provides technical details |
| | 21 | | /// about the query parameters and headers that you use to request images |
| | 22 | | /// and the JSON response objects that contain them. For examples that show |
| | 23 | | /// how to make requests, see [Searching the Web for |
| | 24 | | /// Images](https://docs.microsoft.com/azure/cognitive-services/bing-image-search/search-the-web). |
| | 25 | | /// </summary> |
| | 26 | | public partial class ImageSearchClient : ServiceClient<ImageSearchClient>, IImageSearchClient |
| | 27 | | { |
| | 28 | | /// <summary> |
| | 29 | | /// The base URI of the service. |
| | 30 | | /// </summary> |
| 12 | 31 | | internal string BaseUri {get; set;} |
| | 32 | |
|
| | 33 | | /// <summary> |
| | 34 | | /// Gets or sets json serialization settings. |
| | 35 | | /// </summary> |
| 18 | 36 | | public JsonSerializerSettings SerializationSettings { get; private set; } |
| | 37 | |
|
| | 38 | | /// <summary> |
| | 39 | | /// Gets or sets json deserialization settings. |
| | 40 | | /// </summary> |
| 24 | 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> |
| 18 | 48 | | public string Endpoint { get; set; } |
| | 49 | |
|
| | 50 | | /// <summary> |
| | 51 | | /// Subscription credentials which uniquely identify client subscription. |
| | 52 | | /// </summary> |
| 30 | 53 | | public ServiceClientCredentials Credentials { get; private set; } |
| | 54 | |
|
| | 55 | | /// <summary> |
| | 56 | | /// Gets the IImagesOperations. |
| | 57 | | /// </summary> |
| 12 | 58 | | public virtual IImagesOperations Images { get; private set; } |
| | 59 | |
|
| | 60 | | /// <summary> |
| | 61 | | /// Initializes a new instance of the ImageSearchClient 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 ImageSearchClient.Dispose(). False: will not dispose p |
| 0 | 68 | | protected ImageSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) |
| | 69 | | { |
| 0 | 70 | | Initialize(); |
| 0 | 71 | | } |
| | 72 | |
|
| | 73 | | /// <summary> |
| | 74 | | /// Initializes a new instance of the ImageSearchClient class. |
| | 75 | | /// </summary> |
| | 76 | | /// <param name='handlers'> |
| | 77 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | 78 | | /// </param> |
| 6 | 79 | | protected ImageSearchClient(params DelegatingHandler[] handlers) : base(handlers) |
| | 80 | | { |
| 6 | 81 | | Initialize(); |
| 6 | 82 | | } |
| | 83 | |
|
| | 84 | | /// <summary> |
| | 85 | | /// Initializes a new instance of the ImageSearchClient 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 ImageSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandl |
| | 94 | | { |
| 0 | 95 | | Initialize(); |
| 0 | 96 | | } |
| | 97 | |
|
| | 98 | | /// <summary> |
| | 99 | | /// Initializes a new instance of the ImageSearchClient 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> |
| 6 | 110 | | public ImageSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handl |
| | 111 | | { |
| 6 | 112 | | if (credentials == null) |
| | 113 | | { |
| 0 | 114 | | throw new System.ArgumentNullException("credentials"); |
| | 115 | | } |
| 6 | 116 | | Credentials = credentials; |
| 6 | 117 | | if (Credentials != null) |
| | 118 | | { |
| 6 | 119 | | Credentials.InitializeServiceClient(this); |
| | 120 | | } |
| 6 | 121 | | } |
| | 122 | |
|
| | 123 | | /// <summary> |
| | 124 | | /// Initializes a new instance of the ImageSearchClient 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 ImageSearchClient.Dispose(). False: will not dispose p |
| | 134 | | /// <exception cref="System.ArgumentNullException"> |
| | 135 | | /// Thrown when a required parameter is null |
| | 136 | | /// </exception> |
| 0 | 137 | | public ImageSearchClient(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 ImageSearchClient 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 ImageSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingH |
| | 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 | | { |
| 6 | 187 | | Images = new ImagesOperations(this); |
| 6 | 188 | | BaseUri = "{Endpoint}/bing/v7.0"; |
| 6 | 189 | | Endpoint = "https://api.cognitive.microsoft.com"; |
| 6 | 190 | | SerializationSettings = new JsonSerializerSettings |
| 6 | 191 | | { |
| 6 | 192 | | Formatting = Newtonsoft.Json.Formatting.Indented, |
| 6 | 193 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| 6 | 194 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| 6 | 195 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| 6 | 196 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| 6 | 197 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| 6 | 198 | | Converters = new List<JsonConverter> |
| 6 | 199 | | { |
| 6 | 200 | | new Iso8601TimeSpanConverter() |
| 6 | 201 | | } |
| 6 | 202 | | }; |
| 6 | 203 | | DeserializationSettings = new JsonSerializerSettings |
| 6 | 204 | | { |
| 6 | 205 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| 6 | 206 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| 6 | 207 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| 6 | 208 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| 6 | 209 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| 6 | 210 | | Converters = new List<JsonConverter> |
| 6 | 211 | | { |
| 6 | 212 | | new Iso8601TimeSpanConverter() |
| 6 | 213 | | } |
| 6 | 214 | | }; |
| 6 | 215 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<PropertiesItem>("_type")); |
| 6 | 216 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<PropertiesItem>("_type")); |
| 6 | 217 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type")); |
| 6 | 218 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<ResponseBase>("_type")); |
| | 219 | | CustomInitialize(); |
| 6 | 220 | | } |
| | 221 | | } |
| | 222 | | } |