API

Utilities

Generator Module.

Generates templates using jinja.

class relay_commander.generators.ConfigGenerator

Abstract configuration generator using Jinja

generate_relay_config(environments)

Generate ld-relay.conf file.

validator module

Helper functions to validate CLI input

relay_commander.validator.validateState(state)

Validate State Argument

Checks that either ‘on’ or ‘off’ was entered as an argument to the CLI and make it lower case.

Parameters:state – state to validate
relay_commander.replayBuilder.checkLocal()

Check for directories and create if not already there

relay_commander.replayBuilder.createFile(project, environment, feature, state)

Create file with RC command that will be called against LaunchDarkly API.

Parameters:
  • Project – LaunchDarkly Project
  • environment – LaunchDarkly Environment
  • feature – LaunchDarkly Feature
  • state – State to update feature flag
relay_commander.replayBuilder.executeReplay(logger=None)

Execute commands

  1. Itereate through files created in ./replay/toDO
  2. Execute the command inside each file
  3. Move the file to the archive.

Wrappers

ld module

Wrapper for the LaunchDarkly API

Reference API - https://pypi.org/project/launchdarkly-api/

class relay_commander.ld.LaunchDarklyApi(apiKey, projectKey=None, environmentKey=None, logger=None)

Wrapper for the LaunchDarkly API

formatHostname(key)

Returns formatted hostname for an environment.

Parameters:key – environment key
getEnvironments(projectKey)

Returns List of Environments for a Project.

Includes name, key, and mobile key, and formatted hostname.

Parameters:projectKey – Key for project
Returns:Collection of Environments
updateFlag(state, featureKey)

Update the flag status for the specified feature flag

Parameters:
  • state – New feature flag state
  • featureKey – Feature flag key
Returns:

boolean status of the feature flag attribute “on”

relay_commander.redis

A Redis Wrapper

class relay_commander.redis.RedisConention(host, port)

Redis Connetion

Parameters:
  • host – hostname for redis
  • port – port for redis
class relay_commander.redis.RedisWrapper(host, port, logger, projectKey, environmentKey)

Relay Specific Redis Wrapper.

Parameters:
  • projectKey – LaunchDarkly project key
  • environmentKey – LaunchDarkly environment key.
  • conn – (optional) redis connection string
_formatKeyName()

Return formatted redis key name.

static connectionStringParser(uri)

Parse Connection string to extract host and port.

Parameters:uri – full URI for redis connection in the form of

host:port

Returns:list of RedisConnection objects
getFlagRecord(featureKey)

Get feature flag record from redis.

Parameters:featureKey – key for feature flag
updateFlagRecord(state, featureKey)

Update redis record with new state.

Parameters:
  • state – state for feature flag
  • featureKey – key for feature flag