| | 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.WebSearch |
| | 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 Web Search API lets you send a search query to Bing and get back |
| | 20 | | /// search results that include links to webpages, images, and more. |
| | 21 | | /// </summary> |
| | 22 | | public partial class WebSearchClient : ServiceClient<WebSearchClient>, IWebSearchClient |
| | 23 | | { |
| | 24 | | /// <summary> |
| | 25 | | /// The base URI of the service. |
| | 26 | | /// </summary> |
| 4 | 27 | | internal string BaseUri {get; set;} |
| | 28 | |
|
| | 29 | | /// <summary> |
| | 30 | | /// Gets or sets json serialization settings. |
| | 31 | | /// </summary> |
| 6 | 32 | | public JsonSerializerSettings SerializationSettings { get; private set; } |
| | 33 | |
|
| | 34 | | /// <summary> |
| | 35 | | /// Gets or sets json deserialization settings. |
| | 36 | | /// </summary> |
| 8 | 37 | | public JsonSerializerSettings DeserializationSettings { get; private set; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Supported Cognitive Services endpoints (protocol and hostname, for example: |
| | 41 | | /// "https://westus.api.cognitive.microsoft.com", |
| | 42 | | /// "https://api.cognitive.microsoft.com"). |
| | 43 | | /// </summary> |
| 6 | 44 | | public string Endpoint { get; set; } |
| | 45 | |
|
| | 46 | | /// <summary> |
| | 47 | | /// Subscription credentials which uniquely identify client subscription. |
| | 48 | | /// </summary> |
| 10 | 49 | | public ServiceClientCredentials Credentials { get; private set; } |
| | 50 | |
|
| | 51 | | /// <summary> |
| | 52 | | /// Gets the IWeb. |
| | 53 | | /// </summary> |
| 4 | 54 | | public virtual IWeb Web { get; private set; } |
| | 55 | |
|
| | 56 | | /// <summary> |
| | 57 | | /// Initializes a new instance of the WebSearchClient class. |
| | 58 | | /// </summary> |
| | 59 | | /// <param name='httpClient'> |
| | 60 | | /// HttpClient to be used |
| | 61 | | /// </param> |
| | 62 | | /// <param name='disposeHttpClient'> |
| | 63 | | /// True: will dispose the provided httpClient on calling WebSearchClient.Dispose(). False: will not dispose pro |
| 0 | 64 | | protected WebSearchClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient) |
| | 65 | | { |
| 0 | 66 | | Initialize(); |
| 0 | 67 | | } |
| | 68 | |
|
| | 69 | | /// <summary> |
| | 70 | | /// Initializes a new instance of the WebSearchClient class. |
| | 71 | | /// </summary> |
| | 72 | | /// <param name='handlers'> |
| | 73 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | 74 | | /// </param> |
| 2 | 75 | | protected WebSearchClient(params DelegatingHandler[] handlers) : base(handlers) |
| | 76 | | { |
| 2 | 77 | | Initialize(); |
| 2 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> |
| | 81 | | /// Initializes a new instance of the WebSearchClient class. |
| | 82 | | /// </summary> |
| | 83 | | /// <param name='rootHandler'> |
| | 84 | | /// Optional. The http client handler used to handle http transport. |
| | 85 | | /// </param> |
| | 86 | | /// <param name='handlers'> |
| | 87 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | 88 | | /// </param> |
| 0 | 89 | | protected WebSearchClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler |
| | 90 | | { |
| 0 | 91 | | Initialize(); |
| 0 | 92 | | } |
| | 93 | |
|
| | 94 | | /// <summary> |
| | 95 | | /// Initializes a new instance of the WebSearchClient class. |
| | 96 | | /// </summary> |
| | 97 | | /// <param name='credentials'> |
| | 98 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | 99 | | /// </param> |
| | 100 | | /// <param name='handlers'> |
| | 101 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | 102 | | /// </param> |
| | 103 | | /// <exception cref="System.ArgumentNullException"> |
| | 104 | | /// Thrown when a required parameter is null |
| | 105 | | /// </exception> |
| 2 | 106 | | public WebSearchClient(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handler |
| | 107 | | { |
| 2 | 108 | | if (credentials == null) |
| | 109 | | { |
| 0 | 110 | | throw new System.ArgumentNullException("credentials"); |
| | 111 | | } |
| 2 | 112 | | Credentials = credentials; |
| 2 | 113 | | if (Credentials != null) |
| | 114 | | { |
| 2 | 115 | | Credentials.InitializeServiceClient(this); |
| | 116 | | } |
| 2 | 117 | | } |
| | 118 | |
|
| | 119 | | /// <summary> |
| | 120 | | /// Initializes a new instance of the WebSearchClient class. |
| | 121 | | /// </summary> |
| | 122 | | /// <param name='credentials'> |
| | 123 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | 124 | | /// </param> |
| | 125 | | /// <param name='httpClient'> |
| | 126 | | /// HttpClient to be used |
| | 127 | | /// </param> |
| | 128 | | /// <param name='disposeHttpClient'> |
| | 129 | | /// True: will dispose the provided httpClient on calling WebSearchClient.Dispose(). False: will not dispose pro |
| | 130 | | /// <exception cref="System.ArgumentNullException"> |
| | 131 | | /// Thrown when a required parameter is null |
| | 132 | | /// </exception> |
| 0 | 133 | | public WebSearchClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : th |
| | 134 | | { |
| 0 | 135 | | if (credentials == null) |
| | 136 | | { |
| 0 | 137 | | throw new System.ArgumentNullException("credentials"); |
| | 138 | | } |
| 0 | 139 | | Credentials = credentials; |
| 0 | 140 | | if (Credentials != null) |
| | 141 | | { |
| 0 | 142 | | Credentials.InitializeServiceClient(this); |
| | 143 | | } |
| 0 | 144 | | } |
| | 145 | |
|
| | 146 | | /// <summary> |
| | 147 | | /// Initializes a new instance of the WebSearchClient class. |
| | 148 | | /// </summary> |
| | 149 | | /// <param name='credentials'> |
| | 150 | | /// Required. Subscription credentials which uniquely identify client subscription. |
| | 151 | | /// </param> |
| | 152 | | /// <param name='rootHandler'> |
| | 153 | | /// Optional. The http client handler used to handle http transport. |
| | 154 | | /// </param> |
| | 155 | | /// <param name='handlers'> |
| | 156 | | /// Optional. The delegating handlers to add to the http client pipeline. |
| | 157 | | /// </param> |
| | 158 | | /// <exception cref="System.ArgumentNullException"> |
| | 159 | | /// Thrown when a required parameter is null |
| | 160 | | /// </exception> |
| 0 | 161 | | public WebSearchClient(ServiceClientCredentials credentials, HttpClientHandler rootHandler, params DelegatingHan |
| | 162 | | { |
| 0 | 163 | | if (credentials == null) |
| | 164 | | { |
| 0 | 165 | | throw new System.ArgumentNullException("credentials"); |
| | 166 | | } |
| 0 | 167 | | Credentials = credentials; |
| 0 | 168 | | if (Credentials != null) |
| | 169 | | { |
| 0 | 170 | | Credentials.InitializeServiceClient(this); |
| | 171 | | } |
| 0 | 172 | | } |
| | 173 | |
|
| | 174 | | /// <summary> |
| | 175 | | /// An optional partial-method to perform custom initialization. |
| | 176 | | ///</summary> |
| | 177 | | partial void CustomInitialize(); |
| | 178 | | /// <summary> |
| | 179 | | /// Initializes client properties. |
| | 180 | | /// </summary> |
| | 181 | | private void Initialize() |
| | 182 | | { |
| 2 | 183 | | Web = new Web(this); |
| 2 | 184 | | BaseUri = "{Endpoint}/bing/v7.0"; |
| 2 | 185 | | Endpoint = "https://api.cognitive.microsoft.com"; |
| 2 | 186 | | SerializationSettings = new JsonSerializerSettings |
| 2 | 187 | | { |
| 2 | 188 | | Formatting = Newtonsoft.Json.Formatting.Indented, |
| 2 | 189 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| 2 | 190 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| 2 | 191 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| 2 | 192 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| 2 | 193 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| 2 | 194 | | Converters = new List<JsonConverter> |
| 2 | 195 | | { |
| 2 | 196 | | new Iso8601TimeSpanConverter() |
| 2 | 197 | | } |
| 2 | 198 | | }; |
| 2 | 199 | | DeserializationSettings = new JsonSerializerSettings |
| 2 | 200 | | { |
| 2 | 201 | | DateFormatHandling = Newtonsoft.Json.DateFormatHandling.IsoDateFormat, |
| 2 | 202 | | DateTimeZoneHandling = Newtonsoft.Json.DateTimeZoneHandling.Utc, |
| 2 | 203 | | NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore, |
| 2 | 204 | | ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize, |
| 2 | 205 | | ContractResolver = new ReadOnlyJsonContractResolver(), |
| 2 | 206 | | Converters = new List<JsonConverter> |
| 2 | 207 | | { |
| 2 | 208 | | new Iso8601TimeSpanConverter() |
| 2 | 209 | | } |
| 2 | 210 | | }; |
| 2 | 211 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<WebWebGrouping>("_type")); |
| 2 | 212 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<WebWebGrouping>("_type")); |
| 2 | 213 | | SerializationSettings.Converters.Add(new PolymorphicSerializeJsonConverter<ResponseBase>("_type")); |
| 2 | 214 | | DeserializationSettings.Converters.Add(new PolymorphicDeserializeJsonConverter<ResponseBase>("_type")); |
| | 215 | | CustomInitialize(); |
| 2 | 216 | | } |
| | 217 | | } |
| | 218 | | } |