Skip to main content

Confidence provider for the OpenFeature SDK

Project description

Confidence OpenFeature Python Provider

This repo contains the OpenFeature Python flag provider for Confidence.

OpenFeature

Before starting to use the provider, it can be helpful to read through the general OpenFeature docs and get familiar with the concepts.

Adding the dependency

pip install

pip install confidence-openfeature-provider==0.1.4

requirements.txt

confidence-openfeature-provider==0.1.4

pip install requirements.txt

Creating and using the flag provider

Below is an example for how to create a OpenFeature client using the Confidence flag provider, and then resolve a flag with a boolean attribute. The provider is configured with an api key and a region, which will determine where it will send the resolving requests.

The flag will be applied immediately, meaning that Confidence will count the targeted user as having received the treatment.

You can retrieve attributes on the flag variant using property dot notation, meaning test-flag.boolean-key will retrieve the attribute boolean-key on the flag test-flag.

You can also use only the flag name test-flag and retrieve all values as a map with resolve_object_details().

The flag's schema is validated against the requested data type, and if it doesn't match it will fall back to the default value.

from confidence.provider import Region
from confidence.provider import ConfidenceOpenFeatureProvider
from openfeature.api import EvaluationContext
from openfeature import api

provider = ConfidenceOpenFeatureProvider("client_secret", Region.EU)

api.set_provider(provider)
open_feature_client = api.get_client()

ctx = EvaluationContext(targeting_key="random", attributes={
    "user": {
        "country": "SE"
    }
})

flag_value = open_feature_client.get_boolean_value(flag_key="test-flag.boolean-key", default_value=False,
                                                   evaluation_context=ctx)

print(flag_value)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

confidence_openfeature_provider-0.1.4.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file confidence_openfeature_provider-0.1.4.tar.gz.

File metadata

File hashes

Hashes for confidence_openfeature_provider-0.1.4.tar.gz
Algorithm Hash digest
SHA256 9fe3829bce119c6a3ae20e8b49539304477ceeb5d69ae655f7b3f302edb1f480
MD5 9a07014890b7ac6b5a26351edfbe5e7b
BLAKE2b-256 9c6bee3e175b51321e30130cf408d5951f314649a0e2a9f07886beb632e5bf08

See more details on using hashes here.

File details

Details for the file confidence_openfeature_provider-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for confidence_openfeature_provider-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5e2247337576fb5129bc87e911d3882591025a7354457e7c3a128250d0e13d8f
MD5 2015d84336c0f859d234308975968871
BLAKE2b-256 49c918cca23a359ad8093eb856d6f7cbc9b86b8cd59df5e8be4c0834bdd80f13

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page