The following sharding mongo shell functions are implemented in client-side JS, and rely on the current layout of the config database and the collections within
If a customer wants to configure their sharded cluster outside of the shell (i.e. through a driver), they need to re-implement the above in their language of choice.
This unnecessarily exposes internal sharding implementation details to clients, which is an inappropriately fragile API for users to be dealing with. Any such client-side re-implementation of these functions is therefore brittle in the face of future changes to the sharding implementation (and upgrading across such changes would need to be very carefully managed).
The situation is similar to
SERVER-14378, where querying system.indexes and system.namespaces were replaced with the listIndexes/listCollections commands, for similar reasons. It would be useful if there was also an API (at some level) to allow users to dynamically manage sharded environments via drivers.