Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import init_api_client
import swagger_client
from swagger_client.rest import ApiException
# Initialize SDK and parse the args for connection details
args = init_api_client.parse_arguments()
api_client = init_api_client.get_api_client(args)
# Create search API client object
search_api = swagger_client.SearchApi()
# Create request parameters required for search APIs, searching for all VMs in a certain vCenter
filter_string = "vcenter_manager.name = 'my-vcenter'"
public_api_search_request_params = dict(entity_type=swagger_client.EntityType.VIRTUALMACHINE, filter=filter_string, size=100)
# Create payload from search parameters required for calling the search API & call the search API
search_payload = swagger_client.SearchRequest(**public_api_search_request_params)
api_response = search_api.search_entities(body=search_payload)
# Print the output. This will be a list of entity ids
print(api_response)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.