We introduce a systematic method to solve a type of Cartan's realization
problem. Our method builds upon a new theory of Lie algebroids and Lie
groupoids with structure group and connection. This approach allows to find
local as well as complete solutions, their symmetries, and to determine the
moduli spaces of local and complete solutions. We apply our method to the
problem of classification of extremal K\"ahler metrics on surfaces.Comment: 76 pages, 5 figures; Comments are welcome! This is the final version
submitted for publicatio