Examples#
Invoking an operation#
Initialize the API#
# The following sample code is an example and does not reflect the real APIs provided by this client.
api_instance = SampleApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# Get sample entity by id
try:
api_response = api_instance.get_sample_entity_by_id(extId)
except ApiException as e:
Setting headers for individual operations#
Headers can be configured globally on the python client using the method to set default headers. However, sometimes headers need to be set on an individual operation basis. Nutanix APIs require that concurrent updates are protected using ETag headers.
Setting headers#
# The following sample code is an example and does not reflect the real APIs provided by this client.
api_instance = SampleApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# Get sample entity by id
try:
api_response = api_instance.get_sample_entity_by_id(extId)
except ApiException as e:
# Extract E-Tag Header
etag_value = ApiClient.get_etag(api_response)
# The following sample code is an example and does not reflect the real APIs provided by this client.
# Update sample entity
try:
# The body parameter in the following operation is received from the previous GET request's response which needs to be updated.
api_response = api_instance.update_sample_entity_by_id(body, extId, if_match=etag_value) # Use the extracted etag value
except ApiException as e:
List Operations#
List Operations for Nutanix APIs support pagination, filtering, sorting and projections. The table below details the parameters that can be used to set the options for pagination etc.
List Operations#
bundles_api_instance = BundlesApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# Get LCM bundles on the cluster
try:
api_response = bundles_api_instance.list_bundles(
_page=page, # if page parameter is present
_limit=limit, # if limit parameter is present
_filter=_filter, # if filter parameter is present
_orderby=_orderby, # if orderby parameter is present
_select=select, # if select parameter is present
_expand=expand) # if expand parameter is present
except ApiException as e: