-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
DataSourcesOperationsExtensions.Customization.cs
125 lines (120 loc) · 5.37 KB
/
DataSourcesOperationsExtensions.Customization.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for
// license information.
namespace Microsoft.Azure.Search
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Search.Models;
using Microsoft.Rest.Azure;
/// <summary>
/// Operations for managing datasources.
/// <see href="https://docs.microsoft.com/rest/api/searchservice/Indexer-operations" />
/// </summary>
public static partial class DataSourcesOperationsExtensions
{
/// <summary>
/// Creates a new datasource or updates a datasource if it already
/// exists.
/// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Data-Source" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation.
/// </param>
/// <param name='accessCondition'>
/// Additional parameters for the operation.
/// </param>
/// <returns>
/// The datasource that was created or updated.
/// </returns>
public static DataSource CreateOrUpdate(this IDataSourcesOperations operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition))
{
return operations.CreateOrUpdateAsync(dataSource, searchRequestOptions, accessCondition).GetAwaiter().GetResult();
}
/// <summary>
/// Creates a new datasource or updates a datasource if it already
/// exists.
/// <see href="https://docs.microsoft.com/rest/api/searchservice/Update-Data-Source" />
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='dataSource'>
/// The definition of the datasource to create or update.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation
/// </param>
/// <param name='accessCondition'>
/// Additional parameters for the operation
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <returns>
/// The datasource that was created or updated.
/// </returns>
public static async Task<DataSource> CreateOrUpdateAsync(this IDataSourcesOperations operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(dataSource, searchRequestOptions, accessCondition, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
}
/// <summary>
/// Determines whether or not the given data source exists in the search service.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name="dataSourceName">
/// The name of the data source.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation.
/// </param>
/// <returns>
/// <c>true</c> if the data source exists; <c>false</c> otherwise.
/// </returns>
public static bool Exists(
this IDataSourcesOperations operations,
string dataSourceName,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return operations.ExistsAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult();
}
/// <summary>
/// Determines whether or not the given data source exists in the search service.
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name="dataSourceName">
/// The name of the data source.
/// </param>
/// <param name='searchRequestOptions'>
/// Additional parameters for the operation.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
/// <returns>
/// <c>true</c> if the data source exists; <c>false</c> otherwise.
/// </returns>
public static async Task<bool> ExistsAsync(
this IDataSourcesOperations operations,
string dataSourceName,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions),
CancellationToken cancellationToken = default(CancellationToken))
{
AzureOperationResponse<bool> result = await operations.ExistsWithHttpMessagesAsync(dataSourceName, searchRequestOptions, null, cancellationToken).ConfigureAwait(false);
return result.Body;
}
}
}