Getting started with Python SDK

2 minute read
This is legacy documentation

CloudBees Feature Management is now part of CloudBees Unify. For current feature management documentation, go to CloudBees Unify Feature management.

This documentation covers the original CloudBees Feature Management product (formerly Rollout.io), which is end-of-life. It remains available only for existing customers who are migrating to CloudBees Unify.

Support during the extension period

Because CloudBees Feature Management is an end-of-life product, support during the extension period is limited to critical items only:

  • Critical security fixes: High-impact security issues are in scope and will be addressed.

  • Critical bug fixes: Reviewed case by case; resolution is not guaranteed.

  • General support, enhancements, and non-critical fixes: Not provided for end-of-life products during the extension period.

This coverage is consistent with the CloudBees end-of-life policy in the support Terms & Conditions.

This section describes how to set up and install the Python SDK and how to deploy a feature flag.

Step 1 - Setting up

The following are prerequisites for installing the Python SDK:

  1. Create a CloudBees Feature Management account. See Signup Page to create an account.

  2. Get your environment key. Copy your environment key from App settings > Environments > Key.

Step 2 - Installing the Python SDK

Add the CloudBees Feature Management Python package to your application:

$ pip install rox
▼

Add the following lines of code to your application:

# Import SDK from rox.server.rox_server import Rox from rox.server.flags.rox_flag import RoxFlag from rox.core.entities.rox_string import RoxString from rox.core.entities.rox_int import RoxInt from rox.core.entities.rox_double import RoxDouble # Create Roxflags in the Flags container class class Flags: def __init__(self): #Define the feature flags self.enableTutorial = RoxFlag(False) self.titleColors = RoxString('White', ['White', 'Blue', 'Green', 'Yellow']) self.page = RoxInt(1, [1, 2, 3]) self.percentage = RoxDouble(99.9, [10.5, 50.0, 99.9]) flags = Flags() # Register the flags container Rox.register(flags) # Setup the environment key cancel_event = Rox.setup("<ROLLOUT-ENV-KEY>").result(); # Boolean flag example print('enableTutorial is {}'.format(flags.enableTutorial.is_enabled())) # String flag example print('color is {}'.format(flags.titleColors.get_value())) # Int flag example print('page is {}'.format(flags.page.get_value())) # Double flag example print('percentage is {}'.format(flags.percentage.get_value()))
▼

Container class registration and environment key setup

  • You cannot call Rox.setup() twice in the same runtime.

Run your application

Running the application

The flag name is automatically added to the CloudBees Feature Management dashboard after running the application.