Skip to content
Next Next commit
Initial implementation of additional collection endpoints
  • Loading branch information
tjoubert committed Mar 30, 2022
commit 47df3f135c9312c4efab915befdfb75d4dc3730e
107 changes: 107 additions & 0 deletions arangodb-net-standard/CollectionApi/CollectionApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ArangoDBNetStandard.CollectionApi.Models;
using ArangoDBNetStandard.Serialization;
using ArangoDBNetStandard.Transport;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;

Expand Down Expand Up @@ -267,5 +268,111 @@ public virtual async Task<GetCollectionFiguresResponse> GetCollectionFiguresAsyn
throw await GetApiErrorException(response).ConfigureAwait(false);
};
}













/// <summary>
/// Get the checksum for a specific collection.
/// GET /_api/collection/{collection-name}/checksum
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="query">Query options.</param>
/// <returns></returns>
public virtual async Task<GetChecksumResponse> GetChecksumAsync(string collectionName, GetChecksumQuery query = null)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Load Indexes into Memory.
/// Caches all index entries of this collection into the main memory.
/// Therefore it iterates over all indexes of the collection and
/// stores the indexed values, not the entire document data,
/// in memory.
/// PUT /_api/collection/{collection-name}/loadIndexesIntoMemory
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
public virtual async Task<LoadIndexesIntoMemoryResponse> LoadIndexesIntoMemoryAsync(string collectionName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Recalculates the document count of a collection.
/// PUT /_api/collection/{collection-name}/recalculateCount
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
public virtual async Task<RecalculateCountResponse> RecalculateCountAsync(string collectionName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Returns the responsible shard for a document.
/// PUT /_api/collection/{collection-name}/responsibleShard
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="body">
/// Body of the request consisting of key/value
/// pairs with at least the collection’s shard
/// key attributes set to some values.
/// </param>
/// <returns></returns>
public virtual async Task<DocumentShardResponse> PutDocumentShardAsync(string collectionName, Dictionary<string, object> body)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Returns the shard ids of a collection.
/// This method is only available in a cluster Coordinator.
/// GET /_api/collection/{collection-name}/shards
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
public virtual async Task<CollectionShardsResponse> GetCollectionShardsAsync(string collectionName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Returns the shard ids of a collection.
/// This method is only available in a cluster Coordinator.
/// The response also contains shard IDs as object attribute
/// keys, and the responsible servers for each shard mapped
/// to them. The leader shards will be first in the arrays.
/// GET /_api/collection/{collection-name}/shards?details=true
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
public virtual async Task<CollectionShardsDetailedResponse> GetCollectionShardsWithDetailsAsync(string collectionName)
{
throw new System.NotImplementedException();
}

/// <summary>
/// Compacts the data of a collection in order to reclaim disk space.
/// The operation will compact the document and index data by rewriting
/// the underlying .sst files and only keeping the relevant entries.
/// PUT /_api/collection/{collection-name}/compact
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
public virtual async Task<CompactCollectionDataResponse> CompactCollectionDataAsync(string collectionName)
{
throw new System.NotImplementedException();
}
}
}
83 changes: 82 additions & 1 deletion arangodb-net-standard/CollectionApi/ICollectionApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ArangoDBNetStandard.CollectionApi.Models;
using ArangoDBNetStandard.Serialization;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace ArangoDBNetStandard.CollectionApi
Expand Down Expand Up @@ -92,5 +93,85 @@ Task<PutCollectionPropertyResponse> PutCollectionPropertyAsync(
/// <param name="collectionName"></param>
/// <returns></returns>
Task<GetCollectionFiguresResponse> GetCollectionFiguresAsync(string collectionName);

/// <summary>
/// Get the checksum for a specific collection.
/// GET /_api/collection/{collection-name}/checksum
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="query">Query options.</param>
/// <returns></returns>
Task<GetChecksumResponse> GetChecksumAsync(string collectionName,
GetChecksumQuery query = null);

/// <summary>
/// Load Indexes into Memory.
/// Caches all index entries of this collection into the main memory.
/// Therefore it iterates over all indexes of the collection and
/// stores the indexed values, not the entire document data,
/// in memory.
/// PUT /_api/collection/{collection-name}/loadIndexesIntoMemory
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
Task<LoadIndexesIntoMemoryResponse> LoadIndexesIntoMemoryAsync(
string collectionName);

/// <summary>
/// Recalculates the document count of a collection.
/// PUT /_api/collection/{collection-name}/recalculateCount
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
Task<RecalculateCountResponse> RecalculateCountAsync(
string collectionName);

/// <summary>
/// Returns the responsible shard for a document.
/// PUT /_api/collection/{collection-name}/responsibleShard
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <param name="body">
/// Body of the request consisting of key/value
/// pairs with at least the collection’s shard
/// key attributes set to some values.
/// </param>
/// <returns></returns>
Task<DocumentShardResponse> PutDocumentShardAsync(
string collectionName, Dictionary<string,object> body);

/// <summary>
/// Returns the shard ids of a collection.
/// This method is only available in a cluster Coordinator.
/// GET /_api/collection/{collection-name}/shards
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
Task<CollectionShardsResponse> GetCollectionShardsAsync(
string collectionName);

/// <summary>
/// Returns the shard ids of a collection.
/// This method is only available in a cluster Coordinator.
/// The response also contains shard IDs as object attribute
/// keys, and the responsible servers for each shard mapped
/// to them. The leader shards will be first in the arrays.
/// GET /_api/collection/{collection-name}/shards?details=true
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
Task<CollectionShardsDetailedResponse> GetCollectionShardsWithDetailsAsync(
string collectionName);

/// <summary>
/// Compacts the data of a collection in order to reclaim disk space.
/// The operation will compact the document and index data by rewriting
/// the underlying .sst files and only keeping the relevant entries.
/// PUT /_api/collection/{collection-name}/compact
/// </summary>
/// <param name="collectionName">Name of the collection.</param>
/// <returns></returns>
Task<CompactCollectionDataResponse> CompactCollectionDataAsync(
string collectionName);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ArangoDBNetStandard.CollectionApi.Models
{
public class CollectionShardsDetailedResponse : CollectionShardsResponseBase
{
public Dictionary<string,List<string>> Shards { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace ArangoDBNetStandard.CollectionApi.Models
{

public class CollectionShardsKeyOption
{
public bool? AllowUserKeys { get; set; }
public string Type { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ArangoDBNetStandard.CollectionApi.Models
{
public class CollectionShardsResponse : CollectionShardsResponseBase
{
public List<string> Shards { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;

namespace ArangoDBNetStandard.CollectionApi.Models
{
public class CollectionShardsResponseBase : ResponseBase
{
public bool? WaitForSync { get; set; }
public string ShardingStrategy { get; set; }
public bool? UsesRevisionsAsDocumentIds { get; set; }
public object Schema { get; set; }
public int? WriteConcern { get; set; }
public bool? SyncByRevision { get; set; }
public int? ReplicationFactor { get; set; }
public int? NumberOfShards { get; set; }
public string Id { get; set; }
public string Name { get; set; }
public bool? IsDisjoint { get; set; }
public int? MinReplicationFactor { get; set; }
public int? Status { get; set; }
public int? Type { get; set; }
public string GloballyUniqueId { get; set; }
public bool? IsSmart { get; set; }
public bool? IsSystem { get; set; }
public int? InternalValidatorType { get; set; }
public bool? IsSmartChild { get; set; }
public string StatusString { get; set; }
public bool? CacheEnabled { get; set; }
public List<string> ShardKeys { get; set; }
public CollectionShardsKeyOption KeyOptions { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace ArangoDBNetStandard.CollectionApi.Models
{
public class CompactCollectionDataResponse : ResponseBase
{
public int? Type { get; set; }
public int? Status { get; set; }
public bool? IsSystem { get; set; }
public string Name { get; set; }
public string Id { get; set; }
public string GloballyUniqueId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ArangoDBNetStandard.CollectionApi.Models
{
public class DocumentShardResponse : ResponseBase
{
/// <summary>
/// The Id of the responsible shard.
/// </summary>
public string ShardId { get; set; }
}
}
44 changes: 44 additions & 0 deletions arangodb-net-standard/CollectionApi/Models/GetChecksumQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ArangoDBNetStandard.CollectionApi.Models
{
/// <summary>
/// Generates query for <see cref="ICollectionApiClient.GetChecksumAsync(string, GetChecksumQuery)"/>
/// </summary>
public class GetChecksumQuery
{
/// <summary>
/// Optional. Indicates whether or not to include document
/// revision ids in the checksum calculation.
/// When true, then revision ids (_rev system attributes)
/// are included in the checksumming.
/// </summary>
public bool? WithRevisions { get; set; }

/// <summary>
/// Optional. Indicates whether or not to include document
/// body data in the checksum calculation.
/// When true, the user-defined document attributes will
/// be included in the calculation too.
/// Note: Including user-defined attributes will
/// make the checksumming slower.
/// </summary>
public bool? WithData { get; set; }

internal string ToQueryString()
{
List<string> query = new List<string>();
if (WithRevisions != null)
{
query.Add("withRevisions=" + WithRevisions.ToString().ToLower());
}
if (WithData != null)
{
query.Add("withData=" + WithData.ToString().ToLower());
}
return string.Join("&", query);
}
}
}
Loading