Skip to content
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

101 changes: 44 additions & 57 deletions sdk/search/Azure.Search.Documents/src/Generated/IndexersRestClient.cs

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

113 changes: 3 additions & 110 deletions sdk/search/Azure.Search.Documents/src/Indexes/SearchIndexClient.cs

Large diffs are not rendered by default.

159 changes: 3 additions & 156 deletions sdk/search/Azure.Search.Documents/src/Indexes/SearchIndexerClient.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.Search.Documents
/// </summary>
[CodeGenModel("AutocompleteRequest")]
[CodeGenSuppress(nameof(AutocompleteOptions), typeof(string), typeof(string))]
public partial class AutocompleteOptions : SearchRequestOptions
public partial class AutocompleteOptions
{
/// <summary>
/// Initializes new instance of <see cref="AutocompleteOptions"/>
Expand Down Expand Up @@ -98,7 +98,6 @@ internal AutocompleteOptions Clone() =>
HighlightPreTag = HighlightPreTag,
MinimumCoverage = MinimumCoverage,
UseFuzzyMatching = UseFuzzyMatching,
ClientRequestId = ClientRequestId
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Azure.Search.Documents
/// <summary>
/// Options for <see cref="SearchClient.GetDocumentAsync"/>.
/// </summary>
public class GetDocumentOptions : SearchRequestOptions
public class GetDocumentOptions
{
/// <summary>
/// A list of field names to retrieve. Only fields marked as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Azure.Search.Documents
/// <summary>
/// Options for <see cref="SearchClient.IndexDocumentsAsync(Models.IndexDocumentsBatch{Models.SearchDocument}, IndexDocumentsOptions, System.Threading.CancellationToken)"/>.
/// </summary>
public class IndexDocumentsOptions : SearchRequestOptions
public class IndexDocumentsOptions
{
/// <summary>
/// Gets or sets a value indicating whether to throw an exception on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace Azure.Search.Documents
/// query behaviors.
/// </summary>
[CodeGenModel("SearchRequest")]
public partial class SearchOptions : SearchRequestOptions
public partial class SearchOptions
{
/// <summary>
/// Initializes a new instance of SearchOptions from a continuation
Expand Down Expand Up @@ -189,7 +189,6 @@ private static void Copy(SearchOptions source, SearchOptions destination)
destination.ScoringProfile = source.ScoringProfile;
destination.SearchMode = source.SearchMode;
destination.Skip = source.Skip;
destination.ClientRequestId = source.ClientRequestId;
}

/// <summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Azure.Search.Documents
/// </summary>
[CodeGenModel("SuggestRequest")]
[CodeGenSuppress(nameof(SuggestOptions), typeof(string), typeof(string))]
public partial class SuggestOptions : SearchRequestOptions
public partial class SuggestOptions
{
/// <summary>
/// Initializes new instance of <see cref="SuggestOptions"/>
Expand Down Expand Up @@ -131,7 +131,6 @@ internal SuggestOptions Clone() =>
HighlightPreTag = HighlightPreTag,
MinimumCoverage = MinimumCoverage,
UseFuzzyMatching = UseFuzzyMatching,
ClientRequestId = ClientRequestId
};
}
}
26 changes: 7 additions & 19 deletions sdk/search/Azure.Search.Documents/src/SearchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ public SearchClient(
Pipeline,
endpoint.ToString(),
IndexName,
null,
Version.ToVersionString());
}

