Introduction

The Cohesity Management SDK provides an easy-to-use language binding to harness the power of Cohesity REST APIs in your python applications.


Installation

Cohesity Management Sdk can be either installed from source or through pip.

Install via pip

pip install cohesity-management-sdk

Install from source

The generated code uses Python packages named requests, jsonpickle and dateutil. You can resolve these dependencies using pip. This SDK uses the Requests library and will work for Python 2 >=2.7.9 and Python 3 >=3.4.

* git clone https://github.com/cohesity/management-sdk-python.git
* cd management-sdk-python
* pip install -r requirements.txt
* python setup.py install

Upgrade

To upgrade the package:

pip install cohesity-management-sdk --upgrade

To upgade the package to specific release:

pip install cohesity-management-sdk==1.6.1

Note

Refer Python docs for your cluster version.


How to Use

This SDK exposes all the functionality provided by Cohesity REST API.

To initialize the API client, the following parameters need to be passed.

Parameter

Type

Description

username

string

Specifies the login name of the Cohesity user.

password

string

Specifies the password of the Cohesity user account.

domain

string

Specifies the domain the user is logging in.

  • For a Local user model, the domain is always LOCAL.

  • For LDAP / AD user models, the domain will map to an LDAP connection string.

  • A user is uniquely identified by a combination of username and domain.

cluster_vip

string

VIP or DNS name of cohesity cluster. Default: ‘{CLUSTER_VIP}’

Important

If domain is not set ‘LOCAL’ is assigned.

Initializing the Client

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
""" Sample code to create a cohesity client. """

from cohesity_management_sdk.cohesity_client import CohesityClient

username = 'Username'
password = 'Password'
domain = 'Domain' #optional
cluster_vip = 'cluster_vip'
client = CohesityClient(cluster_vip, username, password, domain)
policies_controller = client.protection_policies
result = policies_controller.get_protection_policies()
print([policy.name for policy in result])

Output

[“Gold”, “Bronze”, “Silver”]


Questions or Feedback

We would love to hear from you. Please send your questions and feedback to: cohesity-api-sdks@cohesity.com