Skip to content

Commit e4d0f9d

Browse files
a-random-stevestephenatsembitjeffrey-elliottamorton
authored
Documentation feedback (#20)
Co-authored-by: Stephen Hewitt <[email protected]> Co-authored-by: jeffrey-elliott <[email protected]> Co-authored-by: Steve Hewitt <[email protected]> Co-authored-by: Aaron Morton <[email protected]>
1 parent 4cf0999 commit e4d0f9d

File tree

19 files changed

+791
-304
lines changed

19 files changed

+791
-304
lines changed

src/DataStax.AstraDB.DataApi/Core/Commands/Command.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private async Task<T> RunCommandAsync<T>(HttpMethod method, bool runSynchronousl
326326
responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
327327
MaybeLogDebugMessage("Response Status Code: {StatusCode}", response.StatusCode);
328328
MaybeLogDebugMessage("Content: {Content}", responseContent);
329-
throw new HttpRequestException($"Request to failed with status code {response.StatusCode}.");
329+
throw new HttpRequestException($"Request failed with status code {response.StatusCode}.");
330330
}
331331
}
332332
responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

src/DataStax.AstraDB.DataApi/Core/Database.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ private async Task<IEnumerable<TableInfo>> ListTablesAsync(DatabaseCommandOption
905905
/// Synchronous version of <see cref="ListTableNamesAsync()"/>
906906
/// </summary>
907907
/// <returns></returns>
908-
public IEnumerable<string> ListTableNames()
908+
public List<string> ListTableNames()
909909
{
910910
return ListTableNames(null);
911911
}
@@ -915,7 +915,7 @@ public IEnumerable<string> ListTableNames()
915915
/// </summary>
916916
/// <param name="options">The options to use for the command, useful for overriding the keyspace, for example.</param>
917917
/// <returns></returns>
918-
public IEnumerable<string> ListTableNames(DatabaseCommandOptions options)
918+
public List<string> ListTableNames(DatabaseCommandOptions options)
919919
{
920920
return ListTableNamesAsync(options, true, true).ResultSync();
921921
}
@@ -924,7 +924,7 @@ public IEnumerable<string> ListTableNames(DatabaseCommandOptions options)
924924
/// List the tables in the database.
925925
/// </summary>
926926
/// <returns></returns>
927-
public Task<IEnumerable<string>> ListTableNamesAsync()
927+
public Task<List<string>> ListTableNamesAsync()
928928
{
929929
return ListTableNamesAsync(null);
930930
}
@@ -934,12 +934,12 @@ public Task<IEnumerable<string>> ListTableNamesAsync()
934934
/// </summary>
935935
/// <param name="options">The options to use for the command, useful for overriding the keyspace, for example.</param>
936936
/// <returns></returns>
937-
public Task<IEnumerable<string>> ListTableNamesAsync(DatabaseCommandOptions options)
937+
public Task<List<string>> ListTableNamesAsync(DatabaseCommandOptions options)
938938
{
939939
return ListTableNamesAsync(options, true, false);
940940
}
941941

942-
private async Task<IEnumerable<string>> ListTableNamesAsync(DatabaseCommandOptions options, bool includeDetails, bool runSynchronously)
942+
private async Task<List<string>> ListTableNamesAsync(DatabaseCommandOptions options, bool includeDetails, bool runSynchronously)
943943
{
944944
var payload = new
945945
{

src/DataStax.AstraDB.DataApi/Core/Query/DocumentFindOptions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ namespace DataStax.AstraDB.DataApi.Core.Query;
2020

2121
public class DocumentFindOptions<T> : FindOptions<T, DocumentSortBuilder<T>>
2222
{
23+
/// <summary>
24+
/// The sort to apply when running the query.
25+
/// </summary>
2326
[JsonIgnore]
2427
public override DocumentSortBuilder<T> Sort { get; set; }
28+
2529
}

src/DataStax.AstraDB.DataApi/Core/Query/FindOptions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ public abstract class FindOptions<T, TSort> : IFindOptions<T, TSort> where TSort
2525
[JsonIgnore]
2626
public IProjectionBuilder Projection { get; set; }
2727

28-
internal bool? IncludeSimilarity { get; set; }
28+
/// <summary>
29+
/// Whether to include a similarity score in the results or not (when performing a vector sort).
30+
/// </summary>
31+
[JsonIgnore]
32+
public bool? IncludeSimilarity { get; set; }
2933

3034
protected bool? _includeSortVector;
3135

src/DataStax.AstraDB.DataApi/Core/Results/ListTableNamesResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17+
using System.Collections.Generic;
1718
using System.Text.Json.Serialization;
1819

1920
namespace DataStax.AstraDB.DataApi.Core.Results;
@@ -24,8 +25,8 @@ namespace DataStax.AstraDB.DataApi.Core.Results;
2425
public class ListTableNamesResult
2526
{
2627
/// <summary>
27-
/// An array of table names.
28+
/// The list of table names.
2829
/// </summary>
2930
[JsonPropertyName("tables")]
30-
public string[] Tables { get; set; }
31+
public List<string> Tables { get; set; }
3132
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright DataStax, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using DataStax.AstraDB.DataApi.Core.Query;
18+
using System.Collections.Generic;
19+
using System.Linq;
20+
using System.Text.Json.Serialization;
21+
22+
namespace DataStax.AstraDB.DataApi.Core;
23+
24+
/// <summary>
25+
/// Options for deleting a row from a table
26+
/// </summary>
27+
/// <typeparam name="T"></typeparam>
28+
public class TableDeleteOptions<T> where T : class
29+
{
30+
internal Filter<T> Filter { get; set; }
31+
32+
[JsonInclude]
33+
[JsonPropertyName("filter")]
34+
internal Dictionary<string, object> FilterMap => Filter == null ? new Dictionary<string, object>() : Filter.Serialize();
35+
}

src/DataStax.AstraDB.DataApi/DataStax.AstraDB.DataApi.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1919
<PackageIcon>packageIcon.png</PackageIcon>
2020
<PackageReadmeFile>README.md</PackageReadmeFile>
21+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
2122
</PropertyGroup>
2223

2324
<ItemGroup>

src/DataStax.AstraDB.DataApi/SerDes/TableInsertManyResultConverter.cs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,33 @@
1414
* limitations under the License.
1515
*/
1616

17+
using DataStax.AstraDB.DataApi.Core.Results;
18+
using DataStax.AstraDB.DataApi.Tables;
1719
using System;
1820
using System.Collections.Generic;
1921
using System.Linq;
2022
using System.Text.Json;
2123
using System.Text.Json.Serialization;
22-
using DataStax.AstraDB.DataApi.Core.Results;
23-
using DataStax.AstraDB.DataApi.Tables;
2424

2525
namespace DataStax.AstraDB.DataApi.SerDes;
2626

27-
public class TableInsertManyResultConverter : JsonConverter<TableInsertManyResult>
27+
internal class TableInsertOneResultConverter : TableInsertResultConverter<TableInsertOneResult>
2828
{
29-
public override TableInsertManyResult Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
29+
}
30+
31+
internal class TableInsertManyResultConverter : TableInsertResultConverter<TableInsertManyResult>
32+
{
33+
}
34+
35+
internal class TableInsertResultConverter<T> : JsonConverter<T> where T : TableInsertManyResult, new()
36+
{
37+
38+
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
3039
{
3140
if (reader.TokenType != JsonTokenType.StartObject)
3241
throw new JsonException("Expected StartObject token");
3342

34-
var result = new TableInsertManyResult();
43+
var result = new T();
3544
JsonDocument insertedIdsDoc = null;
3645
JsonDocument documentResponsesDoc = null;
3746

@@ -207,7 +216,7 @@ private object DeserializeValue(JsonElement element, PrimaryKeySchema schema, Js
207216
}
208217
}
209218

210-
public override void Write(Utf8JsonWriter writer, TableInsertManyResult value, JsonSerializerOptions options)
219+
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
211220
{
212221
throw new NotSupportedException("Serialization is not implemented for TableInsertManyResult");
213222
}

0 commit comments

Comments
 (0)