spicyusername
Contributor
Contributor

Where to find API documentation for vsphere-automation-sdk-python

I'm trying to understand what methods are possible in the vsphere-automation-sdk-python.

I see documentation here[1] in the official GitHub that gets you started. I also see lots of samples, but I don't see anything comprehensive that outlines what methods are available for the object returned by create_vsphere_client.

 

import requests
import urllib3
from vmware.vapi.vsphere.client import create_vsphere_client
session = requests.session()

# Disable cert verification for demo purpose. 
# This is not recommended in a production environment.
session.verify = False

# Disable the secure connection warning for demo purpose.
# This is not recommended in a production environment.
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

# Connect to a vCenter Server using username and password
vsphere_client = create_vsphere_client(server='<vc_ip>', username='<vc_username>', password='<vc_password>', session=session)

# List all VMs inside the vCenter Server
vsphere_client.vcenter.VM.list() # How do I know what to do with vsphere_client?

 

Is it this[2]? I'm having trouble making sense of that.

For example I can't find where VM.list() is documented. 

Where can I find information on how to interact with Content Libraries?

There are samples for Content Library interaction here[3], but they don't outline what is possible, just demonstrate a few specific use-cases. 

[1]: https://github.com/vmware/vsphere-automation-sdk-python#connect-to-a-vcenter-server

[2]: https://vmware.github.io/vsphere-automation-sdk-python/vsphere/cloud/index.html

[3]: https://github.com/vmware/vsphere-automation-sdk-python/tree/master/samples/vsphere/contentlibrary

0 Kudos
1 Reply
spicyusername
Contributor
Contributor

The quick and dirty is to use Python's dir() function to print what methods an Object has

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_attrs', '_stub_config', 'appliance', 'content', 'tagging', 'vcenter']

 

These do in fact relate to the objects found here[1]

 

[1]: https://vmware.github.io/vsphere-automation-sdk-python/vsphere/cloud/com.vmware.html

0 Kudos