diff --git a/sdk/search/Azure.Search.Documents/src/Models/SynonymMap.cs b/sdk/search/Azure.Search.Documents/src/Models/SynonymMap.cs
index 5d7e3142056b0..1ea3da55e2b9c 100644
--- a/sdk/search/Azure.Search.Documents/src/Models/SynonymMap.cs
+++ b/sdk/search/Azure.Search.Documents/src/Models/SynonymMap.cs
@@ -2,9 +2,7 @@
// Licensed under the MIT License.
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Linq;
using Azure.Core;
namespace Azure.Search.Documents.Models
@@ -67,42 +65,5 @@ public ETag? ETag
get => _etag is null ? (ETag?)null : new ETag(_etag);
set => _etag = value?.ToString();
}
-
- ///
- /// Canonicalizes property names from how they appear on to those expected by the Search service.
- ///
- /// The given property names.
- /// Canonicalized property names expected by the Search service, or null if is null.
- internal static IEnumerable CanonicalizePropertyNames(IEnumerable names) =>
- // TODO: Replace when https://github.com/Azure/azure-sdk-for-net/issues/11393 is resolved.
- names?.Select(name =>
- {
- if (string.Equals("name", name, StringComparison.InvariantCultureIgnoreCase))
- {
- return "name";
- }
-
- if (string.Equals("format", name, StringComparison.InvariantCultureIgnoreCase))
- {
- return "format";
- }
-
- if (string.Equals("synonyms", name, StringComparison.InvariantCultureIgnoreCase))
- {
- return "synonyms";
- }
-
- if (string.Equals("encryptionKey", name, StringComparison.InvariantCultureIgnoreCase))
- {
- return "encryptionKey";
- }
-
- if (string.Equals("etag", name, StringComparison.InvariantCultureIgnoreCase))
- {
- return "@odata.etag";
- }
-
- return name;
- });
}
}
diff --git a/sdk/search/Azure.Search.Documents/src/SearchServiceClient.cs b/sdk/search/Azure.Search.Documents/src/SearchServiceClient.cs
index 5693073c3dff9..24fd186a2b7ca 100644
--- a/sdk/search/Azure.Search.Documents/src/SearchServiceClient.cs
+++ b/sdk/search/Azure.Search.Documents/src/SearchServiceClient.cs
@@ -8,6 +8,7 @@
using Azure.Core;
using Azure.Core.Pipeline;
using System.Collections.Generic;
+using System.Linq;
namespace Azure.Search.Documents
{
@@ -438,19 +439,17 @@ await DataSourcesClient.GetAsync(
///
/// Gets a list of all data sources.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual Response> GetDataSources(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = DataSourcesClient.List(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken);
@@ -460,25 +459,66 @@ public virtual Response> GetDataSources(
///
/// Gets a list of all data sources.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual async Task>> GetDataSourcesAsync(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = await DataSourcesClient.ListAsync(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
return Response.FromValue(result.Value.DataSources, result.GetRawResponse());
}
+
+ ///
+ /// Gets a list of all data source names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual Response> GetDataSourceNames(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = DataSourcesClient.List(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken);
+
+ IReadOnlyList names = result.Value.DataSources.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
+
+ ///
+ /// Gets a list of all data source names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual async Task>> GetDataSourceNamesAsync(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = await DataSourcesClient.ListAsync(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ IReadOnlyList names = result.Value.DataSources.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
#endregion
#region Index operations
@@ -734,14 +774,12 @@ await IndexesClient.GetAsync(
///
/// Gets a list of all indexes.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual Pageable GetIndexes(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default) => PageResponseEnumerator.CreateEnumerable((continuationToken) =>
{
@@ -751,7 +789,7 @@ public virtual Pageable GetIndexes(
}
Response result = IndexesClient.List(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken);
@@ -761,14 +799,12 @@ public virtual Pageable GetIndexes(
///
/// Gets a list of all indexes.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual AsyncPageable GetIndexesAsync(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default) => PageResponseEnumerator.CreateAsyncEnumerable(async (continuationToken) =>
{
@@ -778,7 +814,7 @@ public virtual AsyncPageable GetIndexesAsync(
}
Response result = await IndexesClient.ListAsync(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
@@ -786,13 +822,66 @@ public virtual AsyncPageable GetIndexesAsync(
return Page.FromValues(result.Value.Indexes, null, result.GetRawResponse());
});
+ ///
+ /// Gets a list of all index names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual Pageable GetIndexNames(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default) => PageResponseEnumerator.CreateEnumerable((continuationToken) =>
+ {
+ if (continuationToken != null)
+ {
+ throw new NotSupportedException("A continuation token is unexpected and unsupported at this time.");
+ }
+
+ Response result = IndexesClient.List(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken);
+
+ IReadOnlyList names = result.Value.Indexes.Select(value => value.Name).ToArray();
+ return Page.FromValues(names, null, result.GetRawResponse());
+ });
+
+ ///
+ /// Gets a list of all index names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual AsyncPageable GetIndexNamesAsync(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default) => PageResponseEnumerator.CreateAsyncEnumerable(async (continuationToken) =>
+ {
+ if (continuationToken != null)
+ {
+ throw new NotSupportedException("A continuation token is unexpected and unsupported at this time.");
+ }
+
+ Response result = await IndexesClient.ListAsync(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ IReadOnlyList names = result.Value.Indexes.Select(value => value.Name).ToArray();
+ return Page.FromValues(names, null, result.GetRawResponse());
+ });
+
///
/// Gets for the given index, including a document count and storage usage.
///
/// Required. The name of the index.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
- /// The from the server containing .
+ /// The from the server containing names.
/// Thrown when is null.
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
@@ -1008,19 +1097,17 @@ await IndexersClient.GetAsync(
///
/// Gets a list of all indexers.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual Response> GetIndexers(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = IndexersClient.List(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken);
@@ -1030,19 +1117,17 @@ public virtual Response> GetIndexers(
///
/// Gets a list of all indexers.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual async Task>> GetIndexersAsync(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = await IndexersClient.ListAsync(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
@@ -1050,6 +1135,49 @@ public virtual async Task>> GetIndexersAsy
return Response.FromValue(result.Value.Indexers, result.GetRawResponse());
}
+ ///
+ /// Gets a list of all indexer names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual Response> GetIndexerNames(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = IndexersClient.List(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken);
+
+ IReadOnlyList names = result.Value.Indexers.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
+
+ ///
+ /// Gets a list of all indexer names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual async Task>> GetIndexerNamesAsync(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = await IndexersClient.ListAsync(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ IReadOnlyList names = result.Value.Indexers.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
+
///
/// Gets the current status and execution history of an indexer.
///
@@ -1350,19 +1478,17 @@ await SkillsetsClient.GetAsync(
///
/// Gets a list of all skillsets.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual Response> GetSkillsets(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = SkillsetsClient.List(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken);
@@ -1372,25 +1498,66 @@ public virtual Response> GetSkillsets(
///
/// Gets a list of all skillsets.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual async Task>> GetSkillsetsAsync(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
Response result = await SkillsetsClient.ListAsync(
- selectProperties.CommaJoin() ?? Constants.All,
+ Constants.All,
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
return Response.FromValue(result.Value.Skillsets, result.GetRawResponse());
}
+
+ ///
+ /// Gets a list of all skillset names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual Response> GetSkillsetNames(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = SkillsetsClient.List(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken);
+
+ IReadOnlyList names = result.Value.Skillsets.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
+
+ ///
+ /// Gets a list of all skillset names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual async Task>> GetSkillsetNamesAsync(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = await SkillsetsClient.ListAsync(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ IReadOnlyList names = result.Value.Skillsets.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
#endregion
#region SynonymMaps operations
@@ -1595,21 +1762,17 @@ await SynonymMapsClient.GetAsync(
///
/// Gets a list of all synonym maps.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual Response> GetSynonymMaps(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
- string select = SynonymMap.CanonicalizePropertyNames(selectProperties).CommaJoin() ?? Constants.All;
-
Response result = SynonymMapsClient.List(
- select,
+ Constants.All,
options?.ClientRequestId,
cancellationToken);
@@ -1619,27 +1782,66 @@ public virtual Response> GetSynonymMaps(
///
/// Gets a list of all synonym maps.
///
- /// Optional property names to select. The default is all properties.
/// Optional to customize the operation's behavior.
/// Optional to propagate notifications that the operation should be canceled.
/// The from the server containing a list of .
/// Thrown when a failure is returned by the Search service.
[ForwardsClientCalls]
public virtual async Task>> GetSynonymMapsAsync(
- IEnumerable selectProperties = null,
SearchRequestOptions options = null,
CancellationToken cancellationToken = default)
{
- string select = SynonymMap.CanonicalizePropertyNames(selectProperties).CommaJoin() ?? Constants.All;
-
Response result = await SynonymMapsClient.ListAsync(
- select,
+ Constants.All,
options?.ClientRequestId,
cancellationToken)
.ConfigureAwait(false);
return Response.FromValue(result.Value.SynonymMaps, result.GetRawResponse());
}
+
+ ///
+ /// Gets a list of all synonym map names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual Response> GetSynonymMapNames(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = SynonymMapsClient.List(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken);
+
+ IReadOnlyList names = result.Value.SynonymMaps.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
+
+ ///
+ /// Gets a list of all synonym map names.
+ ///
+ /// Optional to customize the operation's behavior.
+ /// Optional to propagate notifications that the operation should be canceled.
+ /// The from the server containing a list of names.
+ /// Thrown when a failure is returned by the Search service.
+ [ForwardsClientCalls]
+ public virtual async Task>> GetSynonymMapNamesAsync(
+ SearchRequestOptions options = null,
+ CancellationToken cancellationToken = default)
+ {
+ Response result = await SynonymMapsClient.ListAsync(
+ Constants.NameKey,
+ options?.ClientRequestId,
+ cancellationToken)
+ .ConfigureAwait(false);
+
+ IReadOnlyList names = result.Value.SynonymMaps.Select(value => value.Name).ToArray();
+ return Response.FromValue(names, result.GetRawResponse());
+ }
#endregion
}
}
diff --git a/sdk/search/Azure.Search.Documents/src/Utilities/Constants.cs b/sdk/search/Azure.Search.Documents/src/Utilities/Constants.cs
index 8fc0a34e28a98..7ff64ebabc4fd 100644
--- a/sdk/search/Azure.Search.Documents/src/Utilities/Constants.cs
+++ b/sdk/search/Azure.Search.Documents/src/Utilities/Constants.cs
@@ -87,6 +87,11 @@ internal static class Constants
///
public const string ODataNextLinkKey = "@odata.nextLink";
+ ///
+ /// The name key.
+ ///
+ public const string NameKey = "name";
+
///
/// The value key.
///
diff --git a/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs b/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs
index af4d80a7782ed..bfe784649a717 100644
--- a/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs
+++ b/sdk/search/Azure.Search.Documents/tests/Models/SynonymMapTests.cs
@@ -2,7 +2,6 @@
// Licensed under the MIT License.
using System;
-using System.Collections.Generic;
using System.IO;
using Azure.Search.Documents.Models;
using NUnit.Framework;
@@ -49,38 +48,6 @@ public void SynonymsFromTextReader()
Assert.AreEqual("ms,msft=>Microsoft\naz=>Azure", map.Synonyms);
}
- [Test]
- public void CanonicalizesNullPropertyNames()
- {
- Assert.IsNull(SynonymMap.CanonicalizePropertyNames(null));
- }
-
- [Test]
- public void CanonicalizesPropertyNames()
- {
- IEnumerable actual = SynonymMap.CanonicalizePropertyNames(new[]
- {
- nameof(SynonymMap.Name),
- nameof(SynonymMap.Format),
- nameof(SynonymMap.Synonyms),
- nameof(SynonymMap.EncryptionKey),
- nameof(SynonymMap.ETag),
- "Other",
- });
-
- IEnumerable expected = new[]
- {
- "name",
- "format",
- "synonyms",
- "encryptionKey",
- "@odata.etag",
- "Other",
- };
-
- CollectionAssert.AreEqual(expected, actual);
- }
-
[TestCase(null, null)]
[TestCase("*", "*")]
[TestCase("\"0123abcd\"", "\"0123abcd\"")]
diff --git a/sdk/search/Azure.Search.Documents/tests/SearchServiceClientTests.cs b/sdk/search/Azure.Search.Documents/tests/SearchServiceClientTests.cs
index 03212b5e7c70d..646e876f556ff 100644
--- a/sdk/search/Azure.Search.Documents/tests/SearchServiceClientTests.cs
+++ b/sdk/search/Azure.Search.Documents/tests/SearchServiceClientTests.cs
@@ -370,12 +370,12 @@ await client.CreateOrUpdateSynonymMapAsync(
onlyIfUnchanged: true));
Assert.AreEqual((int)HttpStatusCode.PreconditionFailed, ex.Status);
- Response> mapsResponse = await client.GetSynonymMapsAsync(new[] { nameof(SynonymMap.Name) });
- foreach (SynonymMap namedMap in mapsResponse.Value)
+ Response> names = await client.GetSynonymMapNamesAsync();
+ foreach (string name in names.Value)
{
- if (string.Equals(updatedMap.Name, namedMap.Name, StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(updatedMap.Name, name, StringComparison.OrdinalIgnoreCase))
{
- SynonymMap fetchedMap = await client.GetSynonymMapAsync(namedMap.Name);
+ SynonymMap fetchedMap = await client.GetSynonymMapAsync(name);
Assert.AreEqual(updatedMap.Synonyms, fetchedMap.Synonyms);
}
}