Examples#
Invoking an operation#
placement_policies_api_instance = PlacementPoliciesApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# Get an image placement policy.
try:
api_response = placement_policies_api_instance.get_placement_policy_by_ext_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.
placement_policies_api_instance = PlacementPoliciesApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# Get an image placement policy.
try:
api_response = placement_policies_api_instance.get_placement_policy_by_ext_id(extId)
except ApiException as e:
# Extract E-Tag Header
etag_value = ApiClient.get_etag(api_response)
# Update an image placement policy.
try:
# The body parameter in the following operation is received from the previous GET request's response which needs to be updated.
api_response = placement_policies_api_instance.update_placement_policy_by_ext_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.
Parameter |
Description |
---|---|
_page |
specifies the page number of the result set. Must be a positive integer between 0 and the maximum number of pages that are available for that resource. Any number out of this range will lead to no results being returned. |
_limit |
specifies the total number of records returned in the result set. Must be a positive integer between 0 and 100. Any number out of this range will lead to a validation error. If the limit is not provided a default value of 50 records will be returned in the result set |
_filter |
allows clients to filter a collection of resources. The expression specified with $filter is evaluated for each resource in the collection, and only items where the expression evaluates to true are included in the response. Expression specified with the $filter must conform to the OData V4.01 URL conventions. |
_orderby |
allows clients to specify the sort criteria for the returned list of objects. Resources can be sorted in ascending order using asc or descending order using desc. If asc or desc are not specified the resources will be sorted in ascending order by default. For example, ‘orderby=templateName desc’ would get all templates sorted by templateName in desc order. |
_select |
allows clients to request a specific set of properties for each entity or complex type. Expression specified with the $select must conform to the OData V4.01 URL conventions. If a $select expression consists of a single select item that is an asterisk (i.e. *), then all properties on the matching resource will be returned. |
_expand |
allows clients to request related resources when a resource that satisfies a particular request is retrieved. Each expand item is evaluated relative to the entity containing the property being expanded. Other query options can be applied to an expanded property by appending a semicolon-separated list of query options, enclosed in parentheses, to the property name. Allowed system query options are $filter,$select, $orderby. |
placement_policies_api_instance = PlacementPoliciesApi(api_client=client) # client configured in previous step
extId = 'extId_example' # UUID.
# List image placement policies.
try:
api_response = placement_policies_api_instance.get_placement_policies_list(
_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: