# Python Client For Nutanix Lifecycle Management APIs
The Python client for Nutanix Lifecycle Management APIs is designed for Python client application developers offering them simple and flexible access to APIs that manage Infrastructure, Software and Firmware Upgrades.
## Features
- Invoke Nutanix APIs with a simple interface.
- Handle Authentication seamlessly.
- Reduce boilerplate code implementation.
- Use standard methods for installation.
## Version
- API version: v4.0
- Package version: 4.0.1
## Requirements.
Python 3.6, 3.7, 3.8 and 3.9 are fully supported and tested.
## Installation & Usage
### Installing in a virtual environment
[virtualenv](https://virtualenv.pypa.io/en/latest/) is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions. virtualenv can help you install this client without needing system install permissions. It creates an environment that has its own installation directories without sharing libraries with other virtualenv environments or the system installation.
#### Mac/Linux
To install virtualenv via pip run:
```sh
$ pip3 install virtualenv
```
Create the virtualenv and activate it
```sh
$ virtualenv -p python3 <my-env>
$ source <my-env>/bin/activate
```
Install the Nutanix client into the virtualenv
```sh
<my-env>/bin/pip install ntnx-lifecycle-py-client
```
#### Windows
To install virtualenv via pip run:
```sh
> pip install virtualenv
```
Create the virtualenv and activate it
```sh
> virtualenv <my-env>
> myenv\Scripts\activate
```
Install the Nutanix SDK into the virtualenv
```sh
<your-env>\Scripts\pip.exe install ntnx-lifecycle-py-client
```
Then import the package:
```python
import ntnx_lifecycle_py_client
```
## Getting Started
## Configuration
The python client for Nutanix Lifecycle Management APIs can be configured with the following parameters
| Parameter | Description | Required | Default Value|
|-----------|----------------------------------------------------------------------------------|----------|--------------|
| scheme | URI scheme for connecting to the cluster (HTTP or HTTPS using SSL/TLS) | No | https |
| host | IPv4/IPv6 address or FQDN of the cluster to which the client will connect to | Yes | N/A |
| port | Port on the cluster to which the client will connect to | No | 9440 |
| username | Username to connect to a cluster | Yes | N/A |
| password | Password to connect to a cluster | Yes | N/A |
| debug | Runs the client in debug mode if specified | No | False |
| verify_ssl| Verify SSL certificate of cluster the client will connect to | No | True |
| max_retry_attempts| Maximum number of retry attempts while connecting to the cluster | No | 5 |
| backoff_factor| A backoff factor to apply between attempts after the second try. | No | 3 |
| max_redirects | Maximum number of redirects to follow | No | 10 |
| logger_file | File location to which debug logs are written to | No | N/A |
| connect_timeout | Connection timeout in milliseconds for all operations | No | 30000 |
| read_timeout | Read timeout in milliseconds for all operations | No | 30000 |
| download_directory| Directory where downloaded files will be stored in | No | Current Working Directory|
| download_chunk_size | Chunk size in bytes for files to download | No | 8*1024 bytes |
| root_ca_certificate_file| PEM encoded Root CA certificate file path | No | N/A |
| client_certificate_file | PEM encoded client certificate file path | No | N/A |
| client_key_file | PEM encoded client key file path | No | N/A |
### Sample Configuration
```python
config = Configuration()
config.host = '10.19.50.27' # IPv4/IPv6 address or FQDN of the cluster
config.port = 9440 # Port to which to connect to
config.username = 'admin' # UserName to connect to the cluster
config.password = 'password' # Password to connect to the cluster
api_client = ApiClient(configuration=config)
```
### Proxy Configuration
```python
config = Configuration()
# Configure the cluster as shown previously along with the following proxy configuration
# ...
config.proxy_scheme = "https"
config.proxy_host = "127.0.0.1"
config.proxy_port = 8080
config.proxy_username = "proxy_admin"
config.proxy_password = "proxy_password"
api_client = ApiClient(configuration=config)
```
### mTLS Configuration
```python
config = Configuration()
# Configure the cluster as shown previously along with the following mTLS configuration
# (use path of your own client certificates)
# ...
config.root_ca_certificate_file = "/home/certs/ca.pem"
config.client_certificate_file = "/home/certs/AdonisService/AdonisService.crt"
config.client_key_file = "/home/certs/AdonisService/AdonisService.key"
api_client = ApiClient(configuration=config)
```
### Authentication
Nutanix APIs currently support two type of authentication schemes:
- **HTTP Basic Authentication**
- The Python client can be configured using the username and password parameters to send Basic headers along with every request.
- **API Key Authentication**
- The Python client can be configured to set an API key to send "**X-ntnx-api-key**" header with every request.
```python
config = Configuration()
config.set_api_key('abcde12345')
api_client = ApiClient(configuration=config)
```
### Additional Headers
The python client can be configured to send additional headers on each request.
```python
client = ApiClient(configuration=config)
client.add_default_header(header_name='Accept-Encoding', header_value='gzip, deflate, br')
```
### Retry Mechanism
The client can be configured to retry requests that fail with the following status codes. The numbers of seconds before which the next retry is attempted is determined by the retryInterval:
- [408 - Request Timeout](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408)
- [429 - Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429)
- [502 - Bad Gateway](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502)
- [503 - Service Unavailable](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503)
The client will also redirect requests that fail with [302 - Found](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) to the new location specified in the response header `Location`.
```{backoff factor} * (2 * ({number of retries so far} - 1))```
```python
config = Configuration()
config.max_retry_attempts = 3 # Max retry attempts while reconnecting on a loss of connection
config.backoff_factor = 3 # Backoff factor to use during retry attempts
config.max_redirects = 3 # Max number of redirects to follow
client = ApiClient(configuration=config)
```
## Usage
### Invoking an operation
```python
# 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](#additional-headers). However, sometimes headers need to be set on an individual operation basis. Nutanix APIs require that concurrent updates are protected using [ETag headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag).
```python
# 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:
# 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.
| 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](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptionfilter) 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 expanded 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. Permissible system query options are $filter,$select and $orderby. |
```python
# Initialize the API
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:
```
The list of filterable and sortable fields with expansion keys can be found in the documentation [here](https://developers.nutanix.com/).
## API Reference
This library has a full set of [API Reference Documentation](https://developers.nutanix.com/sdk-reference?namespace=lifecycle&version=v4.0&language=python). This documentation is auto-generated, and the location may change.
## License
This library is licensed under Apache 2.0 license. Full license text is available in [LICENSE](https://www.apache.org/licenses/LICENSE-2.0.txt).
## Contact us
In case of issues please reach out to us at the [mailing list](mailto:sdk@nutanix.com)
Raw data
{
"_id": null,
"home_page": null,
"name": "ntnx-lifecycle-py-client",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "Nutanix, v4, SDK, Nutanix Lifecycle Management APIs",
"author": null,
"author_email": "sdk@nutanix.com",
"download_url": "https://files.pythonhosted.org/packages/7f/95/ff096ee97e3f302386fbfd1bad8be157022f1ebff69d2778e28e4a58a62f/ntnx_lifecycle_py_client-4.0.1.tar.gz",
"platform": null,
"description": "# Python Client For Nutanix Lifecycle Management APIs\n\nThe Python client for Nutanix Lifecycle Management APIs is designed for Python client application developers offering them simple and flexible access to APIs that manage Infrastructure, Software and Firmware Upgrades.\n## Features\n- Invoke Nutanix APIs with a simple interface.\n- Handle Authentication seamlessly.\n- Reduce boilerplate code implementation.\n- Use standard methods for installation.\n\n## Version\n- API version: v4.0\n- Package version: 4.0.1\n\n## Requirements.\nPython 3.6, 3.7, 3.8 and 3.9 are fully supported and tested.\n\n\n## Installation & Usage\n\n### Installing in a virtual environment\n[virtualenv](https://virtualenv.pypa.io/en/latest/) is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions. virtualenv can help you install this client without needing system install permissions. It creates an environment that has its own installation directories without sharing libraries with other virtualenv environments or the system installation.\n\n#### Mac/Linux\nTo install virtualenv via pip run:\n```sh\n$ pip3 install virtualenv\n```\nCreate the virtualenv and activate it\n```sh\n$ virtualenv -p python3 <my-env>\n$ source <my-env>/bin/activate\n```\nInstall the Nutanix client into the virtualenv\n```sh\n<my-env>/bin/pip install ntnx-lifecycle-py-client\n```\n\n#### Windows\nTo install virtualenv via pip run:\n```sh\n> pip install virtualenv\n```\nCreate the virtualenv and activate it\n```sh\n> virtualenv <my-env>\n> myenv\\Scripts\\activate\n```\nInstall the Nutanix SDK into the virtualenv\n```sh\n<your-env>\\Scripts\\pip.exe install ntnx-lifecycle-py-client\n```\n\nThen import the package:\n```python\nimport ntnx_lifecycle_py_client\n```\n\n## Getting Started\n\n## Configuration\nThe python client for Nutanix Lifecycle Management APIs can be configured with the following parameters\n\n| Parameter | Description | Required | Default Value|\n|-----------|----------------------------------------------------------------------------------|----------|--------------|\n| scheme | URI scheme for connecting to the cluster (HTTP or HTTPS using SSL/TLS) | No | https |\n| host | IPv4/IPv6 address or FQDN of the cluster to which the client will connect to | Yes | N/A |\n| port | Port on the cluster to which the client will connect to | No | 9440 |\n| username | Username to connect to a cluster | Yes | N/A |\n| password | Password to connect to a cluster | Yes | N/A |\n| debug | Runs the client in debug mode if specified | No | False |\n| verify_ssl| Verify SSL certificate of cluster the client will connect to | No | True |\n| max_retry_attempts| Maximum number of retry attempts while connecting to the cluster | No | 5 |\n| backoff_factor| A backoff factor to apply between attempts after the second try. | No | 3 |\n| max_redirects | Maximum number of redirects to follow | No | 10 |\n| logger_file | File location to which debug logs are written to | No | N/A |\n| connect_timeout | Connection timeout in milliseconds for all operations | No | 30000 |\n| read_timeout | Read timeout in milliseconds for all operations | No | 30000 |\n| download_directory| Directory where downloaded files will be stored in | No | Current Working Directory|\n| download_chunk_size | Chunk size in bytes for files to download | No | 8*1024 bytes |\n| root_ca_certificate_file| PEM encoded Root CA certificate file path | No | N/A |\n| client_certificate_file | PEM encoded client certificate file path | No | N/A |\n| client_key_file | PEM encoded client key file path | No | N/A |\n\n\n### Sample Configuration\n```python\nconfig = Configuration()\nconfig.host = '10.19.50.27' # IPv4/IPv6 address or FQDN of the cluster\nconfig.port = 9440 # Port to which to connect to\nconfig.username = 'admin' # UserName to connect to the cluster\nconfig.password = 'password' # Password to connect to the cluster\napi_client = ApiClient(configuration=config)\n```\n\n### Proxy Configuration\n```python\nconfig = Configuration()\n# Configure the cluster as shown previously along with the following proxy configuration\n# ...\nconfig.proxy_scheme = \"https\"\nconfig.proxy_host = \"127.0.0.1\"\nconfig.proxy_port = 8080\nconfig.proxy_username = \"proxy_admin\"\nconfig.proxy_password = \"proxy_password\"\napi_client = ApiClient(configuration=config)\n```\n\n### mTLS Configuration\n```python\nconfig = Configuration()\n# Configure the cluster as shown previously along with the following mTLS configuration\n# (use path of your own client certificates)\n# ...\nconfig.root_ca_certificate_file = \"/home/certs/ca.pem\"\nconfig.client_certificate_file = \"/home/certs/AdonisService/AdonisService.crt\"\nconfig.client_key_file = \"/home/certs/AdonisService/AdonisService.key\"\napi_client = ApiClient(configuration=config)\n```\n\n### Authentication\nNutanix APIs currently support two type of authentication schemes:\n\n- **HTTP Basic Authentication**\n - The Python client can be configured using the username and password parameters to send Basic headers along with every request.\n- **API Key Authentication**\n - The Python client can be configured to set an API key to send \"**X-ntnx-api-key**\" header with every request.\n ```python\n config = Configuration()\n config.set_api_key('abcde12345')\n api_client = ApiClient(configuration=config)\n ```\n\n### Additional Headers\nThe python client can be configured to send additional headers on each request.\n\n```python\nclient = ApiClient(configuration=config)\nclient.add_default_header(header_name='Accept-Encoding', header_value='gzip, deflate, br')\n```\n\n### Retry Mechanism\nThe client can be configured to retry requests that fail with the following status codes. The numbers of seconds before which the next retry is attempted is determined by the retryInterval:\n\n- [408 - Request Timeout](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408)\n- [429 - Too Many Requests](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429)\n- [502 - Bad Gateway](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502)\n- [503 - Service Unavailable](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503)\n\nThe client will also redirect requests that fail with [302 - Found](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/302) to the new location specified in the response header `Location`.\n```{backoff factor} * (2 * ({number of retries so far} - 1))```\n\n\n```python\nconfig = Configuration()\nconfig.max_retry_attempts = 3 # Max retry attempts while reconnecting on a loss of connection\nconfig.backoff_factor = 3 # Backoff factor to use during retry attempts\nconfig.max_redirects = 3 # Max number of redirects to follow\nclient = ApiClient(configuration=config)\n```\n\n## Usage\n\n### Invoking an operation\n```python\n# Initialize the API\n# The following sample code is an example and does not reflect the real APIs provided by this client.\napi_instance = SampleApi(api_client=client) # client configured in previous step\nextId = 'extId_example' # UUID.\n\n# Get sample entity by id\ntry:\n api_response = api_instance.get_sample_entity_by_id(extId)\nexcept ApiException as e:\n```\n\n### Setting headers for individual operations\nHeaders can be configured globally on the python client using the [method to set default headers](#additional-headers). However, sometimes headers need to be set on an individual operation basis. Nutanix APIs require that concurrent updates are protected using [ETag headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag).\n\n```python\n# Initialize the API\n\n# The following sample code is an example and does not reflect the real APIs provided by this client.\napi_instance = SampleApi(api_client=client) # client configured in previous step\nextId = 'extId_example' # UUID.\n\n# Get sample entity by id\ntry:\n api_response = api_instance.get_sample_entity_by_id(extId)\nexcept ApiException as e:\n\n# Extract E-Tag Header\netag_value = ApiClient.get_etag(api_response)\n\n# The following sample code is an example and does not reflect the real APIs provided by this client.\n# Update sample entity\ntry:\n # The body parameter in the following operation is received from the previous GET request's response which needs to be updated.\n api_response = api_instance.update_sample_entity_by_id(body, extId, if_match=etag_value) # Use the extracted etag value\nexcept ApiException as e:\n```\n\n### List Operations\nList 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.\n\n| Parameter | Description\n|-----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| _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.|\n| _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|\n| _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](https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part2-url-conventions.html#sec_SystemQueryOptionfilter) conventions. |\n| _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. |\n| _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. |\n| _expand | allows clients to request related resources when a resource that satisfies a particular request is retrieved. Each expanded 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. Permissible system query options are $filter,$select and $orderby. |\n\n```python\n# Initialize the API\nbundles_api_instance = BundlesApi(api_client=client) # client configured in previous step\nextId = 'extId_example' # UUID.\n\n# Get LCM bundles on the cluster\ntry:\n api_response = bundles_api_instance.list_bundles(\n\t _page=page, # if page parameter is present\n\t _limit=limit, # if limit parameter is present\n\t _filter=_filter, # if filter parameter is present\n\t _orderby=_orderby, # if orderby parameter is present\n\t _select=select, # if select parameter is present\n\t _expand=expand) # if expand parameter is present\nexcept ApiException as e:\n\n```\nThe list of filterable and sortable fields with expansion keys can be found in the documentation [here](https://developers.nutanix.com/).\n\n## API Reference\n\nThis library has a full set of [API Reference Documentation](https://developers.nutanix.com/sdk-reference?namespace=lifecycle&version=v4.0&language=python). This documentation is auto-generated, and the location may change.\n\n## License\nThis library is licensed under Apache 2.0 license. Full license text is available in [LICENSE](https://www.apache.org/licenses/LICENSE-2.0.txt).\n\n## Contact us\nIn case of issues please reach out to us at the [mailing list](mailto:sdk@nutanix.com)\n",
"bugtrack_url": null,
"license": null,
"summary": "Nutanix Lifecycle Management APIs",
"version": "4.0.1",
"project_urls": null,
"split_keywords": [
"nutanix",
" v4",
" sdk",
" nutanix lifecycle management apis"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "af89c1262fd16aacd1b7775d78712b1a4a27ea31dc869ae6d587ae9bb1ba9649",
"md5": "bea5d5d01dcd5360517ea41a2d44d7ea",
"sha256": "39499634aa56af8aa02b8398c3d1848e34e259770145c8600497b1732f4af951"
},
"downloads": -1,
"filename": "ntnx_lifecycle_py_client-4.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bea5d5d01dcd5360517ea41a2d44d7ea",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 288498,
"upload_time": "2024-12-05T19:56:04",
"upload_time_iso_8601": "2024-12-05T19:56:04.932083Z",
"url": "https://files.pythonhosted.org/packages/af/89/c1262fd16aacd1b7775d78712b1a4a27ea31dc869ae6d587ae9bb1ba9649/ntnx_lifecycle_py_client-4.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7f95ff096ee97e3f302386fbfd1bad8be157022f1ebff69d2778e28e4a58a62f",
"md5": "d05ab0f430b3494399b1dcc434d618ff",
"sha256": "e6058079cbcf600b07b5e3ed099a79c5714b44ff790ac9c5ed0122e1a2b82a84"
},
"downloads": -1,
"filename": "ntnx_lifecycle_py_client-4.0.1.tar.gz",
"has_sig": false,
"md5_digest": "d05ab0f430b3494399b1dcc434d618ff",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 85869,
"upload_time": "2024-12-05T19:56:07",
"upload_time_iso_8601": "2024-12-05T19:56:07.025749Z",
"url": "https://files.pythonhosted.org/packages/7f/95/ff096ee97e3f302386fbfd1bad8be157022f1ebff69d2778e28e4a58a62f/ntnx_lifecycle_py_client-4.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-05 19:56:07",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "ntnx-lifecycle-py-client"
}