@@ -43,7 +43,7 @@ type cluster struct {
4343 conn Connection
4444}
4545
46- // LoggerState returns the state of the replication logger
46+ // Health returns the state of the cluster
4747func (c * cluster ) Health (ctx context.Context ) (ClusterHealth , error ) {
4848 req , err := c .conn .NewRequest ("GET" , "_admin/cluster/health" )
4949 if err != nil {
@@ -64,7 +64,7 @@ func (c *cluster) Health(ctx context.Context) (ClusterHealth, error) {
6464 return result , nil
6565}
6666
67- // Get the inventory of the cluster containing all collections (with entire details) of a database.
67+ // DatabaseInventory Get the inventory of the cluster containing all collections (with entire details) of a database.
6868func (c * cluster ) DatabaseInventory (ctx context.Context , db Database ) (DatabaseInventory , error ) {
6969 req , err := c .conn .NewRequest ("GET" , path .Join ("_db" , db .Name (), "_api/replication/clusterInventory" ))
7070 if err != nil {
@@ -290,7 +290,7 @@ type inventoryCollectionParametersInternal struct {
290290 JournalSize int64 `json:"journalSize,omitempty"`
291291 KeyOptions struct {
292292 AllowUserKeys bool `json:"allowUserKeys,omitempty"`
293- LastValue int64 `json:"lastValue,omitempty"`
293+ LastValue uint64 `json:"lastValue,omitempty"`
294294 Type string `json:"type,omitempty"`
295295 } `json:"keyOptions"`
296296 // Deprecated: use 'WriteConcern' instead
@@ -322,23 +322,35 @@ type inventoryCollectionParametersInternal struct {
322322}
323323
324324func (p * InventoryCollectionParameters ) asInternal () inventoryCollectionParametersInternal {
325+ lastValue := p .KeyOptions .LastValueV2
326+ if lastValue == 0 && p .KeyOptions .LastValue != 0 {
327+ lastValue = uint64 (p .KeyOptions .LastValue )
328+ }
329+
325330 return inventoryCollectionParametersInternal {
326- CacheEnabled : p .CacheEnabled ,
327- Deleted : p .Deleted ,
328- DistributeShardsLike : p .DistributeShardsLike ,
329- DoCompact : p .DoCompact ,
330- GloballyUniqueId : p .GloballyUniqueId ,
331- ID : p .ID ,
332- IndexBuckets : p .IndexBuckets ,
333- Indexes : p .Indexes ,
334- InternalValidatorType : p .InternalValidatorType ,
335- IsDisjoint : p .IsDisjoint ,
336- IsSmart : p .IsSmart ,
337- IsSmartChild : p .IsSmartChild ,
338- IsSystem : p .IsSystem ,
339- IsVolatile : p .IsVolatile ,
340- JournalSize : p .JournalSize ,
341- KeyOptions : p .KeyOptions ,
331+ CacheEnabled : p .CacheEnabled ,
332+ Deleted : p .Deleted ,
333+ DistributeShardsLike : p .DistributeShardsLike ,
334+ DoCompact : p .DoCompact ,
335+ GloballyUniqueId : p .GloballyUniqueId ,
336+ ID : p .ID ,
337+ IndexBuckets : p .IndexBuckets ,
338+ Indexes : p .Indexes ,
339+ InternalValidatorType : p .InternalValidatorType ,
340+ IsDisjoint : p .IsDisjoint ,
341+ IsSmart : p .IsSmart ,
342+ IsSmartChild : p .IsSmartChild ,
343+ IsSystem : p .IsSystem ,
344+ IsVolatile : p .IsVolatile ,
345+ JournalSize : p .JournalSize ,
346+ KeyOptions : struct {
347+ AllowUserKeys bool `json:"allowUserKeys,omitempty"`
348+ LastValue uint64 `json:"lastValue,omitempty"`
349+ Type string `json:"type,omitempty"`
350+ }{
351+ p .KeyOptions .AllowUserKeys ,
352+ lastValue ,
353+ p .KeyOptions .Type },
342354 MinReplicationFactor : p .MinReplicationFactor ,
343355 Name : p .Name ,
344356 NumberOfShards : p .NumberOfShards ,
@@ -367,22 +379,32 @@ func (p *InventoryCollectionParameters) fromInternal(i inventoryCollectionParame
367379
368380func (p * inventoryCollectionParametersInternal ) asExternal () InventoryCollectionParameters {
369381 return InventoryCollectionParameters {
370- CacheEnabled : p .CacheEnabled ,
371- Deleted : p .Deleted ,
372- DistributeShardsLike : p .DistributeShardsLike ,
373- DoCompact : p .DoCompact ,
374- GloballyUniqueId : p .GloballyUniqueId ,
375- ID : p .ID ,
376- IndexBuckets : p .IndexBuckets ,
377- Indexes : p .Indexes ,
378- InternalValidatorType : p .InternalValidatorType ,
379- IsDisjoint : p .IsDisjoint ,
380- IsSmart : p .IsSmart ,
381- IsSmartChild : p .IsSmartChild ,
382- IsSystem : p .IsSystem ,
383- IsVolatile : p .IsVolatile ,
384- JournalSize : p .JournalSize ,
385- KeyOptions : p .KeyOptions ,
382+ CacheEnabled : p .CacheEnabled ,
383+ Deleted : p .Deleted ,
384+ DistributeShardsLike : p .DistributeShardsLike ,
385+ DoCompact : p .DoCompact ,
386+ GloballyUniqueId : p .GloballyUniqueId ,
387+ ID : p .ID ,
388+ IndexBuckets : p .IndexBuckets ,
389+ Indexes : p .Indexes ,
390+ InternalValidatorType : p .InternalValidatorType ,
391+ IsDisjoint : p .IsDisjoint ,
392+ IsSmart : p .IsSmart ,
393+ IsSmartChild : p .IsSmartChild ,
394+ IsSystem : p .IsSystem ,
395+ IsVolatile : p .IsVolatile ,
396+ JournalSize : p .JournalSize ,
397+ KeyOptions : struct {
398+ AllowUserKeys bool `json:"allowUserKeys,omitempty"`
399+ LastValue int64 `json:"-"`
400+ LastValueV2 uint64 `json:"lastValue,omitempty"`
401+ Type string `json:"type,omitempty"`
402+ }{
403+ p .KeyOptions .AllowUserKeys ,
404+ // cast to int64 to keep backwards compatibility for most cases
405+ int64 (p .KeyOptions .LastValue ),
406+ p .KeyOptions .LastValue ,
407+ p .KeyOptions .Type },
386408 MinReplicationFactor : p .MinReplicationFactor ,
387409 Name : p .Name ,
388410 NumberOfShards : p .NumberOfShards ,
0 commit comments