featuremanagement.aio package

Module contents

class featuremanagement.aio.FeatureFilter

Bases: ABC

Parent class for all async feature filters.

static alias(alias)

Decorator to set the alias for the filter.

Parameters:

alias (str) – Alias for the filter.

Returns:

Decorator

Return type:

callable

abstract async evaluate(context, **kwargs)

Determine if the feature flag is enabled for the given context.

Parameters:

context (Mapping) – Context for the feature flag.

property name

Get the name of the filter.

Returns:

Name of the filter, or alias if it exists.

Return type:

str

class featuremanagement.aio.FeatureManager(configuration, **kwargs)

Bases: object

Feature Manager that determines if a feature flag is enabled for the given context.

Parameters:

configuration (Mapping) – Configuration object.

Keyword Arguments:

feature_filters (list[FeatureFilter]) – Custom filters to be used for evaluating feature flags.

async is_enabled(feature_flag_id, user_id, **kwargs)

Determine if the feature flag is enabled for the given context.

Parameters:

feature_flag_id (str) – Name of the feature flag.

Returns:

True if the feature flag is enabled for the given context.

Return type:

bool

list_feature_flag_names()

List of all feature flag names.

class featuremanagement.aio.TargetingFilter

Bases: FeatureFilter

Feature Filter that determines if the user is targeted for the feature flag.

async evaluate(context, **kwargs)

Determine if the feature flag is enabled for the given context.

Keyword Arguments:

context (Mapping) – Context for evaluating the user/group.

Returns:

True if the user is targeted for the feature flag.

Return type:

bool

class featuremanagement.aio.TimeWindowFilter

Bases: FeatureFilter

Feature Filter that determines if the current time is within the time window.

async evaluate(context, **kwargs)

Determine if the feature flag is enabled for the given context.

Keyword Arguments:

context (Mapping) – Mapping with the Start and End time for the feature flag.

Returns:

True if the current time is within the time window.

Return type:

bool