Search code examples
javajsonrestvmwarevsphere

Is there an API to map a vSphere JSON Result to an appropriate Java Object?


I am trying to use the REST API of vSphere to get information about our virtual machines. I already connected to the server using the provided REST API and I got a JSON Result from a REST request. The vSphere JSON result looks like this:

{"value":[{
        "hot_add_increment_size_MiB": 8,
        "size_MiB": 1,
        "hot_add_enabled": false,
        "hot_add_limit_MiB": 51258
     }]
}

Now I want to convert this JSON String to an appropriate Class. The problem, I am actually facing is, that it can be a very complex JSON result.

My question is: Is there an API from VMWare, I can use to solve my problem? Every hint is appreciated. Many thanks in advance.


Solution

  • The answer is no. There is schema published by VMware. It might not exist.

    You may be able to get what you want with this API (disclaimer: I am the author): https://github.com/DoubleCloudInc/vim-rest-api/

    The schema is the same as vSphere API, so you can use the vijava data objects as your Java objects. http://vijava.sf.net. Again, I am the author.