Skip to content

Commit 5175f1d

Browse files
chore: readme improvements (#4)
* Readme improvements * PR review feedback * More PR review feedback
1 parent ef5de7b commit 5175f1d

1 file changed

Lines changed: 61 additions & 1 deletion

File tree

README.md

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
11
# flagsmith-openfeature-provider-python
2-
Flagsmith OpenFeature provider for the python SDK
2+
3+
The Flagsmith provider allows you to connect to your Flagsmith instance through the OpenFeature SDK
4+
5+
## Python SDK usage
6+
7+
### Install dependencies
8+
9+
First, you'll need to install the OpenFeature SDK and the Flagsmith Provider.
10+
11+
```bash
12+
pip install openfeature-sdk openfeature-provider-flagsmith
13+
```
14+
15+
### Using the Flagsmith Provider with the OpenFeature SDK
16+
17+
To create a Flagsmith provider you will need to provide a number of arguments. These are shown and described
18+
below. See the [Flagsmith docs](https://docs.flagsmith.com/clients/server-side) for further information on the
19+
configuration options available for the Flagsmith python client.
20+
21+
```python
22+
from flagsmith import Flagsmith
23+
from openfeature_flagsmith.provider import FlagsmithProvider
24+
25+
provider = FlagsmithProvider(
26+
# Provide an instance of the Flagsmith python client.
27+
# Required: True
28+
client=Flagsmith(...),
29+
30+
# By enabling the use_flagsmith_defaults setting, you can instruct the OpenFeature SDK to use
31+
# the default logic included in the Flagsmith client as per the docs here:
32+
# https://docs.flagsmith.com/clients/server-side#managing-default-flags. This will override the
33+
# default provided at evaluation time in the OpenFeature SDK in most cases (excluding those where
34+
# an unexpected exception happens in the Flagsmith client itself).
35+
# Required: False
36+
# Default: False
37+
use_flagsmith_defaults=False,
38+
39+
# By default, when evaluating the boolean value of a feature in the OpenFeature SDK, the Flagsmith
40+
# OpenFeature Provider will use the 'Enabled' state of the feature as defined in Flagsmith. This
41+
# behaviour can be changed to use the 'value' field defined in the Flagsmith feature instead by
42+
# enabling the use_boolean_config_value setting.
43+
# Note: this relies on the value being defined as a Boolean in Flagsmith. If the value is not a
44+
# Boolean, an error will occur and the default value provided as part of the evaluation will be
45+
# returned instead.
46+
# Required: False
47+
# Default: False
48+
use_boolean_config_value=False,
49+
50+
# By default, the Flagsmith OpenFeature Provider will raise an exception (triggering the
51+
# OpenFeature SDK to return the provided default value) if the flag is disabled. This behaviour
52+
# can be configured by enabling this flag so that the Flagsmith OpenFeature provider ignores
53+
# the enabled state of a flag when returning a value.
54+
# Required: False
55+
# Default: False
56+
return_value_for_disabled_flags=False,
57+
)
58+
```
59+
60+
The provider can then be used with the OpenFeature client as per
61+
[the documentation](https://openfeature.dev/docs/reference/concepts/evaluation-api#setting-a-provider).
62+

0 commit comments

Comments
 (0)