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 ProtectedSourceVolumeInfo
class can be accessed from the API Client.
protected_source_volume_info_controller = client.protected_source_volume_info
Gets the list of volumes for a snapshot of a protected source.
def get_protected_source_volume_info(self,
source_id)
Parameter | Tags | Description |
---|---|---|
sourceId | Required |
Unique ID of the protected source. |
source_id = 169
result = protected_source_volume_info_controller.get_protected_source_volume_info(source_id)
Error Code | Error Description |
---|---|
401 | Unauthorized |
404 | Snapshot does not exist. |
500 | Unexpected error |
502 | Bad Gateway. |
504 | Gateway Timeout. |
An instance of the Volume
class can be accessed from the API Client.
volume_controller = client.volume
Gets the status of persistent volume owned by this app.
def get_volume(self,
volume_name)
Parameter | Tags | Description |
---|---|---|
volumeName | Required |
Name of the volume unique within the app instance. |
volume_name = 'volumeName'
result = volume_controller.get_volume(volume_name)
Error Code | Error Description |
---|---|
401 | Unauthorized |
404 | Volume doesn't exist. |
500 | Unexpected error |
502 | Bad Gateway. |
504 | Gateway Timeout. |
Delete a previously created persistent volume owned by this app.
def delete_volume(self,
volume_name)
Parameter | Tags | Description |
---|---|---|
volumeName | Required |
Name of the volume unique within the app instance. |
volume_name = 'volumeName'
volume_controller.delete_volume(volume_name)
Error Code | Error Description |
---|---|
400 | Invalid parameters. |
401 | Unauthorized. |
404 | Volume doesn't exist. |
500 | Unexpected error. |
502 | Bad Gateway. |
504 | Gateway Timeout. |
Use this API to create a new kubernetes persistent volume backed up by cohesity view.
def create_volume(self,
volume_name,
volume_spec)
Parameter | Tags | Description |
---|---|---|
volumeName | Required |
Name of the volume unique within the app instance. |
volumeSpec | Required |
TODO: Add a parameter description |
volume_name = 'volumeName'
volume_spec = VolumeSpec()
volume_controller.create_volume(volume_name, volume_spec)
Error Code | Error Description |
---|---|
401 | Unauthorized. |
409 | Volume already exists with different parameters. |
500 | Unexpected error. |
502 | Bad Gateway. |
504 | Gateway Timeout. |
An instance of the TokenManagement
class can be accessed from the API Client.
token_management_controller = client.token_management
Use this api to get a new management api token.
def create_management_access_token(self)
result = token_management_controller.create_management_access_token()
Error Code | Error Description |
---|---|
401 | Invalid token. |
500 | Unexpected error. |
502 | Bad Gateway. |
504 | Gateway Timeout. |
An instance of the Settings
class can be accessed from the API Client.
settings_controller = client.settings
Returns app settings object.
def get_app_settings(self)
result = settings_controller.get_app_settings()
Error Code | Error Description |
---|---|
401 | Invalid token |
500 | Unexpected error |
502 | Bad Gateway. |
504 | Gateway Timeout. |
An instance of the MountController
class can be accessed from the API Client.
mount_controller = client.mount
Unmount previously mounted view/namespace or volume of a protected entity.
def delete_unmount(self,
dir_name)
Parameter | Tags | Description |
---|---|---|
dirName | Required |
Name of the mount directory. |
dir_name = 'dirName'
mount_controller.delete_unmount(dir_name)
Error Code | Error Description |
---|---|
400 | Invalid parameters. |
401 | Invalid token. |
404 | Directory doesn't exist. |
500 | Unexpected error. |
502 | Bad Gateway. |
504 | Gateway Timeout. |
Allows you to mount a cohesity external view or snapshots of a protected object (VM volumes or NAS).
def create_mount(self,
mount_options)
Parameter | Tags | Description |
---|---|---|
mountOptions | Required |
TODO: Add a parameter description |
mount_options = MountOptions()
mount_controller.create_mount(mount_options)
Error Code | Error Description |
---|---|
400 | Validation errors. |
401 | Invalid token. |
500 | Unexpected error. |
502 | Bad Gateway. |
504 | Gateway Timeout. |