| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Text.Json; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | | using Azure.Search.Documents.Indexes.Models; |
| | 16 | |
|
| | 17 | | namespace Azure.Search.Documents |
| | 18 | | { |
| | 19 | | internal partial class DataSourcesRestClient |
| | 20 | | { |
| | 21 | | private string endpoint; |
| | 22 | | private Guid? xMsClientRequestId; |
| | 23 | | private string apiVersion; |
| | 24 | | private ClientDiagnostics _clientDiagnostics; |
| | 25 | | private HttpPipeline _pipeline; |
| | 26 | |
|
| | 27 | | /// <summary> Initializes a new instance of DataSourcesRestClient. </summary> |
| | 28 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 29 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 30 | | /// <param name="endpoint"> The endpoint URL of the search service. </param> |
| | 31 | | /// <param name="xMsClientRequestId"> The tracking ID sent with the request to help with debugging. </param> |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| | 33 | | /// <exception cref="ArgumentNullException"> <paramref name="endpoint"/> or <paramref name="apiVersion"/> is nul |
| 5 | 34 | | public DataSourcesRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, Guid? |
| | 35 | | { |
| 5 | 36 | | if (endpoint == null) |
| | 37 | | { |
| 0 | 38 | | throw new ArgumentNullException(nameof(endpoint)); |
| | 39 | | } |
| 5 | 40 | | if (apiVersion == null) |
| | 41 | | { |
| 0 | 42 | | throw new ArgumentNullException(nameof(apiVersion)); |
| | 43 | | } |
| | 44 | |
|
| 5 | 45 | | this.endpoint = endpoint; |
| 5 | 46 | | this.xMsClientRequestId = xMsClientRequestId; |
| 5 | 47 | | this.apiVersion = apiVersion; |
| 5 | 48 | | _clientDiagnostics = clientDiagnostics; |
| 5 | 49 | | _pipeline = pipeline; |
| 5 | 50 | | } |
| | 51 | |
|
| | 52 | | internal HttpMessage CreateCreateOrUpdateRequest(string dataSourceName, SearchIndexerDataSourceConnection dataSo |
| | 53 | | { |
| 2 | 54 | | var message = _pipeline.CreateMessage(); |
| 2 | 55 | | var request = message.Request; |
| 2 | 56 | | request.Method = RequestMethod.Put; |
| 2 | 57 | | var uri = new RawRequestUriBuilder(); |
| 2 | 58 | | uri.AppendRaw(endpoint, false); |
| 2 | 59 | | uri.AppendPath("/datasources('", false); |
| 2 | 60 | | uri.AppendPath(dataSourceName, true); |
| 2 | 61 | | uri.AppendPath("')", false); |
| 2 | 62 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 63 | | request.Uri = uri; |
| 2 | 64 | | if (xMsClientRequestId != null) |
| | 65 | | { |
| 0 | 66 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 67 | | } |
| 2 | 68 | | if (ifMatch != null) |
| | 69 | | { |
| 2 | 70 | | request.Headers.Add("If-Match", ifMatch); |
| | 71 | | } |
| 2 | 72 | | if (ifNoneMatch != null) |
| | 73 | | { |
| 0 | 74 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 75 | | } |
| 2 | 76 | | request.Headers.Add("Prefer", "return=representation"); |
| 2 | 77 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 78 | | request.Headers.Add("Content-Type", "application/json"); |
| 2 | 79 | | var content = new Utf8JsonRequestContent(); |
| 2 | 80 | | content.JsonWriter.WriteObjectValue(dataSource); |
| 2 | 81 | | request.Content = content; |
| 2 | 82 | | return message; |
| | 83 | | } |
| | 84 | |
|
| | 85 | | /// <summary> Creates a new datasource or updates a datasource if it already exists. </summary> |
| | 86 | | /// <param name="dataSourceName"> The name of the datasource to create or update. </param> |
| | 87 | | /// <param name="dataSource"> The definition of the datasource to create or update. </param> |
| | 88 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 89 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 90 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 91 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> or <paramref name="dataSource"/> |
| | 92 | | public async Task<Response<SearchIndexerDataSourceConnection>> CreateOrUpdateAsync(string dataSourceName, Search |
| | 93 | | { |
| 1 | 94 | | if (dataSourceName == null) |
| | 95 | | { |
| 0 | 96 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 97 | | } |
| 1 | 98 | | if (dataSource == null) |
| | 99 | | { |
| 0 | 100 | | throw new ArgumentNullException(nameof(dataSource)); |
| | 101 | | } |
| | 102 | |
|
| 1 | 103 | | using var message = CreateCreateOrUpdateRequest(dataSourceName, dataSource, ifMatch, ifNoneMatch); |
| 1 | 104 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 105 | | switch (message.Response.Status) |
| | 106 | | { |
| | 107 | | case 200: |
| | 108 | | case 201: |
| | 109 | | { |
| | 110 | | SearchIndexerDataSourceConnection value = default; |
| 1 | 111 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 112 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 1 | 113 | | return Response.FromValue(value, message.Response); |
| | 114 | | } |
| | 115 | | default: |
| 0 | 116 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 117 | | } |
| 1 | 118 | | } |
| | 119 | |
|
| | 120 | | /// <summary> Creates a new datasource or updates a datasource if it already exists. </summary> |
| | 121 | | /// <param name="dataSourceName"> The name of the datasource to create or update. </param> |
| | 122 | | /// <param name="dataSource"> The definition of the datasource to create or update. </param> |
| | 123 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 124 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 125 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 126 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> or <paramref name="dataSource"/> |
| | 127 | | public Response<SearchIndexerDataSourceConnection> CreateOrUpdate(string dataSourceName, SearchIndexerDataSource |
| | 128 | | { |
| 1 | 129 | | if (dataSourceName == null) |
| | 130 | | { |
| 0 | 131 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 132 | | } |
| 1 | 133 | | if (dataSource == null) |
| | 134 | | { |
| 0 | 135 | | throw new ArgumentNullException(nameof(dataSource)); |
| | 136 | | } |
| | 137 | |
|
| 1 | 138 | | using var message = CreateCreateOrUpdateRequest(dataSourceName, dataSource, ifMatch, ifNoneMatch); |
| 1 | 139 | | _pipeline.Send(message, cancellationToken); |
| 1 | 140 | | switch (message.Response.Status) |
| | 141 | | { |
| | 142 | | case 200: |
| | 143 | | case 201: |
| | 144 | | { |
| | 145 | | SearchIndexerDataSourceConnection value = default; |
| 1 | 146 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 147 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 1 | 148 | | return Response.FromValue(value, message.Response); |
| | 149 | | } |
| | 150 | | default: |
| 0 | 151 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 152 | | } |
| 1 | 153 | | } |
| | 154 | |
|
| | 155 | | internal HttpMessage CreateDeleteRequest(string dataSourceName, string ifMatch, string ifNoneMatch) |
| | 156 | | { |
| 3 | 157 | | var message = _pipeline.CreateMessage(); |
| 3 | 158 | | var request = message.Request; |
| 3 | 159 | | request.Method = RequestMethod.Delete; |
| 3 | 160 | | var uri = new RawRequestUriBuilder(); |
| 3 | 161 | | uri.AppendRaw(endpoint, false); |
| 3 | 162 | | uri.AppendPath("/datasources('", false); |
| 3 | 163 | | uri.AppendPath(dataSourceName, true); |
| 3 | 164 | | uri.AppendPath("')", false); |
| 3 | 165 | | uri.AppendQuery("api-version", apiVersion, true); |
| 3 | 166 | | request.Uri = uri; |
| 3 | 167 | | if (xMsClientRequestId != null) |
| | 168 | | { |
| 0 | 169 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 170 | | } |
| 3 | 171 | | if (ifMatch != null) |
| | 172 | | { |
| 2 | 173 | | request.Headers.Add("If-Match", ifMatch); |
| | 174 | | } |
| 3 | 175 | | if (ifNoneMatch != null) |
| | 176 | | { |
| 0 | 177 | | request.Headers.Add("If-None-Match", ifNoneMatch); |
| | 178 | | } |
| 3 | 179 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 3 | 180 | | return message; |
| | 181 | | } |
| | 182 | |
|
| | 183 | | /// <summary> Deletes a datasource. </summary> |
| | 184 | | /// <param name="dataSourceName"> The name of the datasource to delete. </param> |
| | 185 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 186 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 187 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 188 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> is null. </exception> |
| | 189 | | public async Task<Response> DeleteAsync(string dataSourceName, string ifMatch = null, string ifNoneMatch = null, |
| | 190 | | { |
| 2 | 191 | | if (dataSourceName == null) |
| | 192 | | { |
| 0 | 193 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 194 | | } |
| | 195 | |
|
| 2 | 196 | | using var message = CreateDeleteRequest(dataSourceName, ifMatch, ifNoneMatch); |
| 2 | 197 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 2 | 198 | | switch (message.Response.Status) |
| | 199 | | { |
| | 200 | | case 204: |
| | 201 | | case 404: |
| 2 | 202 | | return message.Response; |
| | 203 | | default: |
| 0 | 204 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 205 | | } |
| 2 | 206 | | } |
| | 207 | |
|
| | 208 | | /// <summary> Deletes a datasource. </summary> |
| | 209 | | /// <param name="dataSourceName"> The name of the datasource to delete. </param> |
| | 210 | | /// <param name="ifMatch"> Defines the If-Match condition. The operation will be performed only if the ETag on t |
| | 211 | | /// <param name="ifNoneMatch"> Defines the If-None-Match condition. The operation will be performed only if the |
| | 212 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 213 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> is null. </exception> |
| | 214 | | public Response Delete(string dataSourceName, string ifMatch = null, string ifNoneMatch = null, CancellationToke |
| | 215 | | { |
| 1 | 216 | | if (dataSourceName == null) |
| | 217 | | { |
| 0 | 218 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 219 | | } |
| | 220 | |
|
| 1 | 221 | | using var message = CreateDeleteRequest(dataSourceName, ifMatch, ifNoneMatch); |
| 1 | 222 | | _pipeline.Send(message, cancellationToken); |
| 1 | 223 | | switch (message.Response.Status) |
| | 224 | | { |
| | 225 | | case 204: |
| | 226 | | case 404: |
| 1 | 227 | | return message.Response; |
| | 228 | | default: |
| 0 | 229 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 230 | | } |
| 1 | 231 | | } |
| | 232 | |
|
| | 233 | | internal HttpMessage CreateGetRequest(string dataSourceName) |
| | 234 | | { |
| 2 | 235 | | var message = _pipeline.CreateMessage(); |
| 2 | 236 | | var request = message.Request; |
| 2 | 237 | | request.Method = RequestMethod.Get; |
| 2 | 238 | | var uri = new RawRequestUriBuilder(); |
| 2 | 239 | | uri.AppendRaw(endpoint, false); |
| 2 | 240 | | uri.AppendPath("/datasources('", false); |
| 2 | 241 | | uri.AppendPath(dataSourceName, true); |
| 2 | 242 | | uri.AppendPath("')", false); |
| 2 | 243 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 244 | | request.Uri = uri; |
| 2 | 245 | | if (xMsClientRequestId != null) |
| | 246 | | { |
| 0 | 247 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 248 | | } |
| 2 | 249 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 250 | | return message; |
| | 251 | | } |
| | 252 | |
|
| | 253 | | /// <summary> Retrieves a datasource definition. </summary> |
| | 254 | | /// <param name="dataSourceName"> The name of the datasource to retrieve. </param> |
| | 255 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 256 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> is null. </exception> |
| | 257 | | public async Task<Response<SearchIndexerDataSourceConnection>> GetAsync(string dataSourceName, CancellationToken |
| | 258 | | { |
| 1 | 259 | | if (dataSourceName == null) |
| | 260 | | { |
| 0 | 261 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 262 | | } |
| | 263 | |
|
| 1 | 264 | | using var message = CreateGetRequest(dataSourceName); |
| 1 | 265 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 266 | | switch (message.Response.Status) |
| | 267 | | { |
| | 268 | | case 200: |
| | 269 | | { |
| | 270 | | SearchIndexerDataSourceConnection value = default; |
| 1 | 271 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 272 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 1 | 273 | | return Response.FromValue(value, message.Response); |
| | 274 | | } |
| | 275 | | default: |
| 0 | 276 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 277 | | } |
| 1 | 278 | | } |
| | 279 | |
|
| | 280 | | /// <summary> Retrieves a datasource definition. </summary> |
| | 281 | | /// <param name="dataSourceName"> The name of the datasource to retrieve. </param> |
| | 282 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 283 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSourceName"/> is null. </exception> |
| | 284 | | public Response<SearchIndexerDataSourceConnection> Get(string dataSourceName, CancellationToken cancellationToke |
| | 285 | | { |
| 1 | 286 | | if (dataSourceName == null) |
| | 287 | | { |
| 0 | 288 | | throw new ArgumentNullException(nameof(dataSourceName)); |
| | 289 | | } |
| | 290 | |
|
| 1 | 291 | | using var message = CreateGetRequest(dataSourceName); |
| 1 | 292 | | _pipeline.Send(message, cancellationToken); |
| 1 | 293 | | switch (message.Response.Status) |
| | 294 | | { |
| | 295 | | case 200: |
| | 296 | | { |
| | 297 | | SearchIndexerDataSourceConnection value = default; |
| 1 | 298 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 299 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 1 | 300 | | return Response.FromValue(value, message.Response); |
| | 301 | | } |
| | 302 | | default: |
| 0 | 303 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 304 | | } |
| 1 | 305 | | } |
| | 306 | |
|
| | 307 | | internal HttpMessage CreateListRequest(string select) |
| | 308 | | { |
| 2 | 309 | | var message = _pipeline.CreateMessage(); |
| 2 | 310 | | var request = message.Request; |
| 2 | 311 | | request.Method = RequestMethod.Get; |
| 2 | 312 | | var uri = new RawRequestUriBuilder(); |
| 2 | 313 | | uri.AppendRaw(endpoint, false); |
| 2 | 314 | | uri.AppendPath("/datasources", false); |
| 2 | 315 | | if (select != null) |
| | 316 | | { |
| 2 | 317 | | uri.AppendQuery("$select", select, true); |
| | 318 | | } |
| 2 | 319 | | uri.AppendQuery("api-version", apiVersion, true); |
| 2 | 320 | | request.Uri = uri; |
| 2 | 321 | | if (xMsClientRequestId != null) |
| | 322 | | { |
| 0 | 323 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 324 | | } |
| 2 | 325 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 2 | 326 | | return message; |
| | 327 | | } |
| | 328 | |
|
| | 329 | | /// <summary> Lists all datasources available for a search service. </summary> |
| | 330 | | /// <param name="select"> Selects which top-level properties of the data sources to retrieve. Specified as a com |
| | 331 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 332 | | public async Task<Response<ListDataSourcesResult>> ListAsync(string select = null, CancellationToken cancellatio |
| | 333 | | { |
| 1 | 334 | | using var message = CreateListRequest(select); |
| 1 | 335 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 1 | 336 | | switch (message.Response.Status) |
| | 337 | | { |
| | 338 | | case 200: |
| | 339 | | { |
| | 340 | | ListDataSourcesResult value = default; |
| 1 | 341 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 1 | 342 | | value = ListDataSourcesResult.DeserializeListDataSourcesResult(document.RootElement); |
| 1 | 343 | | return Response.FromValue(value, message.Response); |
| | 344 | | } |
| | 345 | | default: |
| 0 | 346 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 347 | | } |
| 1 | 348 | | } |
| | 349 | |
|
| | 350 | | /// <summary> Lists all datasources available for a search service. </summary> |
| | 351 | | /// <param name="select"> Selects which top-level properties of the data sources to retrieve. Specified as a com |
| | 352 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 353 | | public Response<ListDataSourcesResult> List(string select = null, CancellationToken cancellationToken = default) |
| | 354 | | { |
| 1 | 355 | | using var message = CreateListRequest(select); |
| 1 | 356 | | _pipeline.Send(message, cancellationToken); |
| 1 | 357 | | switch (message.Response.Status) |
| | 358 | | { |
| | 359 | | case 200: |
| | 360 | | { |
| | 361 | | ListDataSourcesResult value = default; |
| 1 | 362 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 1 | 363 | | value = ListDataSourcesResult.DeserializeListDataSourcesResult(document.RootElement); |
| 1 | 364 | | return Response.FromValue(value, message.Response); |
| | 365 | | } |
| | 366 | | default: |
| 0 | 367 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 368 | | } |
| 1 | 369 | | } |
| | 370 | |
|
| | 371 | | internal HttpMessage CreateCreateRequest(SearchIndexerDataSourceConnection dataSource) |
| | 372 | | { |
| 5 | 373 | | var message = _pipeline.CreateMessage(); |
| 5 | 374 | | var request = message.Request; |
| 5 | 375 | | request.Method = RequestMethod.Post; |
| 5 | 376 | | var uri = new RawRequestUriBuilder(); |
| 5 | 377 | | uri.AppendRaw(endpoint, false); |
| 5 | 378 | | uri.AppendPath("/datasources", false); |
| 5 | 379 | | uri.AppendQuery("api-version", apiVersion, true); |
| 5 | 380 | | request.Uri = uri; |
| 5 | 381 | | if (xMsClientRequestId != null) |
| | 382 | | { |
| 0 | 383 | | request.Headers.Add("x-ms-client-request-id", xMsClientRequestId.Value); |
| | 384 | | } |
| 5 | 385 | | request.Headers.Add("Accept", "application/json; odata.metadata=minimal"); |
| 5 | 386 | | request.Headers.Add("Content-Type", "application/json"); |
| 5 | 387 | | var content = new Utf8JsonRequestContent(); |
| 5 | 388 | | content.JsonWriter.WriteObjectValue(dataSource); |
| 5 | 389 | | request.Content = content; |
| 5 | 390 | | return message; |
| | 391 | | } |
| | 392 | |
|
| | 393 | | /// <summary> Creates a new datasource. </summary> |
| | 394 | | /// <param name="dataSource"> The definition of the datasource to create. </param> |
| | 395 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 396 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSource"/> is null. </exception> |
| | 397 | | public async Task<Response<SearchIndexerDataSourceConnection>> CreateAsync(SearchIndexerDataSourceConnection dat |
| | 398 | | { |
| 3 | 399 | | if (dataSource == null) |
| | 400 | | { |
| 0 | 401 | | throw new ArgumentNullException(nameof(dataSource)); |
| | 402 | | } |
| | 403 | |
|
| 3 | 404 | | using var message = CreateCreateRequest(dataSource); |
| 3 | 405 | | await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); |
| 3 | 406 | | switch (message.Response.Status) |
| | 407 | | { |
| | 408 | | case 201: |
| | 409 | | { |
| | 410 | | SearchIndexerDataSourceConnection value = default; |
| 3 | 411 | | using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, canc |
| 3 | 412 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 3 | 413 | | return Response.FromValue(value, message.Response); |
| | 414 | | } |
| | 415 | | default: |
| 0 | 416 | | throw await _clientDiagnostics.CreateRequestFailedExceptionAsync(message.Response).ConfigureAwait(fa |
| | 417 | | } |
| 3 | 418 | | } |
| | 419 | |
|
| | 420 | | /// <summary> Creates a new datasource. </summary> |
| | 421 | | /// <param name="dataSource"> The definition of the datasource to create. </param> |
| | 422 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 423 | | /// <exception cref="ArgumentNullException"> <paramref name="dataSource"/> is null. </exception> |
| | 424 | | public Response<SearchIndexerDataSourceConnection> Create(SearchIndexerDataSourceConnection dataSource, Cancella |
| | 425 | | { |
| 2 | 426 | | if (dataSource == null) |
| | 427 | | { |
| 0 | 428 | | throw new ArgumentNullException(nameof(dataSource)); |
| | 429 | | } |
| | 430 | |
|
| 2 | 431 | | using var message = CreateCreateRequest(dataSource); |
| 2 | 432 | | _pipeline.Send(message, cancellationToken); |
| 2 | 433 | | switch (message.Response.Status) |
| | 434 | | { |
| | 435 | | case 201: |
| | 436 | | { |
| | 437 | | SearchIndexerDataSourceConnection value = default; |
| 2 | 438 | | using var document = JsonDocument.Parse(message.Response.ContentStream); |
| 2 | 439 | | value = SearchIndexerDataSourceConnection.DeserializeSearchIndexerDataSourceConnection(document. |
| 2 | 440 | | return Response.FromValue(value, message.Response); |
| | 441 | | } |
| | 442 | | default: |
| 0 | 443 | | throw _clientDiagnostics.CreateRequestFailedException(message.Response); |
| | 444 | | } |
| 2 | 445 | | } |
| | 446 | | } |
| | 447 | | } |