diff --git a/.circleci/config.yml b/.circleci/config.yml index 1a926e0f..80ce1bbf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -61,7 +61,7 @@ jobs: - run: name: Test command: - dotnet test -c Release --filter "Feature!=StreamTransaction&RunningMode!=Cluster&Feature!=Analyzer" + dotnet test -c Release --filter "Feature!=StreamTransaction&RunningMode!=Cluster&Feature!=Analyzer&ServerVersion!=3_8_PLUS" "test-arangodb-3_5": working_directory: ~/arangodb-net-standard @@ -80,7 +80,7 @@ jobs: - run: name: Test command: - dotnet test -c Release --filter "RunningMode!=Cluster" + dotnet test -c Release --filter "RunningMode!=Cluster&ServerVersion!=3_8_PLUS" "test-arangodb-3_6": working_directory: ~/arangodb-net-standard @@ -99,7 +99,7 @@ jobs: - run: name: Test command: - dotnet test -c Release --filter "RunningMode!=Cluster" + dotnet test -c Release --filter "RunningMode!=Cluster&ServerVersion!=3_8_PLUS" "test-arangodb-3_7": working_directory: ~/arangodb-net-standard @@ -118,7 +118,7 @@ jobs: - run: name: Test command: - dotnet test -c Release --filter RunningMode!=Cluster + dotnet test -c Release --filter "RunningMode!=Cluster&ServerVersion!=3_8_PLUS" "test-arangodb-3_8": working_directory: ~/arangodb-net-standard diff --git a/arangodb-net-standard.Test/AdminApi/AdminApiClientTest.cs b/arangodb-net-standard.Test/AdminApi/AdminApiClientTest.cs new file mode 100644 index 00000000..1dadb9d7 --- /dev/null +++ b/arangodb-net-standard.Test/AdminApi/AdminApiClientTest.cs @@ -0,0 +1,95 @@ +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using ArangoDBNetStandard; +using ArangoDBNetStandard.AdminApi; +using ArangoDBNetStandard.AdminApi.Models; +using ArangoDBNetStandard.Transport; +using Moq; +using Xunit; + +namespace ArangoDBNetStandardTest.AdminApi +{ + public class AdminApiClientTest : IClassFixture, IAsyncLifetime + { + private AdminApiClient _adminApi; + private ArangoDBClient _adb; + + public AdminApiClientTest(AdminApiClientTestFixture fixture) + { + _adb = fixture.ArangoDBClient; + _adminApi = _adb.Admin; + } + + public Task InitializeAsync() + { + return Task.CompletedTask; + } + + public Task DisposeAsync() + { + return Task.CompletedTask; + } + + /// + /// Works only on version 3.8 onwards. + /// + /// + [Fact] + [Trait("ServerVersion", "3_8_PLUS")] + public async Task GetLogsAsync_ShouldSucceed() + { + var getResponse = await _adminApi.GetLogsAsync(); + Assert.NotNull(getResponse); + } + + [Fact] + public async Task PostReloadRoutingInfoAsync_ShouldSucceed() + { + var postResponse = await _adminApi.PostReloadRoutingInfoAsync(); + Assert.True(postResponse); + } + + /// + /// This test will run only in a cluster + /// + /// + [Fact] + [Trait("RunningMode", "Cluster")] + public async Task GetServerIdAsync_ShouldSucceed() + { + var getResponse = await _adminApi.GetServerIdAsync(); + Assert.NotNull(getResponse); + Assert.False(getResponse.Error); + Assert.NotNull(getResponse.Id); + } + + [Fact] + public async Task GetServerRoleAsync_ShouldSucceed() + { + var getResponse = await _adminApi.GetServerRoleAsync(); + Assert.NotNull(getResponse); + Assert.False(getResponse.Error); + Assert.NotNull(getResponse.Role); + } + + [Fact] + public async Task GetServerEngineTypeAsync_ShouldSucceed() + { + var getResponse = await _adminApi.GetServerEngineTypeAsync(); + Assert.NotNull(getResponse); + Assert.NotNull(getResponse.Name); + } + + [Fact] + public async Task GetServerVersionAsync_ShouldSucceed() + { + var getResponse = await _adminApi.GetServerVersionAsync(); + Assert.NotNull(getResponse); + Assert.NotNull(getResponse.License); + Assert.NotNull(getResponse.Version); + Assert.NotNull(getResponse.Server); + } + } +} \ No newline at end of file diff --git a/arangodb-net-standard.Test/AdminApi/AdminApiClientTestFixture.cs b/arangodb-net-standard.Test/AdminApi/AdminApiClientTestFixture.cs new file mode 100644 index 00000000..eeb714ab --- /dev/null +++ b/arangodb-net-standard.Test/AdminApi/AdminApiClientTestFixture.cs @@ -0,0 +1,41 @@ +using ArangoDBNetStandard; +using ArangoDBNetStandard.CollectionApi.Models; +using ArangoDBNetStandard.IndexApi.Models; +using System; +using System.Threading.Tasks; + +namespace ArangoDBNetStandardTest.AdminApi +{ + public class AdminApiClientTestFixture : ApiClientTestFixtureBase + { + public ArangoDBClient ArangoDBClient { get; internal set; } + + public AdminApiClientTestFixture() + { + } + + public override async Task InitializeAsync() + { + await base.InitializeAsync(); + string dbName = nameof(AdminApiClientTestFixture); + await CreateDatabase(dbName); + Console.WriteLine("Database " + dbName + " created successfully"); + ArangoDBClient = GetArangoDBClient(dbName); + try + { + var dbRes = await ArangoDBClient.Database.GetCurrentDatabaseInfoAsync(); + if (dbRes.Error) + throw new Exception("GetCurrentDatabaseInfoAsync failed: " + dbRes.Code.ToString()); + else + { + Console.WriteLine("Running tests in database " + dbRes.Result.Name); + } + } + catch (ApiErrorException ex) + { + Console.WriteLine(ex.Message); + throw ex; + } + } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/AdminApiClient.cs b/arangodb-net-standard/AdminApi/AdminApiClient.cs new file mode 100644 index 00000000..9013357f --- /dev/null +++ b/arangodb-net-standard/AdminApi/AdminApiClient.cs @@ -0,0 +1,198 @@ +using System.Net; +using System.Threading.Tasks; +using ArangoDBNetStandard.Serialization; +using ArangoDBNetStandard.Transport; +using ArangoDBNetStandard.AdminApi.Models; + +namespace ArangoDBNetStandard.AdminApi +{ + /// + /// A client for interacting with ArangoDB Admin API, + /// implementing . + /// + public class AdminApiClient : ApiClientBase, IAdminApiClient + { + /// + /// The transport client used to communicate with the ArangoDB host. + /// + protected IApiClientTransport _client; + + /// + /// The root path of the API. + /// + protected readonly string _adminApiPath = "_admin"; + + /// + /// Creates an instance of + /// using the provided transport layer and the default JSON serialization. + /// + /// Transport client that the API client will use to communicate with ArangoDB + public AdminApiClient(IApiClientTransport client) + : base(new JsonNetApiClientSerialization()) + { + _client = client; + } + + /// + /// Creates an instance of + /// using the provided transport and serialization layers. + /// + /// Transport client that the API client will use to communicate with ArangoDB. + /// Serializer to be used. + public AdminApiClient(IApiClientTransport client, IApiClientSerialization serializer) + : base(serializer) + { + _client = client; + } + + /// + /// Retrieves log messages from the server. + /// GET /_admin/log/entries + /// Works on ArangoDB 3.8 or later. + /// + /// Query string parameters + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#read-global-logs-from-the-server + /// + public virtual async Task GetLogsAsync(GetLogsQuery query = null) + { + string uri = $"{_adminApiPath}/log/entries"; + if (query != null) + { + uri += '?' + query.ToQueryString(); + } + using (var response = await _client.GetAsync(uri).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + return DeserializeJsonFromStream(stream); + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + + /// + /// Reloads the routing table. + /// POST /_admin/routing/reload + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#reloads-the-routing-information + /// + public virtual async Task PostReloadRoutingInfoAsync() + { + string uri = $"{_adminApiPath}/routing/reload"; + var body = new byte[] { }; + using (var response = await _client.PostAsync(uri, body).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + return true; + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + + /// + /// Retrieves the internal id of the server. + /// The method will fail if the server is not running in cluster mode. + /// GET /_admin/server/id + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster + /// + public virtual async Task GetServerIdAsync() + { + string uri = $"{_adminApiPath}/server/id"; + using (var response = await _client.GetAsync(uri).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + return DeserializeJsonFromStream(stream); + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + + /// + /// Retrieves the role of the server in a cluster. + /// GET /_admin/server/role + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-the-role-of-a-server-in-a-cluster + /// + public virtual async Task GetServerRoleAsync() + { + string uri = $"{_adminApiPath}/server/role"; + using (var response = await _client.GetAsync(uri).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + return DeserializeJsonFromStream(stream); + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + + /// + /// Retrieves the server database engine type. + /// GET /_api/engine + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-database-engine-type + /// + public virtual async Task GetServerEngineTypeAsync() + { + string uri = "_api/engine"; + using (var response = await _client.GetAsync(uri).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + return DeserializeJsonFromStream(stream); + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + + /// + /// Retrieves the server version. + /// GET /_api/version + /// + /// Query string parameters + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-version + /// + public virtual async Task GetServerVersionAsync(GetServerVersionQuery query = null) + { + string uri = "_api/version"; + if (query != null) + { + uri += '?' + query.ToQueryString(); + } + using (var response = await _client.GetAsync(uri).ConfigureAwait(false)) + { + if (response.IsSuccessStatusCode) + { + var stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); + return DeserializeJsonFromStream(stream); + } + throw await GetApiErrorException(response).ConfigureAwait(false); + } + } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/IAdminApiClient.cs b/arangodb-net-standard/AdminApi/IAdminApiClient.cs new file mode 100644 index 00000000..4a8812a1 --- /dev/null +++ b/arangodb-net-standard/AdminApi/IAdminApiClient.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using ArangoDBNetStandard.AdminApi.Models; + +namespace ArangoDBNetStandard.AdminApi +{ + /// + /// Defines a client to access the ArangoDB Admin API. + /// + public interface IAdminApiClient + { + /// + /// Retrieves log messages from the server. + /// GET /_admin/log/entries + /// Works on ArangoDB 3.8 or later. + /// + /// Query string parameters + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#read-global-logs-from-the-server + /// + Task GetLogsAsync(GetLogsQuery query = null); + + /// + /// Reloads the routing table. + /// POST /_admin/routing/reload + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#reloads-the-routing-information + /// + Task PostReloadRoutingInfoAsync(); + + /// + /// Retrieves the internal id of the server. + /// The method will fail if the server is not running in cluster mode. + /// GET /_admin/server/id + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-id-of-a-server-in-a-cluster + /// + Task GetServerIdAsync(); + + /// + /// Retrieves the role of the server in a cluster. + /// GET /_admin/server/role + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/administration-and-monitoring.html#return-the-role-of-a-server-in-a-cluster + /// + Task GetServerRoleAsync(); + + /// + /// Retrieves the server database engine type. + /// GET /_api/engine + /// + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-database-engine-type + /// + Task GetServerEngineTypeAsync(); + + /// + /// Retrieves the server version. + /// GET /_api/version + /// + /// Query string parameters + /// + /// + /// For further information see + /// https://www.arangodb.com/docs/stable/http/miscellaneous-functions.html#return-server-version + /// + Task GetServerVersionAsync(GetServerVersionQuery query = null); + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/EngineAlias.cs b/arangodb-net-standard/AdminApi/Models/EngineAlias.cs new file mode 100644 index 00000000..08e014c1 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/EngineAlias.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + public class EngineAlias + { + /// + /// List of indexes and associated types + /// + public Dictionary Indexes { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/EngineSupports.cs b/arangodb-net-standard/AdminApi/Models/EngineSupports.cs new file mode 100644 index 00000000..67290840 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/EngineSupports.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + public class EngineSupports + { + public bool DFDB { get; set; } + public IList Indexes { get; set; } + public EngineAlias Aliases { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetLogsQuery.cs b/arangodb-net-standard/AdminApi/Models/GetLogsQuery.cs new file mode 100644 index 00000000..b8b07b71 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetLogsQuery.cs @@ -0,0 +1,116 @@ +using System.Collections.Generic; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Parameters for + /// + public class GetLogsQuery + { + public const string SortAscending = "asc"; + public const string SortDescending = "desc"; + + /// + /// Optional. Retrieves all log entries + /// up to this log level. + /// + public LogLevel? UpTo { get; set; } + + /// + /// Optional. Retrieves all log entries + /// of this log level. Note that the query + /// parameters and + /// are mutually exclusive. + /// + public LogLevel? Level { get; set; } + + /// + /// Optional. Retrieves all log entries + /// that their log entry identifier (lid value) + /// is greater or equal to this value. + /// + public long? Start { get; set; } + + /// + /// Optional. Specifies the number of + /// log entries to retrieve. + /// + public long? Size { get; set; } + + /// + /// Optional. Specifies the number of + /// records to skip when retrieving + /// log entries. + /// and + /// can be used for pagination. + /// + public long? Offset { get; set; } + + /// + /// Optional. Retrieves all log entries + /// containing this text string. + /// + public string Search { get; set; } + + /// + /// Optional. Specify whether to sort + /// log entries in ascending or descending order. + /// Only or + /// are accepted here. + /// Log entries are sorted by their Id values. + /// The default value is . + /// + public string Sort { get; set; } + + /// + /// Optional. Retrieves all log entries of + /// the specified server. All other query + /// parameters remain valid. If no serverId + /// is given, the asked server will reply. + /// This parameter is only meaningful on Coordinators. + /// + public string ServerId { get; set; } + + /// + /// Generates the querystring + /// + /// + internal string ToQueryString() + { + var queryParams = new List(); + if (UpTo != null) + { + queryParams.Add("upto=" + ((int)UpTo).ToString()); + } + if (Level != null) + { + queryParams.Add("level=" + Level.ToString()); + } + if (Start != null) + { + queryParams.Add("start=" + Start.ToString()); + } + if (Size != null) + { + queryParams.Add("size=" + Size.ToString()); + } + if (Offset != null) + { + queryParams.Add("offset=" + Offset.ToString()); + } + if (!string.IsNullOrEmpty(Search)) + { + queryParams.Add("search=" + Search); + } + if (!string.IsNullOrEmpty(Sort)) + { + queryParams.Add("sort=" + Sort); + } + if (!string.IsNullOrEmpty(ServerId)) + { + queryParams.Add("serverId=" + ServerId); + } + return string.Join("&", queryParams); + } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetLogsResponse.cs b/arangodb-net-standard/AdminApi/Models/GetLogsResponse.cs new file mode 100644 index 00000000..d0ff6233 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetLogsResponse.cs @@ -0,0 +1,21 @@ +using System.Collections.Generic; +using System.Text; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Returned by + /// + public class GetLogsResponse + { + /// + /// The total amount of log entries before pagination + /// + public int Total { get; set; } + + /// + /// List of log messages that matched the criteria + /// + public List Messages { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetServerEngineTypeResponse.cs b/arangodb-net-standard/AdminApi/Models/GetServerEngineTypeResponse.cs new file mode 100644 index 00000000..4bb6dd98 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetServerEngineTypeResponse.cs @@ -0,0 +1,18 @@ +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Returned by + /// + public class GetServerEngineTypeResponse + { + /// + /// Type of engine + /// + public string Name { get; set; } + + /// + /// Features supported by the engine + /// + public EngineSupports Supports { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetServerIdResponse.cs b/arangodb-net-standard/AdminApi/Models/GetServerIdResponse.cs new file mode 100644 index 00000000..1c8b955c --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetServerIdResponse.cs @@ -0,0 +1,13 @@ +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Returned by + /// + public class GetServerIdResponse : ResponseBase + { + /// + /// Id of the server in the cluster. + /// + public string Id { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetServerRoleResponse.cs b/arangodb-net-standard/AdminApi/Models/GetServerRoleResponse.cs new file mode 100644 index 00000000..f44d693b --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetServerRoleResponse.cs @@ -0,0 +1,20 @@ +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Returned by + /// + public class GetServerRoleResponse : ResponseBase + { + /// + /// The server's role. + /// Possible values for role are: + /// SINGLE: the server is a standalone server without clustering. + /// COORDINATOR: the server is a Coordinator in a cluster. + /// PRIMARY: the server is a DB-Server in a cluster. + /// SECONDARY: this role is not used anymore. + /// AGENT: the server is an Agency node in a cluster. + /// UNDEFINED: the server is in a cluster, but its role cannot be determined. + /// + public string Role { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetServerVersionQuery.cs b/arangodb-net-standard/AdminApi/Models/GetServerVersionQuery.cs new file mode 100644 index 00000000..c3e71ac7 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetServerVersionQuery.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Parameters for + /// + public class GetServerVersionQuery + { + /// + /// If set to true, the response will + /// contain a details attribute with + /// additional information about included + /// components and their versions. + /// The attribute names and internals of + /// the details object may vary depending + /// on platform and ArangoDB version. + /// + public bool? Details { get; set; } + + /// + /// Generates the querystring + /// + /// + internal string ToQueryString() + { + var queryParams = new List(); + if (Details != null) + { + queryParams.Add("details=" + Details.ToString()); + } + return string.Join("&", queryParams); + } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/GetServerVersionResponse.cs b/arangodb-net-standard/AdminApi/Models/GetServerVersionResponse.cs new file mode 100644 index 00000000..adf5f555 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/GetServerVersionResponse.cs @@ -0,0 +1,33 @@ +using System.Collections.Generic; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Returned by + /// + public class GetServerVersionResponse + { + /// + /// The type of server. + /// + public string Server { get; set; } + + /// + /// The type of license. + /// + public string License { get; set; } + + /// + /// The version of the server. + /// + public string Version { get; set; } + + /// + /// Additional details about the DB server. + /// This is returned only if the + /// query parameter is set to true in + /// the request. + /// + public Dictionary Details {get;set;} + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/LogLevel.cs b/arangodb-net-standard/AdminApi/Models/LogLevel.cs new file mode 100644 index 00000000..f14dd48d --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/LogLevel.cs @@ -0,0 +1,14 @@ +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Log levels in ArangoDB + /// + public enum LogLevel + { + Fatal = 0, + Error = 1, + Warning = 2, + Info = 3, + Debug = 4 + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/LogMessage.cs b/arangodb-net-standard/AdminApi/Models/LogMessage.cs new file mode 100644 index 00000000..287cd7c6 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/LogMessage.cs @@ -0,0 +1,35 @@ +using System; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Represents one log entry in ArangoDB + /// + public class LogMessage + { + /// + /// Unique Id of the log entry. + /// + public int Id { get; set; } + + /// + /// Topic or subject of the log entry. + /// + public string Topic { get; set; } + + /// + /// Level of the log entry. + /// + public string Level { get; set; } + + /// + /// Date and time when the log entry was created. + /// + public DateTime Date { get; set; } + + /// + /// The logged message. + /// + public string Message { get; set; } + } +} \ No newline at end of file diff --git a/arangodb-net-standard/AdminApi/Models/ResponseBase.cs b/arangodb-net-standard/AdminApi/Models/ResponseBase.cs new file mode 100644 index 00000000..f9d62f96 --- /dev/null +++ b/arangodb-net-standard/AdminApi/Models/ResponseBase.cs @@ -0,0 +1,25 @@ +using System.Net; + +namespace ArangoDBNetStandard.AdminApi.Models +{ + /// + /// Represents a common response class for Admin API operations. + /// + public class ResponseBase + { + /// + /// Always false. + /// + /// + /// To handle errors, catch + /// thrown by API client methods. + /// + public bool Error { get; set; } + + /// + /// The HTTP status code. + /// + public HttpStatusCode Code { get; set; } + } + +} diff --git a/arangodb-net-standard/ArangoDBClient.cs b/arangodb-net-standard/ArangoDBClient.cs index f5b37341..7c11782a 100644 --- a/arangodb-net-standard/ArangoDBClient.cs +++ b/arangodb-net-standard/ArangoDBClient.cs @@ -1,4 +1,5 @@ using System.Net.Http; +using ArangoDBNetStandard.AdminApi; using ArangoDBNetStandard.AnalyzerApi; using ArangoDBNetStandard.AqlFunctionApi; using ArangoDBNetStandard.AuthApi; @@ -68,24 +69,29 @@ public class ArangoDBClient : IArangoDBClient public GraphApiClient Graph { get; private set; } /// - /// User management API. + /// User management API /// public UserApiClient User { get; private set; } /// - /// Index management API. + /// Index management API /// public IndexApiClient Index { get; private set; } - + /// - /// View management API. + /// View management API /// public ViewApiClient View { get; private set; } /// /// Analyzer management API. /// - public AnalyzerApiClient Analyzer { get; private set; } + public AnalyzerApiClient Analyzer { get; private set; } + + /// + /// Admin management API + /// + public AdminApiClient Admin { get; private set; } /// /// Create an instance of from an existing @@ -151,7 +157,8 @@ private void InitializeApis( User = new UserApiClient(transport, serialization); Index = new IndexApiClient(transport, serialization); View = new ViewApiClient(transport, serialization); - Analyzer = new AnalyzerApiClient(transport, serialization); + Analyzer = new AnalyzerApiClient(transport, serialization); + Admin = new AdminApiClient(transport, serialization); } } -} +} \ No newline at end of file diff --git a/arangodb-net-standard/IArangoDBClient.cs b/arangodb-net-standard/IArangoDBClient.cs index 8f58c74b..5159abfe 100644 --- a/arangodb-net-standard/IArangoDBClient.cs +++ b/arangodb-net-standard/IArangoDBClient.cs @@ -1,4 +1,5 @@ using System; +using ArangoDBNetStandard.AdminApi; using ArangoDBNetStandard.AnalyzerApi; using ArangoDBNetStandard.AqlFunctionApi; using ArangoDBNetStandard.AuthApi; @@ -57,23 +58,28 @@ public interface IArangoDBClient : IDisposable GraphApiClient Graph { get; } /// - /// User management API. + /// User management API /// UserApiClient User { get; } /// - /// Index management API. + /// Index management API /// IndexApiClient Index { get; } - + /// - /// View management API. + /// View management API /// ViewApiClient View { get; } /// - /// Analyzer API. + /// Analyzer API /// AnalyzerApiClient Analyzer { get; } + + /// + /// Admin API + /// + AdminApiClient Admin { get; } } } \ No newline at end of file diff --git a/project/roadmap.md b/project/roadmap.md index f76f4458..817c26d5 100644 --- a/project/roadmap.md +++ b/project/roadmap.md @@ -224,4 +224,13 @@ A tick indicates an item is implemented and has automated tests in place. - [X] `GET/_api/analyzer` List all Analyzers - [X] `POST/_api/analyzer` Create an Analyzer with the supplied definition - [X] `DELETE/_api/analyzer/{analyzer-name}` Remove an Analyzer -- [X] `GET/_api/analyzer/{analyzer-name}` Return the Analyzer definition \ No newline at end of file +- [X] `GET/_api/analyzer/{analyzer-name}` Return the Analyzer definition + +#### Admin API + +- [X] `GET/_admin/log/entries` Read global logs from the server +- [X] `POST/_admin/routing/reload` Reloads the routing information +- [X] `GET/_admin/server/id` Return id of a server in a cluster +- [X] `GET/_admin/server/role` Return role of a server in a cluster +- [X] `GET/_api/engine` Return server database engine type +- [X] `GET/_api/version` Return server version \ No newline at end of file