< Summary

Class:Azure.Search.Documents.Indexes.SearchIndexerClient
Assembly:Azure.Search.Documents
File(s):C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\SearchIndexerClient.cs
Covered lines:389
Uncovered lines:191
Coverable lines:580
Total lines:1671
Line coverage:67% (389 of 580)
Covered branches:47
Total branches:100
Branch coverage:47% (47 of 100)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
.ctor(...)-100%100%
get_Endpoint()-100%100%
get_ServiceName()-100%100%
get_DataSourcesClient()-100%100%
get_IndexersClient()-100%100%
get_SkillsetsClient()-100%100%
CreateDataSourceConnection(...)-70%100%
CreateDataSourceConnectionAsync()-72.73%100%
CreateOrUpdateDataSourceConnection(...)-76.92%50%
CreateOrUpdateDataSourceConnectionAsync()-78.57%50%
DeleteDataSourceConnection(...)-16.67%100%
DeleteDataSourceConnectionAsync()-100%100%
DeleteDataSourceConnection(...)-100%50%
DeleteDataSourceConnectionAsync()-100%50%
DeleteDataSourceConnection(...)-72.73%50%
DeleteDataSourceConnectionAsync()-75%75%
GetDataSourceConnection(...)-70%100%
GetDataSourceConnectionAsync()-72.73%100%
GetDataSourceConnections(...)-0%100%
GetDataSourceConnectionsAsync()-0%100%
GetDataSourceConnectionNames(...)-72.73%100%
GetDataSourceConnectionNamesAsync()-75%100%
CreateIndexer(...)-100%100%
CreateIndexerAsync()-100%100%
CreateOrUpdateIndexer(...)-76.92%50%
CreateOrUpdateIndexerAsync()-78.57%50%
DeleteIndexer(...)-16.67%100%
DeleteIndexerAsync()-100%100%
DeleteIndexer(...)-16.67%0%
DeleteIndexerAsync()-12.5%0%
DeleteIndexer(...)-0%0%
DeleteIndexerAsync()-75%25%
GetIndexer(...)-88.89%100%
GetIndexerAsync()-90%100%
GetIndexers(...)-0%100%
GetIndexersAsync()-0%100%
GetIndexerNames(...)-0%100%
GetIndexerNamesAsync()-0%100%
GetIndexerStatus(...)-66.67%100%
GetIndexerStatusAsync()-70%100%
ResetIndexer(...)-88.89%100%
ResetIndexerAsync()-90%100%
RunIndexer(...)-100%100%
RunIndexerAsync()-100%100%
CreateSkillset(...)-100%100%
CreateSkillsetAsync()-100%100%
CreateOrUpdateSkillset(...)-76.92%50%
CreateOrUpdateSkillsetAsync()-78.57%50%
DeleteSkillset(...)-16.67%100%
DeleteSkillsetAsync()-100%100%
DeleteSkillset(...)-100%50%
DeleteSkillsetAsync()-100%50%
DeleteSkillset(...)-72.73%50%
DeleteSkillsetAsync()-75%75%
GetSkillset(...)-100%100%
GetSkillsetAsync()-100%100%
GetSkillsets(...)-0%100%
GetSkillsetsAsync()-0%100%
GetSkillsetNames(...)-72.73%100%
GetSkillsetNamesAsync()-75%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\search\Azure.Search.Documents\src\Indexes\SearchIndexerClient.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Threading;
 6using System.Threading.Tasks;
 7using Azure.Core;
 8using Azure.Core.Pipeline;
 9using System.Collections.Generic;
 10using System.Linq;
 11using Azure.Search.Documents.Indexes.Models;
 12
 13namespace 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>
 1435        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) :
 2349            this(endpoint, credential, null)
 50        {
 1751        }
 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
 3065        public SearchIndexerClient(
 3066            Uri endpoint,
 3067            AzureKeyCredential credential,
 3068            SearchClientOptions options)
 69        {
 3070            Argument.AssertNotNull(endpoint, nameof(endpoint));
 2871            endpoint.AssertHttpsScheme(nameof(endpoint));
 2672            Argument.AssertNotNull(credential, nameof(credential));
 73
 2474            options ??= new SearchClientOptions();
 2475            Endpoint = endpoint;
 2476            _clientDiagnostics = new ClientDiagnostics(options);
 2477            _pipeline = options.Build(credential);
 2478            _version = options.Version;
 2479        }
 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>
 2185        public virtual Uri Endpoint { get; }
 86
 87        /// <summary>
 88        /// Gets the name of the Search service.
 89        /// </summary>
 90        public virtual string ServiceName =>
 291            _serviceName ??= Endpoint.GetSearchServiceName();
 92
 93        /// <summary>
 94        /// Gets the generated <see cref="DataSourcesRestClient"/> to make requests.
 95        /// </summary>
 1996        private DataSourcesRestClient DataSourcesClient => LazyInitializer.EnsureInitialized(ref _dataSourcesClient, () 
 1997            _clientDiagnostics,
 1998            _pipeline,
 1999            Endpoint.ToString(),
 19100            null,
 19101            _version.ToVersionString())
 14102        );
 103
 104        /// <summary>
 105        /// Gets the generated <see cref="IndexersRestClient"/> to make requests.
 106        /// </summary>
 28107        private IndexersRestClient IndexersClient => LazyInitializer.EnsureInitialized(ref _indexersClient, () => new In
 28108            _clientDiagnostics,
 28109            _pipeline,
 28110            Endpoint.ToString(),
 28111            null,
 28112            _version.ToVersionString())
 21113        );
 114
 115        /// <summary>
 116        /// Gets the generated <see cref="SkillsetsRestClient"/> to make requests.
 117        /// </summary>
 21118        private SkillsetsRestClient SkillsetsClient => LazyInitializer.EnsureInitialized(ref _skillsetsClient, () => new
 21119            _clientDiagnostics,
 21120            _pipeline,
 21121            Endpoint.ToString(),
 21122            null,
 21123            _version.ToVersionString())
 16124        );
 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.
 3143            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 144
 2145            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateD
 2146            scope.Start();
 147            try
 148            {
 2149                return DataSourcesClient.Create(
 2150                    dataSourceConnection,
 2151                    cancellationToken);
 152            }
 0153            catch (Exception ex)
 154            {
 0155                scope.Failed(ex);
 0156                throw;
 157            }
 2158        }
 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.
 4176            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 177
 3178            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateD
 3179            scope.Start();
 180            try
 181            {
 3182                return await DataSourcesClient.CreateAsync(
 3183                    dataSourceConnection,
 3184                    cancellationToken)
 3185                    .ConfigureAwait(false);
 186            }
 0187            catch (Exception ex)
 188            {
 0189                scope.Failed(ex);
 0190                throw;
 191            }
 3192        }
 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.
 2215            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 216
 1217            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 1218            scope.Start();
 219            try
 220            {
 1221                return DataSourcesClient.CreateOrUpdate(
 1222                    dataSourceConnection?.Name,
 1223                    dataSourceConnection,
 1224                    onlyIfUnchanged ? dataSourceConnection?.ETag?.ToString() : null,
 1225                    null,
 1226                    cancellationToken);
 227            }
 0228            catch (Exception ex)
 229            {
 0230                scope.Failed(ex);
 0231                throw;
 232            }
 1233        }
 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.
 2256            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 257
 1258            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 1259            scope.Start();
 260            try
 261            {
 1262                return await DataSourcesClient.CreateOrUpdateAsync(
 1263                    dataSourceConnection?.Name,
 1264                    dataSourceConnection,
 1265                    onlyIfUnchanged ? dataSourceConnection?.ETag?.ToString() : null,
 1266                    null,
 1267                    cancellationToken)
 1268                    .ConfigureAwait(false);
 269            }
 0270            catch (Exception ex)
 271            {
 0272                scope.Failed(ex);
 0273                throw;
 274            }
 1275        }
 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.
 1290            Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName));
 291
 0292            return DeleteDataSourceConnection(
 0293                dataSourceConnectionName,
 0294                null,
 0295                false,
 0296                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.
 2312            Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName));
 313
 1314            return await DeleteDataSourceConnectionAsync(
 1315                dataSourceConnectionName,
 1316                null,
 1317                false,
 1318                cancellationToken)
 1319                .ConfigureAwait(false);
 1320        }
 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.
 2340            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 341
 1342            return DeleteDataSourceConnection(
 1343                dataSourceConnection?.Name,
 1344                dataSourceConnection?.ETag,
 1345                onlyIfUnchanged,
 1346                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.
 2367            Argument.AssertNotNull(dataSourceConnection, nameof(dataSourceConnection));
 368
 1369            return await DeleteDataSourceConnectionAsync(
 1370                dataSourceConnection?.Name,
 1371                dataSourceConnection?.ETag,
 1372                onlyIfUnchanged,
 1373                cancellationToken)
 1374                .ConfigureAwait(false);
 1375        }
 376
 377        private Response DeleteDataSourceConnection(
 378            string dataSourceConnectionName,
 379            ETag? etag,
 380            bool onlyIfUnchanged,
 381            CancellationToken cancellationToken)
 382        {
 1383            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteD
 1384            scope.Start();
 385            try
 386            {
 1387                return DataSourcesClient.Delete(
 1388                    dataSourceConnectionName,
 1389                    onlyIfUnchanged ? etag?.ToString() : null,
 1390                    null,
 1391                    cancellationToken);
 392            }
 0393            catch (Exception ex)
 394            {
 0395                scope.Failed(ex);
 0396                throw;
 397            }
 1398        }
 399
 400        private async Task<Response> DeleteDataSourceConnectionAsync(
 401            string dataSourceConnectionName,
 402            ETag? etag,
 403            bool onlyIfUnchanged,
 404            CancellationToken cancellationToken)
 405        {
 2406            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteD
 2407            scope.Start();
 408            try
 409            {
 2410                return await DataSourcesClient.DeleteAsync(
 2411                    dataSourceConnectionName,
 2412                    onlyIfUnchanged ? etag?.ToString() : null,
 2413                    null,
 2414                    cancellationToken)
 2415                    .ConfigureAwait(false);
 416            }
 0417            catch (Exception ex)
 418            {
 0419                scope.Failed(ex);
 0420                throw;
 421            }
 2422        }
 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.
 2437            Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName));
 438
 1439            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 1440            scope.Start();
 441            try
 442            {
 1443                return DataSourcesClient.Get(
 1444                    dataSourceConnectionName,
 1445                    cancellationToken);
 446            }
 0447            catch (Exception ex)
 448            {
 0449                scope.Failed(ex);
 0450                throw;
 451            }
 1452        }
 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.
 2467            Argument.AssertNotNull(dataSourceConnectionName, nameof(dataSourceConnectionName));
 468
 1469            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 1470            scope.Start();
 471            try
 472            {
 1473                return await DataSourcesClient.GetAsync(
 1474                    dataSourceConnectionName,
 1475                    cancellationToken)
 1476                    .ConfigureAwait(false);
 477            }
 0478            catch (Exception ex)
 479            {
 0480                scope.Failed(ex);
 0481                throw;
 482            }
 1483        }
 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        {
 0494            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 0495            scope.Start();
 496            try
 497            {
 0498                Response<ListDataSourcesResult> result = DataSourcesClient.List(
 0499                    Constants.All,
 0500                    cancellationToken);
 501
 0502                return Response.FromValue(result.Value.DataSources, result.GetRawResponse());
 503            }
 0504            catch (Exception ex)
 505            {
 0506                scope.Failed(ex);
 0507                throw;
 508            }
 0509        }
 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        {
 0520            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 0521            scope.Start();
 522            try
 523            {
 0524                Response<ListDataSourcesResult> result = await DataSourcesClient.ListAsync(
 0525                    Constants.All,
 0526                    cancellationToken)
 0527                    .ConfigureAwait(false);
 528
 0529                return Response.FromValue(result.Value.DataSources, result.GetRawResponse());
 530            }
 0531            catch (Exception ex)
 532            {
 0533                scope.Failed(ex);
 0534                throw;
 535            }
 0536        }
 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        {
 1547            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 1548            scope.Start();
 549            try
 550            {
 1551                Response<ListDataSourcesResult> result = DataSourcesClient.List(
 1552                    Constants.NameKey,
 1553                    cancellationToken);
 554
 2555                IReadOnlyList<string> names = result.Value.DataSources.Select(value => value.Name).ToArray();
 1556                return Response.FromValue(names, result.GetRawResponse());
 557            }
 0558            catch (Exception ex)
 559            {
 0560                scope.Failed(ex);
 0561                throw;
 562            }
 1563        }
 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        {
 1574            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetData
 1575            scope.Start();
 576            try
 577            {
 1578                Response<ListDataSourcesResult> result = await DataSourcesClient.ListAsync(
 1579                    Constants.NameKey,
 1580                    cancellationToken)
 1581                    .ConfigureAwait(false);
 582
 3583                IReadOnlyList<string> names = result.Value.DataSources.Select(value => value.Name).ToArray();
 1584                return Response.FromValue(names, result.GetRawResponse());
 585            }
 0586            catch (Exception ex)
 587            {
 0588                scope.Failed(ex);
 0589                throw;
 590            }
 1591        }
 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        {
 2610            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateI
 2611            scope.Start();
 612            try
 613            {
 2614                return IndexersClient.Create(
 2615                    indexer,
 2616                    cancellationToken);
 617            }
 1618            catch (Exception ex)
 619            {
 1620                scope.Failed(ex);
 1621                throw;
 622            }
 1623        }
 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        {
 3640            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateI
 3641            scope.Start();
 642            try
 643            {
 3644                return await IndexersClient.CreateAsync(
 3645                    indexer,
 3646                    cancellationToken)
 3647                    .ConfigureAwait(false);
 648            }
 1649            catch (Exception ex)
 650            {
 1651                scope.Failed(ex);
 1652                throw;
 653            }
 2654        }
 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.
 2677            Argument.AssertNotNull(indexer, nameof(indexer));
 678
 1679            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 1680            scope.Start();
 681            try
 682            {
 1683                return IndexersClient.CreateOrUpdate(
 1684                    indexer?.Name,
 1685                    indexer,
 1686                    onlyIfUnchanged ? indexer?.ETag?.ToString() : null,
 1687                    null,
 1688                    cancellationToken);
 689            }
 0690            catch (Exception ex)
 691            {
 0692                scope.Failed(ex);
 0693                throw;
 694            }
 1695        }
 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.
 2718            Argument.AssertNotNull(indexer, nameof(indexer));
 719
 1720            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 1721            scope.Start();
 722            try
 723            {
 1724                return await IndexersClient.CreateOrUpdateAsync(
 1725                    indexer?.Name,
 1726                    indexer,
 1727                    onlyIfUnchanged ? indexer?.ETag?.ToString() : null,
 1728                    null,
 1729                    cancellationToken)
 1730                    .ConfigureAwait(false);
 731            }
 0732            catch (Exception ex)
 733            {
 0734                scope.Failed(ex);
 0735                throw;
 736            }
 1737        }
 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.
 1752            Argument.AssertNotNull(indexerName, nameof(indexerName));
 753
 0754            return DeleteIndexer(
 0755                indexerName,
 0756                null,
 0757                false,
 0758                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.
 2774            Argument.AssertNotNull(indexerName, nameof(indexerName));
 775
 1776            return await DeleteIndexerAsync(
 1777                indexerName,
 1778                null,
 1779                false,
 1780                cancellationToken)
 1781                .ConfigureAwait(false);
 1782        }
 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.
 1802            Argument.AssertNotNull(indexer, nameof(indexer));
 803
 0804            return DeleteIndexer(
 0805                indexer?.Name,
 0806                indexer?.ETag,
 0807                onlyIfUnchanged,
 0808                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.
 1829            Argument.AssertNotNull(indexer, nameof(indexer));
 830
 0831            return await DeleteIndexerAsync(
 0832                indexer?.Name,
 0833                indexer?.ETag,
 0834                onlyIfUnchanged,
 0835                cancellationToken)
 0836                .ConfigureAwait(false);
 0837        }
 838
 839        private Response DeleteIndexer(
 840            string indexerName,
 841            ETag? etag,
 842            bool onlyIfUnchanged,
 843            CancellationToken cancellationToken)
 844        {
 0845            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteI
 0846            scope.Start();
 847            try
 848            {
 0849                return IndexersClient.Delete(
 0850                    indexerName,
 0851                    onlyIfUnchanged ? etag?.ToString() : null,
 0852                    null,
 0853                    cancellationToken);
 854            }
 0855            catch (Exception ex)
 856            {
 0857                scope.Failed(ex);
 0858                throw;
 859            }
 0860        }
 861
 862        private async Task<Response> DeleteIndexerAsync(
 863            string indexerName,
 864            ETag? etag,
 865            bool onlyIfUnchanged,
 866            CancellationToken cancellationToken)
 867        {
 1868            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteI
 1869            scope.Start();
 870            try
 871            {
 1872                return await IndexersClient.DeleteAsync(
 1873                    indexerName,
 1874                    onlyIfUnchanged ? etag?.ToString() : null,
 1875                    null,
 1876                    cancellationToken)
 1877                    .ConfigureAwait(false);
 878            }
 0879            catch (Exception ex)
 880            {
 0881                scope.Failed(ex);
 0882                throw;
 883            }
 1884        }
 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        {
 1898            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 1899            scope.Start();
 900            try
 901            {
 1902                return IndexersClient.Get(
 1903                    indexerName,
 1904                    cancellationToken);
 905            }
 1906            catch (Exception ex)
 907            {
 1908                scope.Failed(ex);
 1909                throw;
 910            }
 0911        }
 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        {
 1925            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 1926            scope.Start();
 927            try
 928            {
 1929                return await IndexersClient.GetAsync(
 1930                    indexerName,
 1931                    cancellationToken)
 1932                    .ConfigureAwait(false);
 933            }
 1934            catch (Exception ex)
 935            {
 1936                scope.Failed(ex);
 1937                throw;
 938            }
 0939        }
 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        {
 0950            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 0951            scope.Start();
 952            try
 953            {
 0954                Response<ListIndexersResult> result = IndexersClient.List(
 0955                    Constants.All,
 0956                    cancellationToken);
 957
 0958                return Response.FromValue(result.Value.Indexers, result.GetRawResponse());
 959            }
 0960            catch (Exception ex)
 961            {
 0962                scope.Failed(ex);
 0963                throw;
 964            }
 0965        }
 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        {
 0976            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 0977            scope.Start();
 978            try
 979            {
 0980                Response<ListIndexersResult> result = await IndexersClient.ListAsync(
 0981                    Constants.All,
 0982                    cancellationToken)
 0983                    .ConfigureAwait(false);
 984
 0985                return Response.FromValue(result.Value.Indexers, result.GetRawResponse());
 986            }
 0987            catch (Exception ex)
 988            {
 0989                scope.Failed(ex);
 0990                throw;
 991            }
 0992        }
 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        {
 01003            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 01004            scope.Start();
 1005            try
 1006            {
 01007                Response<ListIndexersResult> result = IndexersClient.List(
 01008                    Constants.NameKey,
 01009                    cancellationToken);
 1010
 01011                IReadOnlyList<string> names = result.Value.Indexers.Select(value => value.Name).ToArray();
 01012                return Response.FromValue(names, result.GetRawResponse());
 1013            }
 01014            catch (Exception ex)
 1015            {
 01016                scope.Failed(ex);
 01017                throw;
 1018            }
 01019        }
 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        {
 01030            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 01031            scope.Start();
 1032            try
 1033            {
 01034                Response<ListIndexersResult> result = await IndexersClient.ListAsync(
 01035                    Constants.NameKey,
 01036                    cancellationToken)
 01037                    .ConfigureAwait(false);
 1038
 01039                IReadOnlyList<string> names = result.Value.Indexers.Select(value => value.Name).ToArray();
 01040                return Response.FromValue(names, result.GetRawResponse());
 1041            }
 01042            catch (Exception ex)
 1043            {
 01044                scope.Failed(ex);
 01045                throw;
 1046            }
 01047        }
 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        {
 21061            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 21062            scope.Start();
 1063            try
 1064            {
 21065                return IndexersClient.GetStatus(
 21066                    indexerName,
 21067                    cancellationToken);
 1068            }
 01069            catch (Exception ex)
 1070            {
 01071                scope.Failed(ex);
 01072                throw;
 1073            }
 21074        }
 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        {
 31088            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetInde
 31089            scope.Start();
 1090            try
 1091            {
 31092                return await IndexersClient.GetStatusAsync(
 31093                    indexerName,
 31094                    cancellationToken)
 31095                    .ConfigureAwait(false);
 1096            }
 01097            catch (Exception ex)
 1098            {
 01099                scope.Failed(ex);
 01100                throw;
 1101            }
 31102        }
 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        {
 11116            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(ResetIn
 11117            scope.Start();
 1118            try
 1119            {
 11120                return IndexersClient.Reset(
 11121                    indexerName,
 11122                    cancellationToken);
 1123            }
 11124            catch (Exception ex)
 1125            {
 11126                scope.Failed(ex);
 11127                throw;
 1128            }
 01129        }
 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        {
 11143            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(ResetIn
 11144            scope.Start();
 1145            try
 1146            {
 11147                return await IndexersClient.ResetAsync(
 11148                    indexerName,
 11149                    cancellationToken)
 11150                    .ConfigureAwait(false);
 1151            }
 11152            catch (Exception ex)
 1153            {
 11154                scope.Failed(ex);
 11155                throw;
 1156            }
 01157        }
 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        {
 21171            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(RunInde
 21172            scope.Start();
 1173            try
 1174            {
 21175                return IndexersClient.Run(
 21176                    indexerName,
 21177                    cancellationToken);
 1178            }
 11179            catch (Exception ex)
 1180            {
 11181                scope.Failed(ex);
 11182                throw;
 1183            }
 11184        }
 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        {
 21198            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(RunInde
 21199            scope.Start();
 1200            try
 1201            {
 21202                return await IndexersClient.RunAsync(
 21203                    indexerName,
 21204                    cancellationToken)
 21205                    .ConfigureAwait(false);
 1206            }
 11207            catch (Exception ex)
 1208            {
 11209                scope.Failed(ex);
 11210                throw;
 1211            }
 11212        }
 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        {
 21231            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateS
 21232            scope.Start();
 1233            try
 1234            {
 21235                return SkillsetsClient.Create(
 21236                    skillset,
 21237                    cancellationToken);
 1238            }
 11239            catch (Exception ex)
 1240            {
 11241                scope.Failed(ex);
 11242                throw;
 1243            }
 11244        }
 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        {
 31261            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateS
 31262            scope.Start();
 1263            try
 1264            {
 31265                return await SkillsetsClient.CreateAsync(
 31266                    skillset,
 31267                    cancellationToken)
 31268                    .ConfigureAwait(false);
 1269            }
 11270            catch (Exception ex)
 1271            {
 11272                scope.Failed(ex);
 11273                throw;
 1274            }
 21275        }
 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.
 21298            Argument.AssertNotNull(skillset, nameof(skillset));
 1299
 11300            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 11301            scope.Start();
 1302            try
 1303            {
 11304                return SkillsetsClient.CreateOrUpdate(
 11305                    skillset?.Name,
 11306                    skillset,
 11307                    onlyIfUnchanged ? skillset?.ETag?.ToString() : null,
 11308                    null,
 11309                    cancellationToken);
 1310            }
 01311            catch (Exception ex)
 1312            {
 01313                scope.Failed(ex);
 01314                throw;
 1315            }
 11316        }
 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.
 21339            Argument.AssertNotNull(skillset, nameof(skillset));
 1340
 11341            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(CreateO
 11342            scope.Start();
 1343            try
 1344            {
 11345                return await SkillsetsClient.CreateOrUpdateAsync(
 11346                    skillset?.Name,
 11347                    skillset,
 11348                    onlyIfUnchanged ? skillset?.ETag?.ToString() : null,
 11349                    null,
 11350                    cancellationToken)
 11351                    .ConfigureAwait(false);
 1352            }
 01353            catch (Exception ex)
 1354            {
 01355                scope.Failed(ex);
 01356                throw;
 1357            }
 11358        }
 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.
 11373            Argument.AssertNotNull(skillsetName, nameof(skillsetName));
 1374
 01375            return DeleteSkillset(
 01376                skillsetName,
 01377                null,
 01378                false,
 01379                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.
 21395            Argument.AssertNotNull(skillsetName, nameof(skillsetName));
 1396
 11397            return await DeleteSkillsetAsync(
 11398                skillsetName,
 11399                null,
 11400                false,
 11401                cancellationToken)
 11402                .ConfigureAwait(false);
 11403        }
 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.
 21423            Argument.AssertNotNull(skillset, nameof(skillset));
 1424
 11425            return DeleteSkillset(
 11426                skillset?.Name,
 11427                skillset?.ETag,
 11428                onlyIfUnchanged,
 11429                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.
 21450            Argument.AssertNotNull(skillset, nameof(skillset));
 1451
 11452            return await DeleteSkillsetAsync(
 11453                skillset?.Name,
 11454                skillset?.ETag,
 11455                onlyIfUnchanged,
 11456                cancellationToken)
 11457                .ConfigureAwait(false);
 11458        }
 1459
 1460        private Response DeleteSkillset(
 1461            string skillsetName,
 1462            ETag? etag,
 1463            bool onlyIfUnchanged,
 1464            CancellationToken cancellationToken)
 1465        {
 11466            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteS
 11467            scope.Start();
 1468            try
 1469            {
 11470                return SkillsetsClient.Delete(
 11471                    skillsetName,
 11472                    onlyIfUnchanged ? etag?.ToString() : null,
 11473                    null,
 11474                    cancellationToken);
 1475            }
 01476            catch (Exception ex)
 1477            {
 01478                scope.Failed(ex);
 01479                throw;
 1480            }
 11481        }
 1482
 1483        private async Task<Response> DeleteSkillsetAsync(
 1484            string skillsetName,
 1485            ETag? etag,
 1486            bool onlyIfUnchanged,
 1487            CancellationToken cancellationToken)
 1488        {
 21489            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(DeleteS
 21490            scope.Start();
 1491            try
 1492            {
 21493                return await SkillsetsClient.DeleteAsync(
 21494                    skillsetName,
 21495                    onlyIfUnchanged ? etag?.ToString() : null,
 21496                    null,
 21497                    cancellationToken)
 21498                    .ConfigureAwait(false);
 1499            }
 01500            catch (Exception ex)
 1501            {
 01502                scope.Failed(ex);
 01503                throw;
 1504            }
 21505        }
 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        {
 21519            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 21520            scope.Start();
 1521            try
 1522            {
 21523                return SkillsetsClient.Get(
 21524                    skillsetName,
 21525                    cancellationToken);
 1526            }
 11527            catch (Exception ex)
 1528            {
 11529                scope.Failed(ex);
 11530                throw;
 1531            }
 11532        }
 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        {
 21546            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 21547            scope.Start();
 1548            try
 1549            {
 21550                return await SkillsetsClient.GetAsync(
 21551                    skillsetName,
 21552                    cancellationToken)
 21553                    .ConfigureAwait(false);
 1554            }
 11555            catch (Exception ex)
 1556            {
 11557                scope.Failed(ex);
 11558                throw;
 1559            }
 11560        }
 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        {
 01571            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 01572            scope.Start();
 1573            try
 1574            {
 01575                Response<ListSkillsetsResult> result = SkillsetsClient.List(
 01576                    Constants.All,
 01577                    cancellationToken);
 1578
 01579                return Response.FromValue(result.Value.Skillsets, result.GetRawResponse());
 1580            }
 01581            catch (Exception ex)
 1582            {
 01583                scope.Failed(ex);
 01584                throw;
 1585            }
 01586        }
 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        {
 01597            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 01598            scope.Start();
 1599            try
 1600            {
 01601                Response<ListSkillsetsResult> result = await SkillsetsClient.ListAsync(
 01602                    Constants.All,
 01603                    cancellationToken)
 01604                    .ConfigureAwait(false);
 1605
 01606                return Response.FromValue(result.Value.Skillsets, result.GetRawResponse());
 1607            }
 01608            catch (Exception ex)
 1609            {
 01610                scope.Failed(ex);
 01611                throw;
 1612            }
 01613        }
 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        {
 11624            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 11625            scope.Start();
 1626            try
 1627            {
 11628                Response<ListSkillsetsResult> result = SkillsetsClient.List(
 11629                    Constants.NameKey,
 11630                    cancellationToken);
 1631
 21632                IReadOnlyList<string> names = result.Value.Skillsets.Select(value => value.Name).ToArray();
 11633                return Response.FromValue(names, result.GetRawResponse());
 1634            }
 01635            catch (Exception ex)
 1636            {
 01637                scope.Failed(ex);
 01638                throw;
 1639            }
 11640        }
 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        {
 11651            using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(SearchIndexerClient)}.{nameof(GetSkil
 11652            scope.Start();
 1653            try
 1654            {
 11655                Response<ListSkillsetsResult> result = await SkillsetsClient.ListAsync(
 11656                    Constants.NameKey,
 11657                    cancellationToken)
 11658                    .ConfigureAwait(false);
 1659
 21660                IReadOnlyList<string> names = result.Value.Skillsets.Select(value => value.Name).ToArray();
 11661                return Response.FromValue(names, result.GetRawResponse());
 1662            }
 01663            catch (Exception ex)
 1664            {
 01665                scope.Failed(ex);
 01666                throw;
 1667            }
 11668        }
 1669        #endregion
 1670    }
 1671}