constructor return { Collection } api import { AddReplica , AddReplicaProp , Alias , BalanceShardUnique , ClusterProp , CreateOptions , DeleteReplica , DeleteReplicaProp , Migrate , RebalanceLeaders , Role , ShardOptions , SplitShard , } from './types' ; export class Collection { private parameters : any [ ] ; constructor ( ) { this . parameters = [ ] ; } param { String } parameter return { Collection } api set ( parameter ) { const self = this ; this . parameters . push ( parameter ) ; return self ; } param { Object } options param { String } name param { String } routerName param { Number } numShards param { String | Array } shards param { Number } replicationFactor param { Number } maxShardsPerNode param { String | Array } createNodeSet param { Boolean } createNodeSetShuffle param { String } collectionConfigName param { String } routerField param { Boolean } autoAddReplicas param { String } async return { Collection } api create ( options ) { const self = this ; this . parameters . push ( 'action=CREATE' ) ; if ( options . name ) { this . parameters . push ( 'name=' + options . name ) ; } if ( options . routerName ) { this . parameters . push ( 'router.name=' + options . routerName ) ; } if ( options . numShards !== undefined ) { this . parameters . push ( 'numShards=' + options . numShards ) ; } if ( options . shards !== undefined ) { if ( typeof options . shards === 'string' ) { this . parameters . push ( 'shards=' + options . shards ) ; } else { this . parameters . push ( 'shards=' + options . shards . join ( ) ) ; } } if ( options . replicationFactor !== undefined ) { this . parameters . push ( 'replicationFactor=' + options . replicationFactor ) ; } if ( options . maxShardsPerNode !== undefined ) { this . parameters . push ( 'maxShardsPerNode=' + options . maxShardsPerNode ) ; } if ( options . createNodeSet !== undefined ) { if ( typeof options . createNodeSet === 'string' ) { this . parameters . push ( 'createNodeSet=' + options . createNodeSet ) ; } else { this . parameters . push ( 'createNodeSet=' + options . createNodeSet . join ( ) ) ; } } if ( options . createNodeSetShuffle !== undefined ) { this . parameters . push ( 'createNodeSet.shuffle=' + options . createNodeSetShuffle ) ; } if ( options . collectionConfigName ) { this . parameters . push ( 'collection.configName=' + options . collectionConfigName ) ; } if ( options . routerField ) { this . parameters . push ( 'router.field=' + options . routerField ) ; } if ( options . autoAddReplicas !== undefined ) { this . parameters . push ( 'autoAddReplicas=' + options . autoAddReplicas ) ; } if ( options . async ) { this . parameters . push ( 'async=' + options . async ) ; } return self ; } param { String } name return { Collection } api reload ( name ) { const self = this ; this . parameters . push ( 'action=RELOAD' ) ; if ( name ) { this . parameters . push ( 'name=' + name ) ; } return self ; } param { Object } options param { String } collection param { String } shard param { String | Array } ranges param { String } splitKey param { String } async return { Collection } api splitShard ( options ) { const self = this ; this . parameters . push ( 'action=SPLITSHARD' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } if ( options . ranges !== undefined ) { if ( typeof options . ranges === 'string' ) { this . parameters . push ( 'ranges=' + options . ranges ) ; } else { this . parameters . push ( 'ranges=' + options . ranges . join ( ) ) ; } } if ( options . splitKey ) { this . parameters . push ( 'split.key=' + options . splitKey ) ; } if ( options . async ) { this . parameters . push ( 'async=' + options . async ) ; } return self ; } param { Object } options param { String } collection param { String } shard return { Collection } api createShard ( options ) { const self = this ; this . parameters . push ( 'action=CREATESHARD' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } return self ; } param { Object } options param { String } collection param { String } shard return { Collection } api deleteShard ( options ) { const self = this ; this . parameters . push ( 'action=DELETESHARD' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } return self ; } param { Object } options param { String } name param { String | Array } collections return { Collection } api createAlias ( options ) { const self = this ; this . parameters . push ( 'action=CREATEALIAS' ) ; if ( options . name ) { this . parameters . push ( 'name=' + options . name ) ; } if ( options . collections !== undefined ) { if ( typeof options . collections === 'string' ) { this . parameters . push ( 'collections=' + options . collections ) ; } else { this . parameters . push ( 'collections=' + options . collections . join ( ) ) ; } } return self ; } param { String } name return { Collection } api deleteAlias ( name ) { const self = this ; this . parameters . push ( 'action=DELETEALIAS' ) ; if ( name ) { this . parameters . push ( 'name=' + name ) ; } return self ; } param { String } name return { Collection } api delete ( name ) { const self = this ; this . parameters . push ( 'action=DELETE' ) ; if ( name ) { this . parameters . push ( 'name=' + name ) ; } return self ; } param { Object } options param { String } collection param { String } shard param { String } replica param { Boolean } onlyIfDown return { Collection } api deleteReplica ( options ) { const self = this ; this . parameters . push ( 'action=DELETEREPLICA' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } if ( options . replica ) { this . parameters . push ( 'replica=' + options . replica ) ; } if ( options . onlyIfDown !== undefined ) { this . parameters . push ( 'onlyIfDown=' + options . onlyIfDown ) ; } return self ; } param { Object } options param { String } collection param { String } shard param { String } route param { String } node param { String } async return { Collection } api addReplica ( options ) { const self = this ; this . parameters . push ( 'action=ADDREPLICA' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } if ( options . route ) { this . parameters . push ( '_route_=' + options . route ) ; } if ( options . node ) { this . parameters . push ( 'node=' + options . node ) ; } if ( options . async ) { this . parameters . push ( 'async=' + options . async ) ; } return self ; } param { Object } options param { String } name param { String } val return { Collection } api clusterProp ( options ) { const self = this ; this . parameters . push ( 'action=CLUSTERPROP' ) ; if ( options . name ) { this . parameters . push ( 'name=' + options . name ) ; } if ( options . val !== undefined ) { this . parameters . push ( 'val=' + options . val ) ; } return self ; } param { Object } options param { String } collection param { String } targetCollection param { String } splitKey param { Number } forwardTimeout param { String } async return { Collection } api migrate ( options ) { const self = this ; this . parameters . push ( 'action=MIGRATE' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . targetCollection ) { this . parameters . push ( 'target.collection=' + options . targetCollection ) ; } if ( options . splitKey ) { this . parameters . push ( 'split.key=' + options . splitKey ) ; } if ( options . forwardTimeout !== undefined ) { this . parameters . push ( 'forward.timeout=' + options . forwardTimeout ) ; } if ( options . async ) { this . parameters . push ( 'async=' + options . async ) ; } return self ; } param { Object } options param { String } role param { String } node return { Collection } api addRole ( options ) { const self = this ; this . parameters . push ( 'action=ADDROLE' ) ; if ( options . role ) { this . parameters . push ( 'role=' + options . role ) ; } if ( options . node ) { this . parameters . push ( 'node=' + options . node ) ; } return self ; } param { Object } options param { String } role param { String } node return { Collection } api removeRole ( options ) { const self = this ; this . parameters . push ( 'action=REMOVEROLE' ) ; if ( options . role ) { this . parameters . push ( 'role=' + options . role ) ; } if ( options . node ) { this . parameters . push ( 'node=' + options . node ) ; } return self ; } return { Collection } api overseerStatus ( ) { const self = this ; this . parameters . push ( 'action=OVERSEERSTATUS' ) ; return self ; } return { Collection } api clusterStatus ( ) { const self = this ; this . parameters . push ( 'action=CLUSTERSTATUS' ) ; return self ; } param { String } requestid return { Collection } api requestStatus ( requestid ) { const self = this ; this . parameters . push ( 'action=REQUESTSTATUS' ) ; if ( requestid ) { this . parameters . push ( 'requestid=' + requestid ) ; } return self ; } return { Collection } api list ( ) { const self = this ; this . parameters . push ( 'action=LIST' ) ; return self ; } param { Object } options param { String } collection param { String } shard param { String } replica param { String } property param { String } propertyValue param { Boolean } shardUnique return { Collection } api addReplicaProp ( options ) { const self = this ; this . parameters . push ( 'action=ADDREPLICAPROP' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } if ( options . replica ) { this . parameters . push ( 'replica=' + options . replica ) ; } if ( options . property ) { this . parameters . push ( 'property=' + options . property ) ; } if ( options . propertyValue !== undefined ) { this . parameters . push ( 'property.value=' + options . propertyValue ) ; } if ( options . shardUnique !== undefined ) { this . parameters . push ( 'shardUnique=' + options . shardUnique ) ; } return self ; } param { Object } options param { String } collection param { String } shard param { String } replica param { String } property return { Collection } api deleteReplicaProp ( options ) { const self = this ; this . parameters . push ( 'action=DELETEREPLICAPROP' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . shard ) { this . parameters . push ( 'shard=' + options . shard ) ; } if ( options . replica ) { this . parameters . push ( 'replica=' + options . replica ) ; } if ( options . property ) { this . parameters . push ( 'property=' + options . property ) ; } return self ; } param { Object } options param { String } collection param { String } property param { Boolean } onlyActiveNodes param { Boolean } shardUnique return { Collection } api balanceShardUnique ( options ) { const self = this ; this . parameters . push ( 'action=BALANCESHARDUNIQUE' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . property ) { this . parameters . push ( 'property=' + options . property ) ; } if ( options . onlyActiveNodes !== undefined ) { this . parameters . push ( 'onlyActiveNodes=' + options . onlyActiveNodes ) ; } if ( options . shardUnique !== undefined ) { this . parameters . push ( 'shardUnique=' + options . shardUnique ) ; } return self ; } param { Object } options param { String } collection param { Number } maxAtOnce param { Number } maxWaitSeconds return { Collection } api rebalanceLeaders ( options ) { const self = this ; this . parameters . push ( 'action=REBALANCELEADERS' ) ; if ( options . collection ) { this . parameters . push ( 'collection=' + options . collection ) ; } if ( options . maxAtOnce !== undefined ) { this . parameters . push ( 'maxAtOnce=' + options . maxAtOnce ) ; } if ( options . maxWaitSeconds !== undefined ) { this . parameters . push ( 'maxWaitSeconds=' + options . maxWaitSeconds ) ; } return self ; } return { String } api build ( ) { return this . parameters . join ( '&' ) ; } }