The Cohesity App SDK provides an easy-to-use language binding to harness the power of Cohesity App APIs in your python applications.These APIs are available for apps running on Cohesity Apps Infrastructure.
The generated code uses Python packages named requests, jsonpickle and dateutil.
You can resolve these dependencies using pip ( https://pip.pypa.io/en/stable/ ).
This SDK uses the Requests library and will work for Python 2 >=2.7.9 and Python 3 >=3.4.
- Invoke
git clone https://github.com/cohesity/app-sdk-python.git cd app-sdk-python- Invoke
pip install -r requirements.txt - Install cohesity_management_package:
python setup.py install. This will install the package in PYTHONPATH.
The following section explains how to use the cohesity_app_sdk package
in a new project.
The App Environment Container has the following parameters initialized by Athena.
HOST_IP
APPS_API_ENDPOINT_IP
POD_UID
APPS_API_ENDPOINT_PORT
APP_AUTHENTICATION_TOKEN
We use the above variables in various usecases to initialize and make call to Athena App server.
In order to setup authentication and initialization of the API client, you need the following information.
# Configuration parameters and credentials
import os
from cohesity_app_sdk.app_client import AppClient
app_auth_token = os.getenv('APP_AUTHENTICATION_TOKEN')
app_endpoint_ip = os.getenv('APPS_API_ENDPOINT_IP')
app_endpoint_port = os.getenv('APPS_API_ENDPOINT_PORT')
app_client = AppClient(app_auth_token, app_endpoint_ip, app_endpoint_port)An instance of the MountController class can be accessed from the API Client.
mount = app_client.mountAllows you to mount a view/namespace.
def create_mount(self, mount_options)
| Parameter |
|---|
| mountOptions |
mount_options = MountOptions()
mount.create_mount(mount_options)| Error Code | Error Description |
|---|---|
| 400 | Validation errors. |
| 401 | Invalid token. |
| 500 | Unexpected error. |
Unmount previously mounted view/namespace.
def delete_unmount(self, dir_name)| Parameter | Tags | Description |
|---|---|---|
| dirName | Required |
Name of the mount directory. |
dir_name = 'dirName'
mount.delete_unmount(dir_name)| Error Code | Error Description |
|---|---|
| 400 | Invalid parameters. |
| 401 | Invalid token. |
| 404 | Directory doesn't exist. |
| 500 | Unexpected error. |
An instance of the Settings class can be accessed from the API Client.
settings_controller = app_client.settingsReturns app settings object.
def get_app_settings(self)result = settings_controller.get_app_settings()| Error Code | Error Description |
|---|---|
| 401 | Invalid token |
| 500 | Unexpected error |
An instance of the TokenManagement class can be accessed from the API Client.
token_management = app_client.token_managementUse this api to get a new management api token.
def create_management_access_token(self)# This example shows interaction of management token got from App SDK to
# Cohesity Management SDK.
from cohesity_management_sdk.cohesity_client import CohesityClient
token = token_management.create_management_access_token()
cluster_ip = os.getenv('HOST_IP')
cohesity_client = CohesityClient(cluster_vip=cluster_ip, auth_token=token)
cohesity_client.cluster.get_basic_cluster_info() | Error Code | Error Description |
|---|---|
| 401 | Invalid token. |
| 500 | Unexpected error. |
The generated code will pick up the default configurations from cohesity_app_sdk/configuration.py, hence, you can use configuration.py to set the attributes such as App Endpoint IP, App Endpoint Port etc before compilation.
Note : These parameters can be easily overwritten in scripts. Please refer to sample_app.py
We would love to hear from you. Please send your questions and feedback to: developer@cohesity.com