Expand Down Expand Up @@ -220,6 +221,7 @@ internal SearchClient(
Pipeline,
endpoint.ToString(),
IndexName,
null,
Version.ToVersionString());
}
#endregion ctors
Expand All @@ -228,9 +230,6 @@ internal SearchClient(
/// <summary>
/// Retrieves a count of the number of documents in this search index.
/// </summary>
/// <param name="options">
/// Options to customize the operation's behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate notifications
/// that the operation should be canceled.
Expand All @@ -240,15 +239,13 @@ internal SearchClient(
/// Thrown when a failure is returned by the Search Service.
/// </exception>
public virtual Response<long> GetDocumentCount(
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(SearchClient)}.{nameof(GetDocumentCount)}");
scope.Start();
try
{
return Protocol.Count(
options?.ClientRequestId,
cancellationToken);
}
catch (Exception ex)
Expand All @@ -261,9 +258,6 @@ public virtual Response<long> GetDocumentCount(
/// <summary>
/// Retrieves a count of the number of documents in this search index.
/// </summary>
/// <param name="options">
/// Options to customize the operation's behavior.
/// </param>
/// <param name="cancellationToken">
/// Optional <see cref="CancellationToken"/> to propagate notifications
/// that the operation should be canceled.
Expand All @@ -273,15 +267,13 @@ public virtual Response<long> GetDocumentCount(
/// Thrown when a failure is returned by the Search Service.
/// </exception>
public virtual async Task<Response<long>> GetDocumentCountAsync(
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
using DiagnosticScope scope = ClientDiagnostics.CreateScope($"{nameof(SearchClient)}.{nameof(GetDocumentCount)}");
scope.Start();
try
{
return await Protocol.CountAsync(
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
}
Expand Down Expand Up @@ -680,7 +672,7 @@ private async Task<Response<T>> GetDocumentInternal<T>(
scope.Start();
try
{
using HttpMessage message = Protocol.CreateGetRequest(key, options?.SelectedFieldsOrNull, options?.ClientRequestId);
using HttpMessage message = Protocol.CreateGetRequest(key, options?.SelectedFieldsOrNull);
if (async)
{
await Pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -961,7 +953,7 @@ private async Task<Response<SearchResults<T>>> SearchInternal<T>(
scope.Start();
try
{
using HttpMessage message = Protocol.CreateSearchPostRequest(options, options.ClientRequestId);
using HttpMessage message = Protocol.CreateSearchPostRequest(options);
if (async)
{
await Pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -1229,7 +1221,7 @@ private async Task<Response<SuggestResults<T>>> SuggestInternal<T>(
scope.Start();
try
{
using HttpMessage message = Protocol.CreateSuggestPostRequest(options, options.ClientRequestId);
using HttpMessage message = Protocol.CreateSuggestPostRequest(options);
if (async)
{
await Pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
Expand Down Expand Up @@ -1372,8 +1364,8 @@ private async Task<Response<AutocompleteResults>> AutocompleteInternal(
options.SuggesterName = suggesterName;

return async ?
await Protocol.AutocompletePostAsync(options, options.ClientRequestId, cancellationToken).ConfigureAwait(false) :
Protocol.AutocompletePost(options, options.ClientRequestId, cancellationToken);
await Protocol.AutocompletePostAsync(options, cancellationToken).ConfigureAwait(false) :
Protocol.AutocompletePost(options, cancellationToken);
}
#endregion Autocomplete

Expand Down Expand Up @@ -1607,10 +1599,6 @@ private async Task<Response<IndexDocumentsResult>> IndexDocumentsInternal<T>(
uri.AppendPath("/docs/search.index", false);
uri.AppendQuery("api-version", Version.ToVersionString(), true);
request.Uri = uri;
if (options?.ClientRequestId != null)
{
request.ClientRequestId = options?.ClientRequestId.ToString();
}
request.Headers.Add("Accept", "application/json; odata.metadata=none");
request.Headers.Add("Content-Type", "application/json");
using Utf8JsonRequestContent content = new Utf8JsonRequestContent();
Expand Down
13 changes: 13 additions & 0 deletions sdk/search/Azure.Search.Documents/src/autorest.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,16 @@ directive:
transform: >
$["x-namespace"] = "Azure.Search.Documents.Indexes.Models"
```

### Relocate x-ms-client-request-id parameter

Remove the `x-ms-client-request-id` parameter from all methods and put it on the client.
This will be later removed when https://github.com/Azure/autorest.csharp/issues/782 is resolved.
Several attempts at just removing the parameter have caused downstream issues, so relocating it for now.

```yaml
directive:
from: swagger-document
where: $.parameters.ClientRequestIdParameter
transform: $["x-ms-parameter-location"] = "client";
```
12 changes: 0 additions & 12 deletions sdk/search/Azure.Search.Documents/tests/SearchClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ public void Constructor()
Assert.Throws<ArgumentException>(() => new SearchClient(new Uri("http://bing.com"), indexName, null));
}

[Test]
public async Task ClientRequestIdRountrips()
{
await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this);
SearchClient client = resources.GetSearchClient();
Guid id = Recording.Random.NewGuid();
Response<long> response = await client.GetDocumentCountAsync(
new SearchRequestOptions { ClientRequestId = id });

Assert.AreEqual(id.ToString(), response.GetRawResponse().ClientRequestId);
}

[Test]
public async Task GetDocumentCount()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,6 @@ public async Task IndexSharesPipeline()
Assert.AreEqual(1, custom.RequestCount);
}

[Test]
public async Task ClientRequestIdRountrips()
{
await using SearchResources resources = await SearchResources.GetSharedHotelsIndexAsync(this);
SearchIndexClient client = resources.GetIndexClient();
Guid id = Recording.Random.NewGuid();
Response<SearchServiceStatistics> response =
await client.GetServiceStatisticsAsync(
new SearchRequestOptions { ClientRequestId = id });

Assert.AreEqual(id.ToString(), response.GetRawResponse().ClientRequestId);
}

[Test]
public void DiagnosticsAreUnique()
{
Expand Down Expand Up @@ -211,8 +198,7 @@ public async Task UpdateIndex()
SearchIndex updatedIndex = await client.CreateOrUpdateIndexAsync(
createdIndex,
allowIndexDowntime: true,
onlyIfUnchanged: true,
options: new SearchRequestOptions { ClientRequestId = Recording.Random.NewGuid() });
onlyIfUnchanged: true);

Assert.AreEqual(createdIndex.Name, updatedIndex.Name);
Assert.That(updatedIndex.Fields, Is.EqualTo(updatedIndex.Fields).Using(SearchFieldComparer.Shared));
Expand Down
Loading