An apparatus for generating electrical power, the apparatus comprising: at least one housing assembly including: a housing located at a tubular configured to be disposed in a borehole in a resource bearing formation, the tubular including a tubular conduit through which a borehole fluid is circulated, the housing including a fluid chamber configured to receive the borehole fluid; one or more conductive coils surrounding the fluid chamber; and a reciprocating magnetic shuttle disposed in the fluid chamber and dividing the fluid chamber into a first volume and a second volume; a first conduit connected to the first volume, and a second conduit connected to the second volume, the first conduit and the second conduit extending from the tubular conduit to an annulus in the borehole; and at least one switching assembly configured to alternate between a first operating state and a second operating state, wherein the first volume is in fluid communication with the annulus via the first conduit and the second volume is in fluid communication with the tubular conduit via the second conduit when the switching assembly is in the first operating state, and the first volume is in fluid communication with the tubular conduit via the first conduit and the second volume is in fluid communication with the annulus via the second conduit when the switching assembly is in the second operating state, wherein the switching assembly is configured to alternate between the first operating state and the second operating state to alternate a direction of a differential pressure between the first volume and the second volume and cause the magnetic shuttle to move in a reciprocating motion and generate an electric current in the one or more conductive coils, the switching assembly including at least one switching device (98, 100) configured to control the direction of the differential pressure based on at least one of: an axial location of the magnetic shuttle in the fluid chamber being within a proximity of the at least one switching device (98, 100); a mechanical contact between the at least one switching device (98, 100) and the magnetic shuttle; an electrical contact between the at least one switching device (98, 100) and the magnetic shuttle; and an increase in fluid pressure on the at least one switching device (98, 100) caused by movement of the magnetic shuttle toward the at least one switching device (98, 100). a housing located at a tubular configured to be disposed in a borehole in a resource bearing formation, the tubular including a tubular conduit through which a borehole fluid is circulated, the housing including a fluid chamber configured to receive the borehole fluid; one or more conductive coils surrounding the fluid chamber; and a reciprocating magnetic shuttle disposed in the fluid chamber and dividing the fluid chamber into a first volume and a second volume; a first conduit connected to the first volume, and a second conduit connected to the second volume, the first conduit and the second conduit extending from the tubular conduit to an annulus in the borehole; and at least one switching assembly configured to alternate between a first operating state and a second operating state, wherein the first volume is in fluid communication with the annulus via the first conduit and the second volume is in fluid communication with the tubular conduit via the second conduit when the switching assembly is in the first operating state, and the first volume is in fluid communication with the tubular conduit via the first conduit and the second volume is in fluid communication with the annulus via the second conduit when the switching assembly is in the second operating state, wherein the switching assembly is configured to alternate between the first operating state and the second operating state to alternate a direction of a differential pressure between the first volume and the second volume and cause the magnetic shuttle to move in a reciprocating motion and generate an electric current in the one or more conductive coils, the switching assembly including at least one switching device (98, 100) configured to control the direction of the differential pressure based on at least one of: an axial location of the magnetic shuttle in the fluid chamber being within a proximity of the at least one switching device (98, 100); a mechanical contact between the at least one switching device (98, 100) and the magnetic shuttle; an electrical contact between the at least one switching device (98, 100) and the magnetic shuttle; and an increase in fluid pressure on the at least one switching device (98, 100) caused by movement of the magnetic shuttle toward the at least one switching device (98, 100).