@@ -216,6 +216,196 @@ func (c collection) Shards(ctx context.Context, details bool) (CollectionShards,
216
216
}
217
217
}
218
218
219
+ func (c collection ) Statistics (ctx context.Context , details bool ) (CollectionFigures , error ) {
220
+ urlEndpoint := c .url ("collection" , "figures" )
221
+
222
+ var response struct {
223
+ shared.ResponseStruct `json:",inline"`
224
+ CollectionFigures `json:",inline"`
225
+ }
226
+
227
+ resp , err := connection .CallGet (
228
+ ctx , c .connection (), urlEndpoint , & response ,
229
+ c .withModifiers (connection .WithQuery ("details" , boolToString (details )))... ,
230
+ )
231
+ if err != nil {
232
+ return CollectionFigures {}, errors .WithStack (err )
233
+ }
234
+
235
+ switch code := resp .Code (); code {
236
+ case http .StatusOK :
237
+ return response .CollectionFigures , nil
238
+ default :
239
+ return CollectionFigures {}, response .AsArangoErrorWithCode (code )
240
+ }
241
+ }
242
+
243
+ func (c collection ) Revision (ctx context.Context ) (CollectionProperties , error ) {
244
+ urlEndpoint := c .url ("collection" , "revision" )
245
+
246
+ var response struct {
247
+ shared.ResponseStruct `json:",inline"`
248
+ CollectionProperties `json:",inline"`
249
+ }
250
+
251
+ resp , err := connection .CallGet (
252
+ ctx , c .connection (), urlEndpoint , & response , c .withModifiers ()... ,
253
+ )
254
+
255
+ if err != nil {
256
+ return CollectionProperties {}, errors .WithStack (err )
257
+ }
258
+
259
+ switch code := resp .Code (); code {
260
+ case http .StatusOK :
261
+ return response .CollectionProperties , nil
262
+ default :
263
+ return CollectionProperties {}, response .AsArangoErrorWithCode (code )
264
+ }
265
+ }
266
+
267
+ func (c collection ) Checksum (ctx context.Context , withRevisions * bool , withData * bool ) (CollectionChecksum , error ) {
268
+ urlEndpoint := c .url ("collection" , "checksum" )
269
+
270
+ var response struct {
271
+ shared.ResponseStruct `json:",inline"`
272
+ CollectionChecksum `json:",inline"`
273
+ }
274
+
275
+ // Prepare query modifiers
276
+ var modifiers []connection.RequestModifier
277
+ if withRevisions != nil && * withRevisions {
278
+ modifiers = append (modifiers , connection .WithQuery ("withRevisions" , boolToString (* withRevisions )))
279
+ }
280
+ if withData != nil && * withData {
281
+ modifiers = append (modifiers , connection .WithQuery ("withData" , boolToString (* withData )))
282
+ }
283
+
284
+ resp , err := connection .CallGet (
285
+ ctx , c .connection (), urlEndpoint , & response ,
286
+ c .withModifiers (modifiers ... )... ,
287
+ )
288
+ if err != nil {
289
+ return CollectionChecksum {}, errors .WithStack (err )
290
+ }
291
+
292
+ switch code := resp .Code (); code {
293
+ case http .StatusOK :
294
+ return response .CollectionChecksum , nil
295
+ default :
296
+ return CollectionChecksum {}, response .AsArangoErrorWithCode (code )
297
+ }
298
+ }
299
+
300
+ func (c collection ) ResponsibleShard (ctx context.Context , options map [string ]interface {}) (string , error ) {
301
+ urlEndpoint := c .url ("collection" , "responsibleShard" )
302
+
303
+ var response struct {
304
+ shared.ResponseStruct `json:",inline"`
305
+ ShardId string `json:"shardId,omitempty"`
306
+ }
307
+
308
+ resp , err := connection .CallPut (ctx , c .connection (), urlEndpoint , & response , options , c .withModifiers ()... )
309
+ if err != nil {
310
+ return "" , errors .WithStack (err )
311
+ }
312
+
313
+ switch code := resp .Code (); code {
314
+ case http .StatusOK :
315
+ return response .ShardId , nil
316
+ default :
317
+ return "" , response .AsArangoErrorWithCode (code )
318
+ }
319
+ }
320
+
321
+ func (c collection ) LoadIndexesIntoMemory (ctx context.Context ) (bool , error ) {
322
+ urlEndpoint := c .url ("collection" , "loadIndexesIntoMemory" )
323
+
324
+ var response struct {
325
+ shared.ResponseStruct `json:",inline"`
326
+ Result bool `json:"result"`
327
+ }
328
+
329
+ resp , err := connection .CallPut (ctx , c .connection (), urlEndpoint , & response , nil , c .withModifiers ()... )
330
+ if err != nil {
331
+ return false , errors .WithStack (err )
332
+ }
333
+
334
+ switch code := resp .Code (); code {
335
+ case http .StatusOK :
336
+ return response .Result , nil
337
+ default :
338
+ return false , response .AsArangoErrorWithCode (code )
339
+ }
340
+ }
341
+
342
+ // Renaming collections is not supported in cluster deployments.
343
+ func (c collection ) Rename (ctx context.Context , req RenameCollectionRequest ) (CollectionInfo , error ) {
344
+ urlEndpoint := c .url ("collection" , "rename" )
345
+
346
+ var response struct {
347
+ shared.ResponseStruct `json:",inline"`
348
+ CollectionInfo `json:",inline"`
349
+ }
350
+
351
+ resp , err := connection .CallPut (ctx , c .connection (), urlEndpoint , & response , req , c .withModifiers ()... )
352
+ if err != nil {
353
+ return CollectionInfo {}, errors .WithStack (err )
354
+ }
355
+
356
+ switch code := resp .Code (); code {
357
+ case http .StatusOK :
358
+ return response .CollectionInfo , nil
359
+ default :
360
+ return CollectionInfo {}, response .AsArangoErrorWithCode (code )
361
+ }
362
+ }
363
+
364
+ func (c collection ) RecalculateCount (ctx context.Context ) (bool , * int64 , error ) {
365
+ urlEndpoint := c .url ("collection" , "recalculateCount" )
366
+
367
+ var response struct {
368
+ shared.ResponseStruct `json:",inline"`
369
+ Count * int64 `json:"count,omitempty"`
370
+ Result bool `json:"result"`
371
+ }
372
+
373
+ resp , err := connection .CallPut (ctx , c .connection (), urlEndpoint , & response , nil , c .withModifiers ()... )
374
+ if err != nil {
375
+ zero := int64 (0 )
376
+ return false , & zero , errors .WithStack (err )
377
+ }
378
+
379
+ switch code := resp .Code (); code {
380
+ case http .StatusOK :
381
+ return response .Result , response .Count , nil
382
+ default :
383
+ zero := int64 (0 )
384
+ return false , & zero , response .AsArangoErrorWithCode (code )
385
+ }
386
+ }
387
+
388
+ func (c collection ) Compact (ctx context.Context ) (CollectionInfo , error ) {
389
+ urlEndpoint := c .url ("collection" , "compact" )
390
+
391
+ var response struct {
392
+ shared.ResponseStruct `json:",inline"`
393
+ CollectionInfo `json:",inline"`
394
+ }
395
+
396
+ resp , err := connection .CallPut (ctx , c .connection (), urlEndpoint , & response , nil , c .withModifiers ()... )
397
+ if err != nil {
398
+ return CollectionInfo {}, errors .WithStack (err )
399
+ }
400
+
401
+ switch code := resp .Code (); code {
402
+ case http .StatusOK :
403
+ return response .CollectionInfo , nil
404
+ default :
405
+ return CollectionInfo {}, response .AsArangoErrorWithCode (code )
406
+ }
407
+ }
408
+
219
409
type RemoveCollectionOptions struct {
220
410
// IsSystem when set to true allows to remove system collections.
221
411
// Use on your own risk!
0 commit comments