| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.Threading; |
| | 6 | | using System.Threading.Tasks; |
| | 7 | | using Azure.Core; |
| | 8 | | using Azure.Core.Pipeline; |
| | 9 | | using System.Collections.Generic; |
| | 10 | | using System.Linq; |
| | 11 | | using Azure.Search.Documents.Indexes.Models; |
| | 12 | |
|
| | 13 | | namespace Azure.Search.Documents.Indexes |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// Azure Cognitive Search client that can be used to manage and query |
| | 17 | | /// indexes and documents, as well as manage other resources, on a Search |
| | 18 | | /// Service. |
| | 19 | | /// </summary> |
| | 20 | | public class SearchIndexerClient |
| | 21 | | { |
| | 22 | | private readonly HttpPipeline _pipeline; |
| | 23 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 24 | | private readonly SearchClientOptions.ServiceVersion _version; |
| | 25 | |
|
| | 26 | | private DataSourcesRestClient _dataSourcesClient; |
| | 27 | | private IndexersRestClient _indexersClient; |
| | 28 | | private SkillsetsRestClient _skillsetsClient; |
| | 29 | | private string _serviceName; |
| | 30 | |
|
| | 31 | |
|
| | 32 | | /// <summary> |
| | 33 | | /// Initializes a new instance of the <see cref="SearchIndexerClient"/> class for mocking. |
| | 34 | | /// </summary> |
| 14 | 35 | | protected SearchIndexerClient() { } |
| | 36 | |
|
| | 37 | | /// <summary> |
| | 38 | | /// Initializes a new instance of the <see cref="SearchIndexerClient"/> class. |
| | 39 | | /// </summary> |
| | 40 | | /// <param name="endpoint">Required. The URI endpoint of the Search service. This is likely to be similar to "ht |
| | 41 | | /// <param name="credential"> |
| | 42 | | /// Required. The API key credential used to authenticate requests against the Search service. |
| | 43 | | /// You need to use an admin key to perform any operations on the SearchIndexerClient. |
| | 44 | | /// See <see href="https://docs.microsoft.com/azure/search/search-security-api-keys">Create and manage api-keys |
| | 45 | | /// </param> |
| | 46 | | /// <exception cref="ArgumentNullException">Thrown when the <paramref name="endpoint"/> or <paramref name="crede |
| | 47 | | /// <exception cref="ArgumentException">Thrown when the <paramref name="endpoint"/> is not using HTTPS.</excepti |
| | 48 | | public SearchIndexerClient(Uri endpoint, AzureKeyCredential credential) : |
| 23 | 49 | | this(endpoint, credential, null) |
| | 50 | | { |
| 17 | 51 | | } |
| | 52 | |
|
| | 53 | | /// <summary> |
| | 54 | | /// Initializes a new instance of the <see cref="SearchIndexerClient"/> class. |
| | 55 | | /// </summary> |
| | 56 | | /// <param name="endpoint">Required. The URI endpoint of the Search service. This is likely to be similar to "ht |
| | 57 | | /// <param name="credential"> |
| | 58 | | /// Required. The API key credential used to authenticate requests against the Search service. |
| | 59 | | /// You need to use an admin key to perform any operations on the SearchIndexerClient. |
| | 60 | | /// See <see href="https://docs.microsoft.com/azure/search/search-security-api-keys">Create and manage api-keys |
| | 61 | | /// </param> |
| | 62 | | /// <param name="options">Client configuration options for connecting to Azure Cognitive Search.</param> |
| | 63 | | /// <exception cref="ArgumentNullException">Thrown when the <paramref name="endpoint"/> or <paramref name="crede |
| | 64 | | /// <exception cref="ArgumentException">Thrown when the <paramref name="endpoint"/> is not using HTTPS.</excepti |
| 30 | 65 | | public SearchIndexerClient( |
| 30 | 66 | | Uri endpoint, |
| 30 | 67 | | AzureKeyCredential credential, |
| 30 | 68 | | SearchClientOptions options) |
| | 69 | | { |
| 30 | 70 | | Argument.AssertNotNull(endpoint, nameof(endpoint)); |
| 28 | 71 | | endpoint.AssertHttpsScheme(nameof(endpoint)); |
| 26 | 72 | | Argument.AssertNotNull(credential, nameof(credential)); |
| | 73 | |
|
| 24 | 74 | | options ??= new SearchClientOptions(); |
| 24 | 75 | | Endpoint = endpoint; |
| 24 | 76 | | _clientDiagnostics = new ClientDiagnostics(options); |
| 24 | 77 | | _pipeline = options.Build(credential); |
| 24 | 78 | | _version = options.Version; |
| 24 | 79 | | } |
| | 80 | |
|
| | 81 | | /// <summary> |
| | 82 | | /// Gets the URI endpoint of the Search service. This is likely |
| | 83 | | /// to be similar to "https://{search_service}.search.windows.net". |
| | 84 | | /// </summary> |
| 21 | 85 | | public virtual Uri Endpoint { get; } |
| | 86 | |
|
| | 87 | | /// <summary> |
| | 88 | | /// Gets the name of the Search service. |
| | 89 | | /// </summary> |
| | 90 | | public virtual string ServiceName => |
| 2 | 91 | | _serviceName ??= Endpoint.GetSearchServiceName(); |
| | 92 | |
|
| | 93 | | /// <summary> |
| | 94 | | /// Gets the generated <see cref="DataSourcesRestClient"/> to make requests. |
| | 95 | | /// </summary> |
| 19 | 96 | | private DataSourcesRestClient DataSourcesClient => LazyInitializer.EnsureInitialized(ref _dataSourcesClient, () |
| 19 | 97 | | _clientDiagnostics, |
| 19 | 98 | | _pipeline, |
| 19 | 99 | | Endpoint.ToString(), |
| 19 | 100 | | null, |
| 19 | 101 | | _version.ToVersionString()) |
| 14 | 102 | | ); |
| | 103 | |
|
| | 104 | | /// <summary> |
| | 105 | | /// Gets the generated <see cref="IndexersRestClient"/> to make requests. |
| | 106 | | /// </summary> |
| 28 | 107 | | private IndexersRestClient IndexersClient => LazyInitializer.EnsureInitialized(ref _indexersClient, () => new In |
| 28 | 108 | | _clientDiagnostics, |
| 28 | 109 | | _pipeline, |
| 28 | 110 | | Endpoint.ToString(), |
| 28 | 111 | | null, |
| 28 | 112 | | _version.ToVersionString()) |
| 21 | 113 | | ); |
| | 114 | |
|
| | 115 | | /// <summary> |
| | 116 | | /// Gets the generated <see cref="SkillsetsRestClient"/> to make requests. |
| | 117 | | /// </summary> |
| 21 | 118 | | private SkillsetsRestClient SkillsetsClient => LazyInitializer.EnsureInitialized(ref _skillsetsClient, () => new |
| 21 | 119 | | _clientDiagnostics, |
| 21 | 120 | | _pipeline, |
| 21 | 121 | | Endpoint.ToString(), |
| 21 | 122 | | null, |
| 21 | 123 | | _version.ToVersionString()) |
| 16 | 124 | | ); |
| | 125 | |
|
| | 126 | | #region Data Sources operations |
| | 127 | | /// <summary> |
| | 128 | | /// Creates a new data source connection. |
| | 129 | | /// </summary> |
| | 130 | | /// <param name="dataSourceConnection">Required. The <see cref="SearchIndexerDataSourceConnection"/> to create.< |
| | 131 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 132 | | /// <returns> |
| | 133 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerDataSourceConnection"/> |
| | 134 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 135 | | /// </returns> |
| | 136 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 137 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 138 | | public virtual Response<SearchIndexerDataSourceConnection> CreateDataSourceConnection( |
| | 139 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 140 | | CancellationToken cancellationToken = default) |
| | 141 | | { |
| | 142 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 3 | 143 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 144 | |
|
| 2 | 145 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateD |
| 2 | 146 | | scope.Start(); |
| | 147 | | try |
| | 148 | | { |
| 2 | 149 | | return DataSourcesClient.Create( |
| 2 | 150 | | dataSourceConnection, |
| 2 | 151 | | cancellationToken); |
| | 152 | | } |
| 0 | 153 | | catch (Exception ex) |
| | 154 | | { |
| 0 | 155 | | scope.Failed(ex); |
| 0 | 156 | | throw; |
| | 157 | | } |
| 2 | 158 | | } |
| | 159 | |
|
| | 160 | | /// <summary> |
| | 161 | | /// Creates a new data source connection. |
| | 162 | | /// </summary> |
| | 163 | | /// <param name="dataSourceConnection">Required. The <see cref="SearchIndexerDataSourceConnection"/> to create.< |
| | 164 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 165 | | /// <returns> |
| | 166 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerDataSourceConnection"/> |
| | 167 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 168 | | /// </returns> |
| | 169 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 170 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 171 | | public virtual async Task<Response<SearchIndexerDataSourceConnection>> CreateDataSourceConnectionAsync( |
| | 172 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 173 | | CancellationToken cancellationToken = default) |
| | 174 | | { |
| | 175 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 4 | 176 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 177 | |
|
| 3 | 178 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateD |
| 3 | 179 | | scope.Start(); |
| | 180 | | try |
| | 181 | | { |
| 3 | 182 | | return await DataSourcesClient.CreateAsync( |
| 3 | 183 | | dataSourceConnection, |
| 3 | 184 | | cancellationToken) |
| 3 | 185 | | .ConfigureAwait(false); |
| | 186 | | } |
| 0 | 187 | | catch (Exception ex) |
| | 188 | | { |
| 0 | 189 | | scope.Failed(ex); |
| 0 | 190 | | throw; |
| | 191 | | } |
| 3 | 192 | | } |
| | 193 | |
|
| | 194 | | /// <summary> |
| | 195 | | /// Creates a new data source or updates an existing data source connection. |
| | 196 | | /// </summary> |
| | 197 | | /// <param name="dataSourceConnection">Required. The <see cref="SearchIndexerDataSourceConnection"/> to create o |
| | 198 | | /// <param name="onlyIfUnchanged"> |
| | 199 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerDataSourceConnection.ETa |
| | 200 | | /// otherwise, the current service version will be overwritten. |
| | 201 | | /// </param> |
| | 202 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 203 | | /// <returns> |
| | 204 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerDataSourceConnection"/> |
| | 205 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 206 | | /// </returns> |
| | 207 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 208 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 209 | | public virtual Response<SearchIndexerDataSourceConnection> CreateOrUpdateDataSourceConnection( |
| | 210 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 211 | | bool onlyIfUnchanged = false, |
| | 212 | | CancellationToken cancellationToken = default) |
| | 213 | | { |
| | 214 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 215 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 216 | |
|
| 1 | 217 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 218 | | scope.Start(); |
| | 219 | | try |
| | 220 | | { |
| 1 | 221 | | return DataSourcesClient.CreateOrUpdate( |
| 1 | 222 | | dataSourceConnection?.Name, |
| 1 | 223 | | dataSourceConnection, |
| 1 | 224 | | onlyIfUnchanged ? dataSourceConnection?.ETag?.ToString() : null, |
| 1 | 225 | | null, |
| 1 | 226 | | cancellationToken); |
| | 227 | | } |
| 0 | 228 | | catch (Exception ex) |
| | 229 | | { |
| 0 | 230 | | scope.Failed(ex); |
| 0 | 231 | | throw; |
| | 232 | | } |
| 1 | 233 | | } |
| | 234 | |
|
| | 235 | | /// <summary> |
| | 236 | | /// Creates a new data source or updates an existing data source connection. |
| | 237 | | /// </summary> |
| | 238 | | /// <param name="dataSourceConnection">Required. The <see cref="SearchIndexerDataSourceConnection"/> to create o |
| | 239 | | /// <param name="onlyIfUnchanged"> |
| | 240 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerDataSourceConnection.ETa |
| | 241 | | /// otherwise, the current service version will be overwritten. |
| | 242 | | /// </param> |
| | 243 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 244 | | /// <returns> |
| | 245 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerDataSourceConnection"/> |
| | 246 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 247 | | /// </returns> |
| | 248 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 249 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 250 | | public virtual async Task<Response<SearchIndexerDataSourceConnection>> CreateOrUpdateDataSourceConnectionAsync( |
| | 251 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 252 | | bool onlyIfUnchanged = false, |
| | 253 | | CancellationToken cancellationToken = default) |
| | 254 | | { |
| | 255 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 256 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 257 | |
|
| 1 | 258 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 259 | | scope.Start(); |
| | 260 | | try |
| | 261 | | { |
| 1 | 262 | | return await DataSourcesClient.CreateOrUpdateAsync( |
| 1 | 263 | | dataSourceConnection?.Name, |
| 1 | 264 | | dataSourceConnection, |
| 1 | 265 | | onlyIfUnchanged ? dataSourceConnection?.ETag?.ToString() : null, |
| 1 | 266 | | null, |
| 1 | 267 | | cancellationToken) |
| 1 | 268 | | .ConfigureAwait(false); |
| | 269 | | } |
| 0 | 270 | | catch (Exception ex) |
| | 271 | | { |
| 0 | 272 | | scope.Failed(ex); |
| 0 | 273 | | throw; |
| | 274 | | } |
| 1 | 275 | | } |
| | 276 | |
|
| | 277 | | /// <summary> |
| | 278 | | /// Deletes a data source connection. |
| | 279 | | /// </summary> |
| | 280 | | /// <param name="dataSourceConnectionName">The name of the <see cref="SearchIndexerDataSourceConnection"/> to de |
| | 281 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 282 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 283 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnectionName"/> is null.</ex |
| | 284 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 285 | | public virtual Response DeleteDataSourceConnection( |
| | 286 | | string dataSourceConnectionName, |
| | 287 | | CancellationToken cancellationToken = default) |
| | 288 | | { |
| | 289 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 1 | 290 | | Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName)); |
| | 291 | |
|
| 0 | 292 | | return DeleteDataSourceConnection( |
| 0 | 293 | | dataSourceConnectionName, |
| 0 | 294 | | null, |
| 0 | 295 | | false, |
| 0 | 296 | | cancellationToken); |
| | 297 | | } |
| | 298 | |
|
| | 299 | | /// <summary> |
| | 300 | | /// Deletes a data source connection. |
| | 301 | | /// </summary> |
| | 302 | | /// <param name="dataSourceConnectionName">The name of the <see cref="SearchIndexerDataSourceConnection"/> to de |
| | 303 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 304 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 305 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnectionName"/> is null.</ex |
| | 306 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 307 | | public virtual async Task<Response> DeleteDataSourceConnectionAsync( |
| | 308 | | string dataSourceConnectionName, |
| | 309 | | CancellationToken cancellationToken = default) |
| | 310 | | { |
| | 311 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 312 | | Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName)); |
| | 313 | |
|
| 1 | 314 | | return await DeleteDataSourceConnectionAsync( |
| 1 | 315 | | dataSourceConnectionName, |
| 1 | 316 | | null, |
| 1 | 317 | | false, |
| 1 | 318 | | cancellationToken) |
| 1 | 319 | | .ConfigureAwait(false); |
| 1 | 320 | | } |
| | 321 | |
|
| | 322 | | /// <summary> |
| | 323 | | /// Deletes a data source connection. |
| | 324 | | /// </summary> |
| | 325 | | /// <param name="dataSourceConnection">The <see cref="SearchIndexerDataSourceConnection"/> to delete.</param> |
| | 326 | | /// <param name="onlyIfUnchanged"> |
| | 327 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerDataSourceConnection.ETa |
| | 328 | | /// otherwise, the current service version will be overwritten. |
| | 329 | | /// </param> |
| | 330 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 331 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 332 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 333 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 334 | | public virtual Response DeleteDataSourceConnection( |
| | 335 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 336 | | bool onlyIfUnchanged = false, |
| | 337 | | CancellationToken cancellationToken = default) |
| | 338 | | { |
| | 339 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 340 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 341 | |
|
| 1 | 342 | | return DeleteDataSourceConnection( |
| 1 | 343 | | dataSourceConnection?.Name, |
| 1 | 344 | | dataSourceConnection?.ETag, |
| 1 | 345 | | onlyIfUnchanged, |
| 1 | 346 | | cancellationToken); |
| | 347 | | } |
| | 348 | |
|
| | 349 | | /// <summary> |
| | 350 | | /// Deletes a data source connection. |
| | 351 | | /// </summary> |
| | 352 | | /// <param name="dataSourceConnection">The <see cref="SearchIndexerDataSourceConnection"/> to delete.</param> |
| | 353 | | /// <param name="onlyIfUnchanged"> |
| | 354 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerDataSourceConnection.ETa |
| | 355 | | /// otherwise, the current service version will be overwritten. |
| | 356 | | /// </param> |
| | 357 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 358 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 359 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnection"/> is null.</except |
| | 360 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 361 | | public virtual async Task<Response> DeleteDataSourceConnectionAsync( |
| | 362 | | SearchIndexerDataSourceConnection dataSourceConnection, |
| | 363 | | bool onlyIfUnchanged = false, |
| | 364 | | CancellationToken cancellationToken = default) |
| | 365 | | { |
| | 366 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 367 | | Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection)); |
| | 368 | |
|
| 1 | 369 | | return await DeleteDataSourceConnectionAsync( |
| 1 | 370 | | dataSourceConnection?.Name, |
| 1 | 371 | | dataSourceConnection?.ETag, |
| 1 | 372 | | onlyIfUnchanged, |
| 1 | 373 | | cancellationToken) |
| 1 | 374 | | .ConfigureAwait(false); |
| 1 | 375 | | } |
| | 376 | |
|
| | 377 | | private Response DeleteDataSourceConnection( |
| | 378 | | string dataSourceConnectionName, |
| | 379 | | ETag? etag, |
| | 380 | | bool onlyIfUnchanged, |
| | 381 | | CancellationToken cancellationToken) |
| | 382 | | { |
| 1 | 383 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteD |
| 1 | 384 | | scope.Start(); |
| | 385 | | try |
| | 386 | | { |
| 1 | 387 | | return DataSourcesClient.Delete( |
| 1 | 388 | | dataSourceConnectionName, |
| 1 | 389 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 1 | 390 | | null, |
| 1 | 391 | | cancellationToken); |
| | 392 | | } |
| 0 | 393 | | catch (Exception ex) |
| | 394 | | { |
| 0 | 395 | | scope.Failed(ex); |
| 0 | 396 | | throw; |
| | 397 | | } |
| 1 | 398 | | } |
| | 399 | |
|
| | 400 | | private async Task<Response> DeleteDataSourceConnectionAsync( |
| | 401 | | string dataSourceConnectionName, |
| | 402 | | ETag? etag, |
| | 403 | | bool onlyIfUnchanged, |
| | 404 | | CancellationToken cancellationToken) |
| | 405 | | { |
| 2 | 406 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteD |
| 2 | 407 | | scope.Start(); |
| | 408 | | try |
| | 409 | | { |
| 2 | 410 | | return await DataSourcesClient.DeleteAsync( |
| 2 | 411 | | dataSourceConnectionName, |
| 2 | 412 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 2 | 413 | | null, |
| 2 | 414 | | cancellationToken) |
| 2 | 415 | | .ConfigureAwait(false); |
| | 416 | | } |
| 0 | 417 | | catch (Exception ex) |
| | 418 | | { |
| 0 | 419 | | scope.Failed(ex); |
| 0 | 420 | | throw; |
| | 421 | | } |
| 2 | 422 | | } |
| | 423 | |
|
| | 424 | | /// <summary> |
| | 425 | | /// Gets a specific <see cref="SearchIndexerDataSourceConnection"/>. |
| | 426 | | /// </summary> |
| | 427 | | /// <param name="dataSourceConnectionName">Required. The name of the <see cref="SearchIndexerDataSourceConnectio |
| | 428 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 429 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerData |
| | 430 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnectionName"/> is null.</ex |
| | 431 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 432 | | public virtual Response<SearchIndexerDataSourceConnection> GetDataSourceConnection( |
| | 433 | | string dataSourceConnectionName, |
| | 434 | | CancellationToken cancellationToken = default) |
| | 435 | | { |
| | 436 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 437 | | Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName)); |
| | 438 | |
|
| 1 | 439 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 1 | 440 | | scope.Start(); |
| | 441 | | try |
| | 442 | | { |
| 1 | 443 | | return DataSourcesClient.Get( |
| 1 | 444 | | dataSourceConnectionName, |
| 1 | 445 | | cancellationToken); |
| | 446 | | } |
| 0 | 447 | | catch (Exception ex) |
| | 448 | | { |
| 0 | 449 | | scope.Failed(ex); |
| 0 | 450 | | throw; |
| | 451 | | } |
| 1 | 452 | | } |
| | 453 | |
|
| | 454 | | /// <summary> |
| | 455 | | /// Gets a specific <see cref="SearchIndexerDataSourceConnection"/>. |
| | 456 | | /// </summary> |
| | 457 | | /// <param name="dataSourceConnectionName">Required. The name of the <see cref="SearchIndexerDataSourceConnectio |
| | 458 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 459 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerData |
| | 460 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="dataSourceConnectionName"/> is null.</ex |
| | 461 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 462 | | public virtual async Task<Response<SearchIndexerDataSourceConnection>> GetDataSourceConnectionAsync( |
| | 463 | | string dataSourceConnectionName, |
| | 464 | | CancellationToken cancellationToken = default) |
| | 465 | | { |
| | 466 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 467 | | Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName)); |
| | 468 | |
|
| 1 | 469 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 1 | 470 | | scope.Start(); |
| | 471 | | try |
| | 472 | | { |
| 1 | 473 | | return await DataSourcesClient.GetAsync( |
| 1 | 474 | | dataSourceConnectionName, |
| 1 | 475 | | cancellationToken) |
| 1 | 476 | | .ConfigureAwait(false); |
| | 477 | | } |
| 0 | 478 | | catch (Exception ex) |
| | 479 | | { |
| 0 | 480 | | scope.Failed(ex); |
| 0 | 481 | | throw; |
| | 482 | | } |
| 1 | 483 | | } |
| | 484 | |
|
| | 485 | | /// <summary> |
| | 486 | | /// Gets a list of all data source connections. |
| | 487 | | /// </summary> |
| | 488 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 489 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerDataSour |
| | 490 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 491 | | public virtual Response<IReadOnlyList<SearchIndexerDataSourceConnection>> GetDataSourceConnections( |
| | 492 | | CancellationToken cancellationToken = default) |
| | 493 | | { |
| 0 | 494 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 0 | 495 | | scope.Start(); |
| | 496 | | try |
| | 497 | | { |
| 0 | 498 | | Response<ListDataSourcesResult> result = DataSourcesClient.List( |
| 0 | 499 | | Constants.All, |
| 0 | 500 | | cancellationToken); |
| | 501 | |
|
| 0 | 502 | | return Response.FromValue(result.Value.DataSources, result.GetRawResponse()); |
| | 503 | | } |
| 0 | 504 | | catch (Exception ex) |
| | 505 | | { |
| 0 | 506 | | scope.Failed(ex); |
| 0 | 507 | | throw; |
| | 508 | | } |
| 0 | 509 | | } |
| | 510 | |
|
| | 511 | | /// <summary> |
| | 512 | | /// Gets a list of all data source connections. |
| | 513 | | /// </summary> |
| | 514 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 515 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerDataSour |
| | 516 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 517 | | public virtual async Task<Response<IReadOnlyList<SearchIndexerDataSourceConnection>>> GetDataSourceConnectionsAs |
| | 518 | | CancellationToken cancellationToken = default) |
| | 519 | | { |
| 0 | 520 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 0 | 521 | | scope.Start(); |
| | 522 | | try |
| | 523 | | { |
| 0 | 524 | | Response<ListDataSourcesResult> result = await DataSourcesClient.ListAsync( |
| 0 | 525 | | Constants.All, |
| 0 | 526 | | cancellationToken) |
| 0 | 527 | | .ConfigureAwait(false); |
| | 528 | |
|
| 0 | 529 | | return Response.FromValue(result.Value.DataSources, result.GetRawResponse()); |
| | 530 | | } |
| 0 | 531 | | catch (Exception ex) |
| | 532 | | { |
| 0 | 533 | | scope.Failed(ex); |
| 0 | 534 | | throw; |
| | 535 | | } |
| 0 | 536 | | } |
| | 537 | |
|
| | 538 | | /// <summary> |
| | 539 | | /// Gets a list of all data source connection names. |
| | 540 | | /// </summary> |
| | 541 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 542 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerDataSour |
| | 543 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 544 | | public virtual Response<IReadOnlyList<string>> GetDataSourceConnectionNames( |
| | 545 | | CancellationToken cancellationToken = default) |
| | 546 | | { |
| 1 | 547 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 1 | 548 | | scope.Start(); |
| | 549 | | try |
| | 550 | | { |
| 1 | 551 | | Response<ListDataSourcesResult> result = DataSourcesClient.List( |
| 1 | 552 | | Constants.NameKey, |
| 1 | 553 | | cancellationToken); |
| | 554 | |
|
| 2 | 555 | | IReadOnlyList<string> names = result.Value.DataSources.Select(value => value.Name).ToArray(); |
| 1 | 556 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 557 | | } |
| 0 | 558 | | catch (Exception ex) |
| | 559 | | { |
| 0 | 560 | | scope.Failed(ex); |
| 0 | 561 | | throw; |
| | 562 | | } |
| 1 | 563 | | } |
| | 564 | |
|
| | 565 | | /// <summary> |
| | 566 | | /// Gets a list of all data source connection names. |
| | 567 | | /// </summary> |
| | 568 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 569 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerDataSour |
| | 570 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 571 | | public virtual async Task<Response<IReadOnlyList<string>>> GetDataSourceConnectionNamesAsync( |
| | 572 | | CancellationToken cancellationToken = default) |
| | 573 | | { |
| 1 | 574 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData |
| 1 | 575 | | scope.Start(); |
| | 576 | | try |
| | 577 | | { |
| 1 | 578 | | Response<ListDataSourcesResult> result = await DataSourcesClient.ListAsync( |
| 1 | 579 | | Constants.NameKey, |
| 1 | 580 | | cancellationToken) |
| 1 | 581 | | .ConfigureAwait(false); |
| | 582 | |
|
| 3 | 583 | | IReadOnlyList<string> names = result.Value.DataSources.Select(value => value.Name).ToArray(); |
| 1 | 584 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 585 | | } |
| 0 | 586 | | catch (Exception ex) |
| | 587 | | { |
| 0 | 588 | | scope.Failed(ex); |
| 0 | 589 | | throw; |
| | 590 | | } |
| 1 | 591 | | } |
| | 592 | | #endregion |
| | 593 | |
|
| | 594 | | #region Indexer operations |
| | 595 | | /// <summary> |
| | 596 | | /// Creates a new indexer. |
| | 597 | | /// </summary> |
| | 598 | | /// <param name="indexer">Required. The <see cref="SearchIndex"/> to create.</param> |
| | 599 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 600 | | /// <returns> |
| | 601 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexer"/> created. |
| | 602 | | /// This may differ slightly from what was passed into the service. |
| | 603 | | /// </returns> |
| | 604 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 605 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 606 | | public virtual Response<SearchIndexer> CreateIndexer( |
| | 607 | | SearchIndexer indexer, |
| | 608 | | CancellationToken cancellationToken = default) |
| | 609 | | { |
| 2 | 610 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateI |
| 2 | 611 | | scope.Start(); |
| | 612 | | try |
| | 613 | | { |
| 2 | 614 | | return IndexersClient.Create( |
| 2 | 615 | | indexer, |
| 2 | 616 | | cancellationToken); |
| | 617 | | } |
| 1 | 618 | | catch (Exception ex) |
| | 619 | | { |
| 1 | 620 | | scope.Failed(ex); |
| 1 | 621 | | throw; |
| | 622 | | } |
| 1 | 623 | | } |
| | 624 | |
|
| | 625 | | /// <summary> |
| | 626 | | /// Creates a new indexer. |
| | 627 | | /// </summary> |
| | 628 | | /// <param name="indexer">Required. The <see cref="SearchIndexer"/> to create.</param> |
| | 629 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 630 | | /// <returns> |
| | 631 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexer"/> created. |
| | 632 | | /// This may differ slightly from what was passed into the service. |
| | 633 | | /// </returns> |
| | 634 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 635 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 636 | | public virtual async Task<Response<SearchIndexer>> CreateIndexerAsync( |
| | 637 | | SearchIndexer indexer, |
| | 638 | | CancellationToken cancellationToken = default) |
| | 639 | | { |
| 3 | 640 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateI |
| 3 | 641 | | scope.Start(); |
| | 642 | | try |
| | 643 | | { |
| 3 | 644 | | return await IndexersClient.CreateAsync( |
| 3 | 645 | | indexer, |
| 3 | 646 | | cancellationToken) |
| 3 | 647 | | .ConfigureAwait(false); |
| | 648 | | } |
| 1 | 649 | | catch (Exception ex) |
| | 650 | | { |
| 1 | 651 | | scope.Failed(ex); |
| 1 | 652 | | throw; |
| | 653 | | } |
| 2 | 654 | | } |
| | 655 | |
|
| | 656 | | /// <summary> |
| | 657 | | /// Creates a new indexer or updates an existing indexer. |
| | 658 | | /// </summary> |
| | 659 | | /// <param name="indexer">Required. The <see cref="SearchIndexer"/> to create or update.</param> |
| | 660 | | /// <param name="onlyIfUnchanged"> |
| | 661 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexer.ETag"/> does not match |
| | 662 | | /// otherwise, the current service version will be overwritten. |
| | 663 | | /// </param> |
| | 664 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 665 | | /// <returns> |
| | 666 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexer"/> created. |
| | 667 | | /// This may differ slightly from what was passed into the service. |
| | 668 | | /// </returns> |
| | 669 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 670 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 671 | | public virtual Response<SearchIndexer> CreateOrUpdateIndexer( |
| | 672 | | SearchIndexer indexer, |
| | 673 | | bool onlyIfUnchanged = false, |
| | 674 | | CancellationToken cancellationToken = default) |
| | 675 | | { |
| | 676 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 677 | | Argument.AssertNotNull(indexer, nameof(indexer)); |
| | 678 | |
|
| 1 | 679 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 680 | | scope.Start(); |
| | 681 | | try |
| | 682 | | { |
| 1 | 683 | | return IndexersClient.CreateOrUpdate( |
| 1 | 684 | | indexer?.Name, |
| 1 | 685 | | indexer, |
| 1 | 686 | | onlyIfUnchanged ? indexer?.ETag?.ToString() : null, |
| 1 | 687 | | null, |
| 1 | 688 | | cancellationToken); |
| | 689 | | } |
| 0 | 690 | | catch (Exception ex) |
| | 691 | | { |
| 0 | 692 | | scope.Failed(ex); |
| 0 | 693 | | throw; |
| | 694 | | } |
| 1 | 695 | | } |
| | 696 | |
|
| | 697 | | /// <summary> |
| | 698 | | /// Creates a new indexer or updates an existing indexer. |
| | 699 | | /// </summary> |
| | 700 | | /// <param name="indexer">Required. The <see cref="SearchIndexer"/> to create or update.</param> |
| | 701 | | /// <param name="onlyIfUnchanged"> |
| | 702 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexer.ETag"/> does not match |
| | 703 | | /// otherwise, the current service version will be overwritten. |
| | 704 | | /// </param> |
| | 705 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 706 | | /// <returns> |
| | 707 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexer"/> created. |
| | 708 | | /// This may differ slightly from what was passed into the service. |
| | 709 | | /// </returns> |
| | 710 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 711 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 712 | | public virtual async Task<Response<SearchIndexer>> CreateOrUpdateIndexerAsync( |
| | 713 | | SearchIndexer indexer, |
| | 714 | | bool onlyIfUnchanged = false, |
| | 715 | | CancellationToken cancellationToken = default) |
| | 716 | | { |
| | 717 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 718 | | Argument.AssertNotNull(indexer, nameof(indexer)); |
| | 719 | |
|
| 1 | 720 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 721 | | scope.Start(); |
| | 722 | | try |
| | 723 | | { |
| 1 | 724 | | return await IndexersClient.CreateOrUpdateAsync( |
| 1 | 725 | | indexer?.Name, |
| 1 | 726 | | indexer, |
| 1 | 727 | | onlyIfUnchanged ? indexer?.ETag?.ToString() : null, |
| 1 | 728 | | null, |
| 1 | 729 | | cancellationToken) |
| 1 | 730 | | .ConfigureAwait(false); |
| | 731 | | } |
| 0 | 732 | | catch (Exception ex) |
| | 733 | | { |
| 0 | 734 | | scope.Failed(ex); |
| 0 | 735 | | throw; |
| | 736 | | } |
| 1 | 737 | | } |
| | 738 | |
|
| | 739 | | /// <summary> |
| | 740 | | /// Deletes an indexer. |
| | 741 | | /// </summary> |
| | 742 | | /// <param name="indexerName">The name of the <see cref="SearchIndexer"/> to delete.</param> |
| | 743 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 744 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 745 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 746 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 747 | | public virtual Response DeleteIndexer( |
| | 748 | | string indexerName, |
| | 749 | | CancellationToken cancellationToken = default) |
| | 750 | | { |
| | 751 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 1 | 752 | | Argument.AssertNotNull(indexerName, nameof(indexerName)); |
| | 753 | |
|
| 0 | 754 | | return DeleteIndexer( |
| 0 | 755 | | indexerName, |
| 0 | 756 | | null, |
| 0 | 757 | | false, |
| 0 | 758 | | cancellationToken); |
| | 759 | | } |
| | 760 | |
|
| | 761 | | /// <summary> |
| | 762 | | /// Deletes an indexer. |
| | 763 | | /// </summary> |
| | 764 | | /// <param name="indexerName">The name of the <see cref="SearchIndexer"/> to delete.</param> |
| | 765 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 766 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 767 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 768 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 769 | | public virtual async Task<Response> DeleteIndexerAsync( |
| | 770 | | string indexerName, |
| | 771 | | CancellationToken cancellationToken = default) |
| | 772 | | { |
| | 773 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 774 | | Argument.AssertNotNull(indexerName, nameof(indexerName)); |
| | 775 | |
|
| 1 | 776 | | return await DeleteIndexerAsync( |
| 1 | 777 | | indexerName, |
| 1 | 778 | | null, |
| 1 | 779 | | false, |
| 1 | 780 | | cancellationToken) |
| 1 | 781 | | .ConfigureAwait(false); |
| 1 | 782 | | } |
| | 783 | |
|
| | 784 | | /// <summary> |
| | 785 | | /// Deletes an indexer. |
| | 786 | | /// </summary> |
| | 787 | | /// <param name="indexer">The <see cref="SearchIndexer"/> to delete.</param> |
| | 788 | | /// <param name="onlyIfUnchanged"> |
| | 789 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexer.ETag"/> does not match |
| | 790 | | /// otherwise, the current service version will be overwritten. |
| | 791 | | /// </param> |
| | 792 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 793 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 794 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 795 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 796 | | public virtual Response DeleteIndexer( |
| | 797 | | SearchIndexer indexer, |
| | 798 | | bool onlyIfUnchanged = false, |
| | 799 | | CancellationToken cancellationToken = default) |
| | 800 | | { |
| | 801 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 1 | 802 | | Argument.AssertNotNull(indexer, nameof(indexer)); |
| | 803 | |
|
| 0 | 804 | | return DeleteIndexer( |
| 0 | 805 | | indexer?.Name, |
| 0 | 806 | | indexer?.ETag, |
| 0 | 807 | | onlyIfUnchanged, |
| 0 | 808 | | cancellationToken); |
| | 809 | | } |
| | 810 | |
|
| | 811 | | /// <summary> |
| | 812 | | /// Deletes an indexer. |
| | 813 | | /// </summary> |
| | 814 | | /// <param name="indexer">The <see cref="SearchIndexer"/> to delete.</param> |
| | 815 | | /// <param name="onlyIfUnchanged"> |
| | 816 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexer.ETag"/> does not match |
| | 817 | | /// otherwise, the current service version will be overwritten. |
| | 818 | | /// </param> |
| | 819 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 820 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 821 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexer"/> is null.</exception> |
| | 822 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 823 | | public virtual async Task<Response> DeleteIndexerAsync( |
| | 824 | | SearchIndexer indexer, |
| | 825 | | bool onlyIfUnchanged = false, |
| | 826 | | CancellationToken cancellationToken = default) |
| | 827 | | { |
| | 828 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 1 | 829 | | Argument.AssertNotNull(indexer, nameof(indexer)); |
| | 830 | |
|
| 0 | 831 | | return await DeleteIndexerAsync( |
| 0 | 832 | | indexer?.Name, |
| 0 | 833 | | indexer?.ETag, |
| 0 | 834 | | onlyIfUnchanged, |
| 0 | 835 | | cancellationToken) |
| 0 | 836 | | .ConfigureAwait(false); |
| 0 | 837 | | } |
| | 838 | |
|
| | 839 | | private Response DeleteIndexer( |
| | 840 | | string indexerName, |
| | 841 | | ETag? etag, |
| | 842 | | bool onlyIfUnchanged, |
| | 843 | | CancellationToken cancellationToken) |
| | 844 | | { |
| 0 | 845 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteI |
| 0 | 846 | | scope.Start(); |
| | 847 | | try |
| | 848 | | { |
| 0 | 849 | | return IndexersClient.Delete( |
| 0 | 850 | | indexerName, |
| 0 | 851 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 0 | 852 | | null, |
| 0 | 853 | | cancellationToken); |
| | 854 | | } |
| 0 | 855 | | catch (Exception ex) |
| | 856 | | { |
| 0 | 857 | | scope.Failed(ex); |
| 0 | 858 | | throw; |
| | 859 | | } |
| 0 | 860 | | } |
| | 861 | |
|
| | 862 | | private async Task<Response> DeleteIndexerAsync( |
| | 863 | | string indexerName, |
| | 864 | | ETag? etag, |
| | 865 | | bool onlyIfUnchanged, |
| | 866 | | CancellationToken cancellationToken) |
| | 867 | | { |
| 1 | 868 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteI |
| 1 | 869 | | scope.Start(); |
| | 870 | | try |
| | 871 | | { |
| 1 | 872 | | return await IndexersClient.DeleteAsync( |
| 1 | 873 | | indexerName, |
| 1 | 874 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 1 | 875 | | null, |
| 1 | 876 | | cancellationToken) |
| 1 | 877 | | .ConfigureAwait(false); |
| | 878 | | } |
| 0 | 879 | | catch (Exception ex) |
| | 880 | | { |
| 0 | 881 | | scope.Failed(ex); |
| 0 | 882 | | throw; |
| | 883 | | } |
| 1 | 884 | | } |
| | 885 | |
|
| | 886 | | /// <summary> |
| | 887 | | /// Gets a specific <see cref="SearchIndexer"/>. |
| | 888 | | /// </summary> |
| | 889 | | /// <param name="indexerName">Required. The name of the <see cref="SearchIndexer"/> to get.</param> |
| | 890 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 891 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexer"/>. |
| | 892 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 893 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 894 | | public virtual Response<SearchIndexer> GetIndexer( |
| | 895 | | string indexerName, |
| | 896 | | CancellationToken cancellationToken = default) |
| | 897 | | { |
| 1 | 898 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 1 | 899 | | scope.Start(); |
| | 900 | | try |
| | 901 | | { |
| 1 | 902 | | return IndexersClient.Get( |
| 1 | 903 | | indexerName, |
| 1 | 904 | | cancellationToken); |
| | 905 | | } |
| 1 | 906 | | catch (Exception ex) |
| | 907 | | { |
| 1 | 908 | | scope.Failed(ex); |
| 1 | 909 | | throw; |
| | 910 | | } |
| 0 | 911 | | } |
| | 912 | |
|
| | 913 | | /// <summary> |
| | 914 | | /// Gets a specific <see cref="SearchIndexer"/>. |
| | 915 | | /// </summary> |
| | 916 | | /// <param name="indexerName">Required. The name of the <see cref="SearchIndexer"/> to get.</param> |
| | 917 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 918 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexer"/>. |
| | 919 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 920 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 921 | | public virtual async Task<Response<SearchIndexer>> GetIndexerAsync( |
| | 922 | | string indexerName, |
| | 923 | | CancellationToken cancellationToken = default) |
| | 924 | | { |
| 1 | 925 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 1 | 926 | | scope.Start(); |
| | 927 | | try |
| | 928 | | { |
| 1 | 929 | | return await IndexersClient.GetAsync( |
| 1 | 930 | | indexerName, |
| 1 | 931 | | cancellationToken) |
| 1 | 932 | | .ConfigureAwait(false); |
| | 933 | | } |
| 1 | 934 | | catch (Exception ex) |
| | 935 | | { |
| 1 | 936 | | scope.Failed(ex); |
| 1 | 937 | | throw; |
| | 938 | | } |
| 0 | 939 | | } |
| | 940 | |
|
| | 941 | | /// <summary> |
| | 942 | | /// Gets a list of all indexers. |
| | 943 | | /// </summary> |
| | 944 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 945 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexer"/>.</re |
| | 946 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 947 | | public virtual Response<IReadOnlyList<SearchIndexer>> GetIndexers( |
| | 948 | | CancellationToken cancellationToken = default) |
| | 949 | | { |
| 0 | 950 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 0 | 951 | | scope.Start(); |
| | 952 | | try |
| | 953 | | { |
| 0 | 954 | | Response<ListIndexersResult> result = IndexersClient.List( |
| 0 | 955 | | Constants.All, |
| 0 | 956 | | cancellationToken); |
| | 957 | |
|
| 0 | 958 | | return Response.FromValue(result.Value.Indexers, result.GetRawResponse()); |
| | 959 | | } |
| 0 | 960 | | catch (Exception ex) |
| | 961 | | { |
| 0 | 962 | | scope.Failed(ex); |
| 0 | 963 | | throw; |
| | 964 | | } |
| 0 | 965 | | } |
| | 966 | |
|
| | 967 | | /// <summary> |
| | 968 | | /// Gets a list of all indexers. |
| | 969 | | /// </summary> |
| | 970 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 971 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexer"/>.</re |
| | 972 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 973 | | public virtual async Task<Response<IReadOnlyList<SearchIndexer>>> GetIndexersAsync( |
| | 974 | | CancellationToken cancellationToken = default) |
| | 975 | | { |
| 0 | 976 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 0 | 977 | | scope.Start(); |
| | 978 | | try |
| | 979 | | { |
| 0 | 980 | | Response<ListIndexersResult> result = await IndexersClient.ListAsync( |
| 0 | 981 | | Constants.All, |
| 0 | 982 | | cancellationToken) |
| 0 | 983 | | .ConfigureAwait(false); |
| | 984 | |
|
| 0 | 985 | | return Response.FromValue(result.Value.Indexers, result.GetRawResponse()); |
| | 986 | | } |
| 0 | 987 | | catch (Exception ex) |
| | 988 | | { |
| 0 | 989 | | scope.Failed(ex); |
| 0 | 990 | | throw; |
| | 991 | | } |
| 0 | 992 | | } |
| | 993 | |
|
| | 994 | | /// <summary> |
| | 995 | | /// Gets a list of all indexer names. |
| | 996 | | /// </summary> |
| | 997 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 998 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexer"/> name |
| | 999 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1000 | | public virtual Response<IReadOnlyList<string>> GetIndexerNames( |
| | 1001 | | CancellationToken cancellationToken = default) |
| | 1002 | | { |
| 0 | 1003 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 0 | 1004 | | scope.Start(); |
| | 1005 | | try |
| | 1006 | | { |
| 0 | 1007 | | Response<ListIndexersResult> result = IndexersClient.List( |
| 0 | 1008 | | Constants.NameKey, |
| 0 | 1009 | | cancellationToken); |
| | 1010 | |
|
| 0 | 1011 | | IReadOnlyList<string> names = result.Value.Indexers.Select(value => value.Name).ToArray(); |
| 0 | 1012 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 1013 | | } |
| 0 | 1014 | | catch (Exception ex) |
| | 1015 | | { |
| 0 | 1016 | | scope.Failed(ex); |
| 0 | 1017 | | throw; |
| | 1018 | | } |
| 0 | 1019 | | } |
| | 1020 | |
|
| | 1021 | | /// <summary> |
| | 1022 | | /// Gets a list of all indexer names. |
| | 1023 | | /// </summary> |
| | 1024 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1025 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexer"/> name |
| | 1026 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1027 | | public virtual async Task<Response<IReadOnlyList<string>>> GetIndexerNamesAsync( |
| | 1028 | | CancellationToken cancellationToken = default) |
| | 1029 | | { |
| 0 | 1030 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 0 | 1031 | | scope.Start(); |
| | 1032 | | try |
| | 1033 | | { |
| 0 | 1034 | | Response<ListIndexersResult> result = await IndexersClient.ListAsync( |
| 0 | 1035 | | Constants.NameKey, |
| 0 | 1036 | | cancellationToken) |
| 0 | 1037 | | .ConfigureAwait(false); |
| | 1038 | |
|
| 0 | 1039 | | IReadOnlyList<string> names = result.Value.Indexers.Select(value => value.Name).ToArray(); |
| 0 | 1040 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 1041 | | } |
| 0 | 1042 | | catch (Exception ex) |
| | 1043 | | { |
| 0 | 1044 | | scope.Failed(ex); |
| 0 | 1045 | | throw; |
| | 1046 | | } |
| 0 | 1047 | | } |
| | 1048 | |
|
| | 1049 | | /// <summary> |
| | 1050 | | /// Gets the current status and execution history of an indexer. |
| | 1051 | | /// </summary> |
| | 1052 | | /// <param name="indexerName">Required. The name of the indexer for which to retrieve status.</param> |
| | 1053 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1054 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerStat |
| | 1055 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1056 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1057 | | public virtual Response<SearchIndexerStatus> GetIndexerStatus( |
| | 1058 | | string indexerName, |
| | 1059 | | CancellationToken cancellationToken = default) |
| | 1060 | | { |
| 2 | 1061 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 2 | 1062 | | scope.Start(); |
| | 1063 | | try |
| | 1064 | | { |
| 2 | 1065 | | return IndexersClient.GetStatus( |
| 2 | 1066 | | indexerName, |
| 2 | 1067 | | cancellationToken); |
| | 1068 | | } |
| 0 | 1069 | | catch (Exception ex) |
| | 1070 | | { |
| 0 | 1071 | | scope.Failed(ex); |
| 0 | 1072 | | throw; |
| | 1073 | | } |
| 2 | 1074 | | } |
| | 1075 | |
|
| | 1076 | | /// <summary> |
| | 1077 | | /// Gets the current status and execution history of an indexer. |
| | 1078 | | /// </summary> |
| | 1079 | | /// <param name="indexerName">Required. The name of the indexer for which to retrieve status.</param> |
| | 1080 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1081 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerStat |
| | 1082 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1083 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1084 | | public virtual async Task<Response<SearchIndexerStatus>> GetIndexerStatusAsync( |
| | 1085 | | string indexerName, |
| | 1086 | | CancellationToken cancellationToken = default) |
| | 1087 | | { |
| 3 | 1088 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde |
| 3 | 1089 | | scope.Start(); |
| | 1090 | | try |
| | 1091 | | { |
| 3 | 1092 | | return await IndexersClient.GetStatusAsync( |
| 3 | 1093 | | indexerName, |
| 3 | 1094 | | cancellationToken) |
| 3 | 1095 | | .ConfigureAwait(false); |
| | 1096 | | } |
| 0 | 1097 | | catch (Exception ex) |
| | 1098 | | { |
| 0 | 1099 | | scope.Failed(ex); |
| 0 | 1100 | | throw; |
| | 1101 | | } |
| 3 | 1102 | | } |
| | 1103 | |
|
| | 1104 | | /// <summary> |
| | 1105 | | /// Resets the change tracking state associated with an indexer. |
| | 1106 | | /// </summary> |
| | 1107 | | /// <param name="indexerName">Required. The name of the indexer to reset.</param> |
| | 1108 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1109 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1110 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1111 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1112 | | public virtual Response ResetIndexer( |
| | 1113 | | string indexerName, |
| | 1114 | | CancellationToken cancellationToken = default) |
| | 1115 | | { |
| 1 | 1116 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(ResetIn |
| 1 | 1117 | | scope.Start(); |
| | 1118 | | try |
| | 1119 | | { |
| 1 | 1120 | | return IndexersClient.Reset( |
| 1 | 1121 | | indexerName, |
| 1 | 1122 | | cancellationToken); |
| | 1123 | | } |
| 1 | 1124 | | catch (Exception ex) |
| | 1125 | | { |
| 1 | 1126 | | scope.Failed(ex); |
| 1 | 1127 | | throw; |
| | 1128 | | } |
| 0 | 1129 | | } |
| | 1130 | |
|
| | 1131 | | /// <summary> |
| | 1132 | | /// Resets the change tracking state associated with an indexer. |
| | 1133 | | /// </summary> |
| | 1134 | | /// <param name="indexerName">Required. The name of the indexer to reset.</param> |
| | 1135 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1136 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1137 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1138 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1139 | | public virtual async Task<Response> ResetIndexerAsync( |
| | 1140 | | string indexerName, |
| | 1141 | | CancellationToken cancellationToken = default) |
| | 1142 | | { |
| 1 | 1143 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(ResetIn |
| 1 | 1144 | | scope.Start(); |
| | 1145 | | try |
| | 1146 | | { |
| 1 | 1147 | | return await IndexersClient.ResetAsync( |
| 1 | 1148 | | indexerName, |
| 1 | 1149 | | cancellationToken) |
| 1 | 1150 | | .ConfigureAwait(false); |
| | 1151 | | } |
| 1 | 1152 | | catch (Exception ex) |
| | 1153 | | { |
| 1 | 1154 | | scope.Failed(ex); |
| 1 | 1155 | | throw; |
| | 1156 | | } |
| 0 | 1157 | | } |
| | 1158 | |
|
| | 1159 | | /// <summary> |
| | 1160 | | /// Run an indexer now. |
| | 1161 | | /// </summary> |
| | 1162 | | /// <param name="indexerName">Required. The name of the indexer to run.</param> |
| | 1163 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1164 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1165 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1166 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1167 | | public virtual Response RunIndexer( |
| | 1168 | | string indexerName, |
| | 1169 | | CancellationToken cancellationToken = default) |
| | 1170 | | { |
| 2 | 1171 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(RunInde |
| 2 | 1172 | | scope.Start(); |
| | 1173 | | try |
| | 1174 | | { |
| 2 | 1175 | | return IndexersClient.Run( |
| 2 | 1176 | | indexerName, |
| 2 | 1177 | | cancellationToken); |
| | 1178 | | } |
| 1 | 1179 | | catch (Exception ex) |
| | 1180 | | { |
| 1 | 1181 | | scope.Failed(ex); |
| 1 | 1182 | | throw; |
| | 1183 | | } |
| 1 | 1184 | | } |
| | 1185 | |
|
| | 1186 | | /// <summary> |
| | 1187 | | /// Run an indexer now. |
| | 1188 | | /// </summary> |
| | 1189 | | /// <param name="indexerName">Required. The name of the indexer to run.</param> |
| | 1190 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1191 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1192 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="indexerName"/> is null.</exception> |
| | 1193 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1194 | | public virtual async Task<Response> RunIndexerAsync( |
| | 1195 | | string indexerName, |
| | 1196 | | CancellationToken cancellationToken = default) |
| | 1197 | | { |
| 2 | 1198 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(RunInde |
| 2 | 1199 | | scope.Start(); |
| | 1200 | | try |
| | 1201 | | { |
| 2 | 1202 | | return await IndexersClient.RunAsync( |
| 2 | 1203 | | indexerName, |
| 2 | 1204 | | cancellationToken) |
| 2 | 1205 | | .ConfigureAwait(false); |
| | 1206 | | } |
| 1 | 1207 | | catch (Exception ex) |
| | 1208 | | { |
| 1 | 1209 | | scope.Failed(ex); |
| 1 | 1210 | | throw; |
| | 1211 | | } |
| 1 | 1212 | | } |
| | 1213 | | #endregion |
| | 1214 | |
|
| | 1215 | | #region Skillsets operations |
| | 1216 | | /// <summary> |
| | 1217 | | /// Creates a new skillset. |
| | 1218 | | /// </summary> |
| | 1219 | | /// <param name="skillset">Required. The <see cref="SearchIndexerSkillset"/> to create.</param> |
| | 1220 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1221 | | /// <returns> |
| | 1222 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerSkillset"/> that was cr |
| | 1223 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 1224 | | /// </returns> |
| | 1225 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1226 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1227 | | public virtual Response<SearchIndexerSkillset> CreateSkillset( |
| | 1228 | | SearchIndexerSkillset skillset, |
| | 1229 | | CancellationToken cancellationToken = default) |
| | 1230 | | { |
| 2 | 1231 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateS |
| 2 | 1232 | | scope.Start(); |
| | 1233 | | try |
| | 1234 | | { |
| 2 | 1235 | | return SkillsetsClient.Create( |
| 2 | 1236 | | skillset, |
| 2 | 1237 | | cancellationToken); |
| | 1238 | | } |
| 1 | 1239 | | catch (Exception ex) |
| | 1240 | | { |
| 1 | 1241 | | scope.Failed(ex); |
| 1 | 1242 | | throw; |
| | 1243 | | } |
| 1 | 1244 | | } |
| | 1245 | |
|
| | 1246 | | /// <summary> |
| | 1247 | | /// Creates a new skillset. |
| | 1248 | | /// </summary> |
| | 1249 | | /// <param name="skillset">Required. The <see cref="SearchIndexerSkillset"/> to create.</param> |
| | 1250 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1251 | | /// <returns> |
| | 1252 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerSkillset"/> that was cr |
| | 1253 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 1254 | | /// </returns> |
| | 1255 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1256 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1257 | | public virtual async Task<Response<SearchIndexerSkillset>> CreateSkillsetAsync( |
| | 1258 | | SearchIndexerSkillset skillset, |
| | 1259 | | CancellationToken cancellationToken = default) |
| | 1260 | | { |
| 3 | 1261 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateS |
| 3 | 1262 | | scope.Start(); |
| | 1263 | | try |
| | 1264 | | { |
| 3 | 1265 | | return await SkillsetsClient.CreateAsync( |
| 3 | 1266 | | skillset, |
| 3 | 1267 | | cancellationToken) |
| 3 | 1268 | | .ConfigureAwait(false); |
| | 1269 | | } |
| 1 | 1270 | | catch (Exception ex) |
| | 1271 | | { |
| 1 | 1272 | | scope.Failed(ex); |
| 1 | 1273 | | throw; |
| | 1274 | | } |
| 2 | 1275 | | } |
| | 1276 | |
|
| | 1277 | | /// <summary> |
| | 1278 | | /// Creates a new skillset or updates an existing skillset. |
| | 1279 | | /// </summary> |
| | 1280 | | /// <param name="skillset">Required. The <see cref="SearchIndexerSkillset"/> to create or update.</param> |
| | 1281 | | /// <param name="onlyIfUnchanged"> |
| | 1282 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerSkillset.ETag"/> does no |
| | 1283 | | /// otherwise, the current service version will be overwritten. |
| | 1284 | | /// </param> |
| | 1285 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1286 | | /// <returns> |
| | 1287 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerSkillset"/> that was cr |
| | 1288 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 1289 | | /// </returns> |
| | 1290 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1291 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1292 | | public virtual Response<SearchIndexerSkillset> CreateOrUpdateSkillset( |
| | 1293 | | SearchIndexerSkillset skillset, |
| | 1294 | | bool onlyIfUnchanged = false, |
| | 1295 | | CancellationToken cancellationToken = default) |
| | 1296 | | { |
| | 1297 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 1298 | | Argument.AssertNotNull(skillset, nameof(skillset)); |
| | 1299 | |
|
| 1 | 1300 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 1301 | | scope.Start(); |
| | 1302 | | try |
| | 1303 | | { |
| 1 | 1304 | | return SkillsetsClient.CreateOrUpdate( |
| 1 | 1305 | | skillset?.Name, |
| 1 | 1306 | | skillset, |
| 1 | 1307 | | onlyIfUnchanged ? skillset?.ETag?.ToString() : null, |
| 1 | 1308 | | null, |
| 1 | 1309 | | cancellationToken); |
| | 1310 | | } |
| 0 | 1311 | | catch (Exception ex) |
| | 1312 | | { |
| 0 | 1313 | | scope.Failed(ex); |
| 0 | 1314 | | throw; |
| | 1315 | | } |
| 1 | 1316 | | } |
| | 1317 | |
|
| | 1318 | | /// <summary> |
| | 1319 | | /// Creates a new skillset or updates an existing skillset. |
| | 1320 | | /// </summary> |
| | 1321 | | /// <param name="skillset">Required. The <see cref="SearchIndexerSkillset"/> to create or update.</param> |
| | 1322 | | /// <param name="onlyIfUnchanged"> |
| | 1323 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerSkillset.ETag"/> does no |
| | 1324 | | /// otherwise, the current service version will be overwritten. |
| | 1325 | | /// </param> |
| | 1326 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1327 | | /// <returns> |
| | 1328 | | /// The <see cref="Response{T}"/> from the server containing the <see cref="SearchIndexerSkillset"/> that was cr |
| | 1329 | | /// This may differ slightly from what was passed in since the service may return back properties set to their d |
| | 1330 | | /// </returns> |
| | 1331 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1332 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1333 | | public virtual async Task<Response<SearchIndexerSkillset>> CreateOrUpdateSkillsetAsync( |
| | 1334 | | SearchIndexerSkillset skillset, |
| | 1335 | | bool onlyIfUnchanged = false, |
| | 1336 | | CancellationToken cancellationToken = default) |
| | 1337 | | { |
| | 1338 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 1339 | | Argument.AssertNotNull(skillset, nameof(skillset)); |
| | 1340 | |
|
| 1 | 1341 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO |
| 1 | 1342 | | scope.Start(); |
| | 1343 | | try |
| | 1344 | | { |
| 1 | 1345 | | return await SkillsetsClient.CreateOrUpdateAsync( |
| 1 | 1346 | | skillset?.Name, |
| 1 | 1347 | | skillset, |
| 1 | 1348 | | onlyIfUnchanged ? skillset?.ETag?.ToString() : null, |
| 1 | 1349 | | null, |
| 1 | 1350 | | cancellationToken) |
| 1 | 1351 | | .ConfigureAwait(false); |
| | 1352 | | } |
| 0 | 1353 | | catch (Exception ex) |
| | 1354 | | { |
| 0 | 1355 | | scope.Failed(ex); |
| 0 | 1356 | | throw; |
| | 1357 | | } |
| 1 | 1358 | | } |
| | 1359 | |
|
| | 1360 | | /// <summary> |
| | 1361 | | /// Deletes a skillset. |
| | 1362 | | /// </summary> |
| | 1363 | | /// <param name="skillsetName">The name of the <see cref="SearchIndexerSkillset"/> to delete.</param> |
| | 1364 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1365 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1366 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillsetName"/> is null.</exception> |
| | 1367 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1368 | | public virtual Response DeleteSkillset( |
| | 1369 | | string skillsetName, |
| | 1370 | | CancellationToken cancellationToken = default) |
| | 1371 | | { |
| | 1372 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 1 | 1373 | | Argument.AssertNotNull(skillsetName, nameof(skillsetName)); |
| | 1374 | |
|
| 0 | 1375 | | return DeleteSkillset( |
| 0 | 1376 | | skillsetName, |
| 0 | 1377 | | null, |
| 0 | 1378 | | false, |
| 0 | 1379 | | cancellationToken); |
| | 1380 | | } |
| | 1381 | |
|
| | 1382 | | /// <summary> |
| | 1383 | | /// Deletes a skillset. |
| | 1384 | | /// </summary> |
| | 1385 | | /// <param name="skillsetName">The name of the <see cref="SearchIndexerSkillset"/> to delete.</param> |
| | 1386 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1387 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1388 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillsetName"/> is null.</exception> |
| | 1389 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1390 | | public virtual async Task<Response> DeleteSkillsetAsync( |
| | 1391 | | string skillsetName, |
| | 1392 | | CancellationToken cancellationToken = default) |
| | 1393 | | { |
| | 1394 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 1395 | | Argument.AssertNotNull(skillsetName, nameof(skillsetName)); |
| | 1396 | |
|
| 1 | 1397 | | return await DeleteSkillsetAsync( |
| 1 | 1398 | | skillsetName, |
| 1 | 1399 | | null, |
| 1 | 1400 | | false, |
| 1 | 1401 | | cancellationToken) |
| 1 | 1402 | | .ConfigureAwait(false); |
| 1 | 1403 | | } |
| | 1404 | |
|
| | 1405 | | /// <summary> |
| | 1406 | | /// Deletes a skillset. |
| | 1407 | | /// </summary> |
| | 1408 | | /// <param name="skillset">The <see cref="SearchIndexerSkillset"/> to delete.</param> |
| | 1409 | | /// <param name="onlyIfUnchanged"> |
| | 1410 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerSkillset.ETag"/> does no |
| | 1411 | | /// otherwise, the current service version will be overwritten. |
| | 1412 | | /// </param> |
| | 1413 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1414 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1415 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1416 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1417 | | public virtual Response DeleteSkillset( |
| | 1418 | | SearchIndexerSkillset skillset, |
| | 1419 | | bool onlyIfUnchanged = false, |
| | 1420 | | CancellationToken cancellationToken = default) |
| | 1421 | | { |
| | 1422 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 1423 | | Argument.AssertNotNull(skillset, nameof(skillset)); |
| | 1424 | |
|
| 1 | 1425 | | return DeleteSkillset( |
| 1 | 1426 | | skillset?.Name, |
| 1 | 1427 | | skillset?.ETag, |
| 1 | 1428 | | onlyIfUnchanged, |
| 1 | 1429 | | cancellationToken); |
| | 1430 | | } |
| | 1431 | |
|
| | 1432 | | /// <summary> |
| | 1433 | | /// Deletes a skillset. |
| | 1434 | | /// </summary> |
| | 1435 | | /// <param name="skillset">The <see cref="SearchIndexerSkillset"/> to delete.</param> |
| | 1436 | | /// <param name="onlyIfUnchanged"> |
| | 1437 | | /// True to throw a <see cref="RequestFailedException"/> if the <see cref="SearchIndexerSkillset.ETag"/> does no |
| | 1438 | | /// otherwise, the current service version will be overwritten. |
| | 1439 | | /// </param> |
| | 1440 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1441 | | /// <returns>The <see cref="Response"/> from the server.</returns> |
| | 1442 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillset"/> is null.</exception> |
| | 1443 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1444 | | public virtual async Task<Response> DeleteSkillsetAsync( |
| | 1445 | | SearchIndexerSkillset skillset, |
| | 1446 | | bool onlyIfUnchanged = false, |
| | 1447 | | CancellationToken cancellationToken = default) |
| | 1448 | | { |
| | 1449 | | // The REST client uses a different parameter name that would be confusing to reference. |
| 2 | 1450 | | Argument.AssertNotNull(skillset, nameof(skillset)); |
| | 1451 | |
|
| 1 | 1452 | | return await DeleteSkillsetAsync( |
| 1 | 1453 | | skillset?.Name, |
| 1 | 1454 | | skillset?.ETag, |
| 1 | 1455 | | onlyIfUnchanged, |
| 1 | 1456 | | cancellationToken) |
| 1 | 1457 | | .ConfigureAwait(false); |
| 1 | 1458 | | } |
| | 1459 | |
|
| | 1460 | | private Response DeleteSkillset( |
| | 1461 | | string skillsetName, |
| | 1462 | | ETag? etag, |
| | 1463 | | bool onlyIfUnchanged, |
| | 1464 | | CancellationToken cancellationToken) |
| | 1465 | | { |
| 1 | 1466 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteS |
| 1 | 1467 | | scope.Start(); |
| | 1468 | | try |
| | 1469 | | { |
| 1 | 1470 | | return SkillsetsClient.Delete( |
| 1 | 1471 | | skillsetName, |
| 1 | 1472 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 1 | 1473 | | null, |
| 1 | 1474 | | cancellationToken); |
| | 1475 | | } |
| 0 | 1476 | | catch (Exception ex) |
| | 1477 | | { |
| 0 | 1478 | | scope.Failed(ex); |
| 0 | 1479 | | throw; |
| | 1480 | | } |
| 1 | 1481 | | } |
| | 1482 | |
|
| | 1483 | | private async Task<Response> DeleteSkillsetAsync( |
| | 1484 | | string skillsetName, |
| | 1485 | | ETag? etag, |
| | 1486 | | bool onlyIfUnchanged, |
| | 1487 | | CancellationToken cancellationToken) |
| | 1488 | | { |
| 2 | 1489 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteS |
| 2 | 1490 | | scope.Start(); |
| | 1491 | | try |
| | 1492 | | { |
| 2 | 1493 | | return await SkillsetsClient.DeleteAsync( |
| 2 | 1494 | | skillsetName, |
| 2 | 1495 | | onlyIfUnchanged ? etag?.ToString() : null, |
| 2 | 1496 | | null, |
| 2 | 1497 | | cancellationToken) |
| 2 | 1498 | | .ConfigureAwait(false); |
| | 1499 | | } |
| 0 | 1500 | | catch (Exception ex) |
| | 1501 | | { |
| 0 | 1502 | | scope.Failed(ex); |
| 0 | 1503 | | throw; |
| | 1504 | | } |
| 2 | 1505 | | } |
| | 1506 | |
|
| | 1507 | | /// <summary> |
| | 1508 | | /// Gets a specific <see cref="SearchIndexerSkillset"/>. |
| | 1509 | | /// </summary> |
| | 1510 | | /// <param name="skillsetName">Required. The name of the <see cref="SearchIndexerSkillset"/> to get.</param> |
| | 1511 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1512 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerSkil |
| | 1513 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillsetName"/> is null.</exception> |
| | 1514 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1515 | | public virtual Response<SearchIndexerSkillset> GetSkillset( |
| | 1516 | | string skillsetName, |
| | 1517 | | CancellationToken cancellationToken = default) |
| | 1518 | | { |
| 2 | 1519 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 2 | 1520 | | scope.Start(); |
| | 1521 | | try |
| | 1522 | | { |
| 2 | 1523 | | return SkillsetsClient.Get( |
| 2 | 1524 | | skillsetName, |
| 2 | 1525 | | cancellationToken); |
| | 1526 | | } |
| 1 | 1527 | | catch (Exception ex) |
| | 1528 | | { |
| 1 | 1529 | | scope.Failed(ex); |
| 1 | 1530 | | throw; |
| | 1531 | | } |
| 1 | 1532 | | } |
| | 1533 | |
|
| | 1534 | | /// <summary> |
| | 1535 | | /// Gets a specific <see cref="SearchIndexerSkillset"/>. |
| | 1536 | | /// </summary> |
| | 1537 | | /// <param name="skillsetName">Required. The name of the <see cref="SearchIndexerSkillset"/> to get.</param> |
| | 1538 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1539 | | /// <returns>The <see cref="Response{T}"/> from the server containing the requested <see cref="SearchIndexerSkil |
| | 1540 | | /// <exception cref="ArgumentNullException">Thrown when <paramref name="skillsetName"/> is null.</exception> |
| | 1541 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1542 | | public virtual async Task<Response<SearchIndexerSkillset>> GetSkillsetAsync( |
| | 1543 | | string skillsetName, |
| | 1544 | | CancellationToken cancellationToken = default) |
| | 1545 | | { |
| 2 | 1546 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 2 | 1547 | | scope.Start(); |
| | 1548 | | try |
| | 1549 | | { |
| 2 | 1550 | | return await SkillsetsClient.GetAsync( |
| 2 | 1551 | | skillsetName, |
| 2 | 1552 | | cancellationToken) |
| 2 | 1553 | | .ConfigureAwait(false); |
| | 1554 | | } |
| 1 | 1555 | | catch (Exception ex) |
| | 1556 | | { |
| 1 | 1557 | | scope.Failed(ex); |
| 1 | 1558 | | throw; |
| | 1559 | | } |
| 1 | 1560 | | } |
| | 1561 | |
|
| | 1562 | | /// <summary> |
| | 1563 | | /// Gets a list of all skillsets. |
| | 1564 | | /// </summary> |
| | 1565 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1566 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerSkillset |
| | 1567 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1568 | | public virtual Response<IReadOnlyList<SearchIndexerSkillset>> GetSkillsets( |
| | 1569 | | CancellationToken cancellationToken = default) |
| | 1570 | | { |
| 0 | 1571 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 0 | 1572 | | scope.Start(); |
| | 1573 | | try |
| | 1574 | | { |
| 0 | 1575 | | Response<ListSkillsetsResult> result = SkillsetsClient.List( |
| 0 | 1576 | | Constants.All, |
| 0 | 1577 | | cancellationToken); |
| | 1578 | |
|
| 0 | 1579 | | return Response.FromValue(result.Value.Skillsets, result.GetRawResponse()); |
| | 1580 | | } |
| 0 | 1581 | | catch (Exception ex) |
| | 1582 | | { |
| 0 | 1583 | | scope.Failed(ex); |
| 0 | 1584 | | throw; |
| | 1585 | | } |
| 0 | 1586 | | } |
| | 1587 | |
|
| | 1588 | | /// <summary> |
| | 1589 | | /// Gets a list of all skillsets. |
| | 1590 | | /// </summary> |
| | 1591 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1592 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerSkillset |
| | 1593 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1594 | | public virtual async Task<Response<IReadOnlyList<SearchIndexerSkillset>>> GetSkillsetsAsync( |
| | 1595 | | CancellationToken cancellationToken = default) |
| | 1596 | | { |
| 0 | 1597 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 0 | 1598 | | scope.Start(); |
| | 1599 | | try |
| | 1600 | | { |
| 0 | 1601 | | Response<ListSkillsetsResult> result = await SkillsetsClient.ListAsync( |
| 0 | 1602 | | Constants.All, |
| 0 | 1603 | | cancellationToken) |
| 0 | 1604 | | .ConfigureAwait(false); |
| | 1605 | |
|
| 0 | 1606 | | return Response.FromValue(result.Value.Skillsets, result.GetRawResponse()); |
| | 1607 | | } |
| 0 | 1608 | | catch (Exception ex) |
| | 1609 | | { |
| 0 | 1610 | | scope.Failed(ex); |
| 0 | 1611 | | throw; |
| | 1612 | | } |
| 0 | 1613 | | } |
| | 1614 | |
|
| | 1615 | | /// <summary> |
| | 1616 | | /// Gets a list of all skillset names. |
| | 1617 | | /// </summary> |
| | 1618 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1619 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerSkillset |
| | 1620 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1621 | | public virtual Response<IReadOnlyList<string>> GetSkillsetNames( |
| | 1622 | | CancellationToken cancellationToken = default) |
| | 1623 | | { |
| 1 | 1624 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 1 | 1625 | | scope.Start(); |
| | 1626 | | try |
| | 1627 | | { |
| 1 | 1628 | | Response<ListSkillsetsResult> result = SkillsetsClient.List( |
| 1 | 1629 | | Constants.NameKey, |
| 1 | 1630 | | cancellationToken); |
| | 1631 | |
|
| 2 | 1632 | | IReadOnlyList<string> names = result.Value.Skillsets.Select(value => value.Name).ToArray(); |
| 1 | 1633 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 1634 | | } |
| 0 | 1635 | | catch (Exception ex) |
| | 1636 | | { |
| 0 | 1637 | | scope.Failed(ex); |
| 0 | 1638 | | throw; |
| | 1639 | | } |
| 1 | 1640 | | } |
| | 1641 | |
|
| | 1642 | | /// <summary> |
| | 1643 | | /// Gets a list of all skillset names. |
| | 1644 | | /// </summary> |
| | 1645 | | /// <param name="cancellationToken">Optional <see cref="CancellationToken"/> to propagate notifications that the |
| | 1646 | | /// <returns>The <see cref="Response{T}"/> from the server containing a list of <see cref="SearchIndexerSkillset |
| | 1647 | | /// <exception cref="RequestFailedException">Thrown when a failure is returned by the Search service.</exception |
| | 1648 | | public virtual async Task<Response<IReadOnlyList<string>>> GetSkillsetNamesAsync( |
| | 1649 | | CancellationToken cancellationToken = default) |
| | 1650 | | { |
| 1 | 1651 | | using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil |
| 1 | 1652 | | scope.Start(); |
| | 1653 | | try |
| | 1654 | | { |
| 1 | 1655 | | Response<ListSkillsetsResult> result = await SkillsetsClient.ListAsync( |
| 1 | 1656 | | Constants.NameKey, |
| 1 | 1657 | | cancellationToken) |
| 1 | 1658 | | .ConfigureAwait(false); |
| | 1659 | |
|
| 2 | 1660 | | IReadOnlyList<string> names = result.Value.Skillsets.Select(value => value.Name).ToArray(); |
| 1 | 1661 | | return Response.FromValue(names, result.GetRawResponse()); |
| | 1662 | | } |
| 0 | 1663 | | catch (Exception ex) |
| | 1664 | | { |
| 0 | 1665 | | scope.Failed(ex); |
| 0 | 1666 | | throw; |
| | 1667 | | } |
| 1 | 1668 | | } |
| | 1669 | | #endregion |
| | 1670 | | } |
| | 1671 | | } |