Skip to content

Latest commit

 

History

History
54 lines (32 loc) · 3.08 KB

CONTRIBUTING.md

File metadata and controls

54 lines (32 loc) · 3.08 KB

Rubrik Python SDK Development Guide

Contributions via GitHub pull requests are gladly accepted from their original author. Along with any pull requests, please state that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

Common Environment Setup

  1. Clone the Python SDK repository

    git clone https://github.com/rubrikinc/rubrik-sdk-for-python.git

  2. Change directory to the repository root dir

    cd rubrik-sdk-for-python

  3. Switch to the devel branch

    git checkout devel

  4. Create a virtual environment

    python3 -m venv venv (or for Python 2 virtualenv venv)

    Note: This requires you to install the virtualenv package: pip install virtualenv

  5. Activate the virtual environment

    . venv/bin/activate

  6. Install the SDK from Source

    python setup.py install

New Function Development

The /rubrik-sdk-for-python/rubrik_cdm directory contains all functions for the SDK.

At a high level the directory contains the following:

  • api.py - Base API Functions (get, post, etc.) that should only be touched for bug fixes.
  • cloud.py - Cloud relation functions
  • cluster.py - Functions involving the configuration of the Rubrik cluster itself (think Day 0 configurations)
  • data_management.py - Functions related to "Data Protection" taks (ex. on-demand-snapshot)
  • physical.py - Functions involving the management of Physical servers
  • rubrik_cdm.py - Several internal functions and the Connect class that all other functions are accessed through. This should only be touched for bug fixes.

When adding a new function, it would ideally fit into one of these files. Each function should have the following:

  • Each function must be idempotent. Before making any configuration changes (post, patch, delete) you should first check to see if that change is necessary. If it's not you must return a message formated as No change required. {message}: For example, the assign_sla function first checks to see if the Rubrik object is already assigned to the provided SLA Domain.
  • A doc string using the docBlockr format. Visual Studio Code users can take advantage of the autoDocstring extension to simplify this process.
  • Each API call made in the function should have a self.log() call made explaining what the API call is doing. The log message should be formated as function_name: message.
  • A corresponding example in the /rubrik-sdk-for-python/sample directory named the same as the function_name.
  • Each function also must have associated documentation which can be autogenerated through cd docs && python create_docs.py

Once a new function has been added you will then submit a new Pull Request which will be reviewed before merging into the devel branch.