Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Azure Search] Merge 4.x preview code to psSdkJson6 branch and bump version #4062

Merged
merged 12 commits into from
Feb 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static partial class DataSourcesOperationsExtensions
/// </param>
public static DataSource CreateOrUpdate(this IDataSourcesOperations operations, DataSource dataSource, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition))
{
return Task.Factory.StartNew(s => ((IDataSourcesOperations)s).CreateOrUpdateAsync(dataSource, searchRequestOptions, accessCondition), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.CreateOrUpdateAsync(dataSource, searchRequestOptions, accessCondition).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -83,7 +83,7 @@ public static bool Exists(
string dataSourceName,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDataSourcesOperations)s).ExistsAsync(dataSourceName, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.ExistsAsync(dataSourceName, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,19 @@ private async Task<AzureOperationResponse<T>> DoGetWithHttpMessagesAsync<T>(
CancellationToken cancellationToken,
JsonSerializerSettings jsonSerializerSettings) where T : class
{
if (this.Client.ApiVersion == null)
if (Client.SearchServiceName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
}
if (Client.SearchDnsSuffix == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
}
if (Client.IndexName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName");
}
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
Expand Down Expand Up @@ -506,8 +518,11 @@ private async Task<AzureOperationResponse<T>> DoGetWithHttpMessagesAsync<T>(

string selectClause = selectedFields.ToCommaSeparatedString();

var baseUrl = this.Client.BaseUri.AbsoluteUri;
var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "docs('{key}')").ToString();
var baseUrl = Client.BaseUri;
var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "docs('{key}')";
url = url.Replace("{searchServiceName}", Client.SearchServiceName);
url = url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
url = url.Replace("{indexName}", Client.IndexName);
url = url.Replace("{key}", Uri.EscapeDataString(key));
List<string> queryParameters = new List<string>();
if (this.Client.ApiVersion != null)
Expand Down Expand Up @@ -654,7 +669,19 @@ private async Task<AzureOperationResponse<DocumentIndexResult>> DoIndexWithHttpM
Dictionary<string, List<string>> customHeaders,
CancellationToken cancellationToken)
{
if (this.Client.ApiVersion == null)
if (Client.SearchServiceName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
}
if (Client.SearchDnsSuffix == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
}
if (Client.IndexName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName");
}
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
Expand Down Expand Up @@ -683,9 +710,11 @@ private async Task<AzureOperationResponse<DocumentIndexResult>> DoIndexWithHttpM
}

// Construct URL
var baseUrl = this.Client.BaseUri.AbsoluteUri;
var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "docs/search.index").ToString();

var baseUrl = Client.BaseUri;
var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + "docs/search.index";
url = url.Replace("{searchServiceName}", Client.SearchServiceName);
url = url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
url = url.Replace("{indexName}", Client.IndexName);
List<string> queryParameters = new List<string>();
if (this.Client.ApiVersion != null)
{
Expand Down Expand Up @@ -866,7 +895,19 @@ private Task<AzureOperationResponse<TSearchResult>> DoSearchWithHttpMessagesAsyn
where TDoc : class
{
// Validate
if (this.Client.ApiVersion == null)
if (Client.SearchServiceName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
}
if (Client.SearchDnsSuffix == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
}
if (Client.IndexName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName");
}
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
Expand Down Expand Up @@ -899,12 +940,11 @@ private Task<AzureOperationResponse<TSearchResult>> DoSearchWithHttpMessagesAsyn

// Construct URL
bool useGet = Client.UseHttpGetForQueries;
var baseUrl = this.Client.BaseUri.AbsoluteUri;
var url =
new Uri(
new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")),
(useGet ? "docs" : "docs/search.post.search")).ToString();

var baseUrl = Client.BaseUri;
var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + (useGet ? "docs" : "docs/search.post.search");
url = url.Replace("{searchServiceName}", Client.SearchServiceName);
url = url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
url = url.Replace("{indexName}", Client.IndexName);
List<string> queryParameters = new List<string>();
if (this.Client.ApiVersion != null)
{
Expand Down Expand Up @@ -945,7 +985,19 @@ private async Task<AzureOperationResponse<TSuggestResult>> DoSuggestWithHttpMess
where TDoc : class
{
// Validate
if (this.Client.ApiVersion == null)
if (Client.SearchServiceName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchServiceName");
}
if (Client.SearchDnsSuffix == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.SearchDnsSuffix");
}
if (Client.IndexName == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.IndexName");
}
if (Client.ApiVersion == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.ApiVersion");
}
Expand Down Expand Up @@ -987,12 +1039,11 @@ private async Task<AzureOperationResponse<TSuggestResult>> DoSuggestWithHttpMess

// Construct URL
bool useGet = Client.UseHttpGetForQueries;
var baseUrl = this.Client.BaseUri.AbsoluteUri;
var url =
new Uri(
new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")),
(useGet ? "docs/search.suggest" : "docs/search.post.suggest")).ToString();

var baseUrl = Client.BaseUri;
var url = baseUrl + (baseUrl.EndsWith("/") ? "" : "/") + (useGet ? "docs/search.suggest" : "docs/search.post.suggest");
url = url.Replace("{searchServiceName}", Client.SearchServiceName);
url = url.Replace("{searchDnsSuffix}", Client.SearchDnsSuffix);
url = url.Replace("{indexName}", Client.IndexName);
List<string> queryParameters = new List<string>();
if (this.Client.ApiVersion != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static long Count(
this IDocumentsOperations operations,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).CountAsync(searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.CountAsync(searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -98,7 +98,7 @@ public static DocumentSearchResult ContinueSearch(
SearchContinuationToken continuationToken,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).ContinueSearchAsync(continuationToken, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.ContinueSearchAsync(continuationToken, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -199,7 +199,7 @@ public static DocumentSearchResult<T> ContinueSearch<T>(
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
where T : class
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).ContinueSearchAsync<T>(continuationToken, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.ContinueSearchAsync<T>(continuationToken, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -290,7 +290,7 @@ public static Document Get(
IEnumerable<string> selectedFields = null,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).GetAsync(key, selectedFields, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.GetAsync(key, selectedFields, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -375,7 +375,7 @@ public static T Get<T>(
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
where T : class
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).GetAsync<T>(key, selectedFields, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.GetAsync<T>(key, selectedFields, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -460,7 +460,7 @@ public static DocumentIndexResult Index(
IndexBatch batch,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).IndexAsync(batch, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.IndexAsync(batch, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -545,7 +545,7 @@ public static DocumentIndexResult Index<T>(
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
where T : class
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).IndexAsync<T>(batch, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.IndexAsync<T>(batch, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -635,7 +635,7 @@ public static DocumentSearchResult Search(
SearchParameters searchParameters = null,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).SearchAsync(searchText, searchParameters, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.SearchAsync(searchText, searchParameters, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -733,7 +733,7 @@ public static DocumentSearchResult<T> Search<T>(
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
where T : class
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).SearchAsync<T>(searchText, searchParameters, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.SearchAsync<T>(searchText, searchParameters, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -824,7 +824,7 @@ public static DocumentSuggestResult Suggest(
SuggestParameters suggestParameters = null,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).SuggestAsync(searchText, suggesterName, suggestParameters, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.SuggestAsync(searchText, suggesterName, suggestParameters, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -910,7 +910,7 @@ public static DocumentSuggestResult<T> Suggest<T>(
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
where T : class
{
return Task.Factory.StartNew(s => ((IDocumentsOperations)s).SuggestAsync<T>(searchText, suggesterName, suggestParameters, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.SuggestAsync<T>(searchText, suggesterName, suggestParameters, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static partial class IndexersOperationsExtensions
/// </param>
public static Indexer CreateOrUpdate(this IIndexersOperations operations, Indexer indexer, SearchRequestOptions searchRequestOptions = default(SearchRequestOptions), AccessCondition accessCondition = default(AccessCondition))
{
return Task.Factory.StartNew(s => ((IIndexersOperations)s).CreateOrUpdateAsync(indexer, searchRequestOptions, accessCondition), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.CreateOrUpdateAsync(indexer, searchRequestOptions, accessCondition).GetAwaiter().GetResult();
}

/// <summary>
Expand Down Expand Up @@ -83,7 +83,7 @@ public static bool Exists(
string indexerName,
SearchRequestOptions searchRequestOptions = default(SearchRequestOptions))
{
return Task.Factory.StartNew(s => ((IIndexersOperations)s).ExistsAsync(indexerName, searchRequestOptions), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
return operations.ExistsAsync(indexerName, searchRequestOptions).GetAwaiter().GetResult();
}

/// <summary>
Expand Down
Loading