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
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ src/DataStax.AstraDB.DataApi/bin
src/DataStax.AstraDB.DataApi/obj
test/DataStax.AstraDB.DataApi.IntegrationTests/bin
test/DataStax.AstraDB.DataApi.IntegrationTests/obj
test/DataStax.AstraDB.DataApi.Tests/bin
test/DataStax.AstraDB.DataApi.Tests/obj
appsettings.json
test/DataStax.AstraDB.DataAPI.IntegrationTests/appsettings.sample.json
test/DataStax.AstraDB.DataApi.UnitTests/bin
test/DataStax.AstraDB.DataApi.UnitTests/obj
appsettings.json
27 changes: 25 additions & 2 deletions src/DataStax.AstraDB.DataApi/Admin/AstraDatabasesAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Core.Commands;
using DataStax.AstraDB.DataApi.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Admin;

Expand Down Expand Up @@ -45,9 +50,27 @@ public List<string> ListDatabaseNames()
return ListDatabases().Select(db => db.Info.Name).ToList();
}

public async Task<List<string>> ListDatabaseNamesAsync()
{
var databases = await ListDatabasesAsync().ConfigureAwait(false);
return databases.Select(db => db.Info.Name).ToList();
}

public List<DatabaseInfo> ListDatabases()
{
throw new NotImplementedException();
return ListDatabasesAsync(true).ResultSync();
}

public async Task<List<DatabaseInfo>> ListDatabasesAsync()
{
return await ListDatabasesAsync(false).ConfigureAwait(false);
}

internal async Task<List<DatabaseInfo>> ListDatabasesAsync(bool runSynchronously)
{
var command = CreateCommand().AddUrlPath("databases");
var response = await command.RunAsyncRaw<List<DatabaseInfo>>(HttpMethod.Get, runSynchronously).ConfigureAwait(false);
return response;
}

public bool DatabaseExists(string name)
Expand Down Expand Up @@ -139,7 +162,7 @@ internal async Task<DatabaseInfo> GetDatabaseInfoAsync(Guid id, bool runSynchron
{
Guard.NotEmpty(id, nameof(id));
var command = CreateCommand().AddUrlPath("databases").AddUrlPath(id.ToString());
var response = await command.RunAsyncRaw<DatabaseInfo>(System.Net.Http.HttpMethod.Get, runSynchronously).ConfigureAwait(false);
var response = await command.RunAsyncRaw<DatabaseInfo>(HttpMethod.Get, runSynchronously).ConfigureAwait(false);
return response;
}

Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Admin/IDatabaseAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Core.Results;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Admin;

Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Collections/Collection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
using DataStax.AstraDB.DataApi.Core;
using DataStax.AstraDB.DataApi.Core.Commands;
using DataStax.AstraDB.DataApi.Utils;
using System;
using System.Text.Json.Serialization;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Collections;

Expand Down
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Core/ApiData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using DataStax.AstraDB.DataApi.Collections;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace DataStax.AstraDB.DataApi.Core;
Expand Down
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Core/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace DataStax.AstraDB.DataApi.Core;
Expand Down
3 changes: 3 additions & 0 deletions src/DataStax.AstraDB.DataApi/Core/ApiVector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

using System;
using System.Linq;

namespace DataStax.AstraDB.DataApi.Core;

//TODO: placeholder
Expand Down
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Core/CommandOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

using DataStax.AstraDB.DataApi.Utils;
using System.Linq;

namespace DataStax.AstraDB.DataApi.Core;

Expand Down
6 changes: 5 additions & 1 deletion src/DataStax.AstraDB.DataApi/Core/Commands/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
*/

using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Core.Commands;

Expand All @@ -29,7 +33,7 @@ public class Command
private readonly DataApiClient _client;
private readonly CommandUrlBuilder _urlBuilder;
private readonly string _name;
private List<String> _urlPaths = new();
private List<string> _urlPaths = new();

internal object Payload { get; set; }
internal string UrlPostfix { get; set; }
Expand Down
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Core/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using DataStax.AstraDB.DataApi.Collections;
using DataStax.AstraDB.DataApi.Core.Commands;
using DataStax.AstraDB.DataApi.Utils;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Core;

Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Core/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* limitations under the License.
*/

using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi.Core;

public static class CoreExtensions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace DataStax.AstraDB.DataApi.Core.Results;

public class EmbeddingProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace DataStax.AstraDB.DataApi.Core.Results;

public class FindEmbeddingProvidersResult
Expand Down
1 change: 1 addition & 0 deletions src/DataStax.AstraDB.DataApi/Core/SerDes/DataSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

using System.Collections.Generic;
using System.Text.Json;

namespace DataStax.AstraDB.DataApi.Core.SerDes;
Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Core/SerDes/IDataSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace DataStax.AstraDB.DataApi.Core.SerDes;

public interface IDataSerializer
Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/DataAPIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Http;
using System.Net.Http;
using System;
using System.Threading.Tasks;

namespace DataStax.AstraDB.DataApi;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<TargetFrameworks>net462;netstandard2.1;net8.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<LangVersion>10.0</LangVersion>
</PropertyGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/HttpClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System;

namespace DataStax.AstraDB.DataApi;

public class HttpClientOptions
Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Utils/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace DataStax.AstraDB.DataApi.Utils;

public static class Extensions
Expand Down
2 changes: 2 additions & 0 deletions src/DataStax.AstraDB.DataApi/Utils/Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

using System;

namespace DataStax.AstraDB.DataApi.Utils;

public static class Guard
Expand Down
25 changes: 25 additions & 0 deletions test/DataStax.AstraDB.DataApi.IntegrationTests/Tests/AdminTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,29 @@ public async Task ConnectViaDbId()
database = fixture.Client.GetDatabase(dbId);
Assert.NotNull(database);
}

[Fact]
public async Task GetDatabasesList()
{
var list = await fixture.Client.GetAstraAdmin().ListDatabasesAsync();
Assert.NotNull(list);

list = fixture.Client.GetAstraAdmin().ListDatabases();
Assert.NotNull(list);

Console.WriteLine($"GetDatabasesList: {list.Count} items");
}

[Fact]
public async Task GetDatabasesNamesList()
{
var list = await fixture.Client.GetAstraAdmin().ListDatabaseNamesAsync();
Assert.NotNull(list);

list = fixture.Client.GetAstraAdmin().ListDatabaseNames();
Assert.NotNull(list);

Console.WriteLine($"GetDatabasesNamesList: {list.Count} items");
Console.WriteLine(string.Join(", ", list));
}
}