Skip to main content

A Feature Flags management SDK

Project description

Installation

pip install flagsup

Integration

  • Docs: Integration doc

  • Init client

    import flagsup
    flagsup_client = flagsup.CachedFlagsupClient("https://flagsup.dev.tekoapis.net")
    
  • To get flag status (and experiment info if available) for a specific user using User IAM ID

    • batchEvaluateFlags(<flagsup.EvaluateRequest>, [<default_status>, <default_treatment>, <default_exp_id>, <default_branch_id>])
    • evaluateFlag(<flag_key>, <iam_id>, [<default_status>, <default_treatment>, <default_exp_id>, <default_branch_id>])

    It is recommended to call batchEvaluateFlags() for all your feature flags upon getting userId from IAM service Subsequently you can call evaluateFlag() to get flag value from in-memory cache

  • To get flag status when user is not logged in (note: this will disable canary release, black/white list, experiment)

    • batchGetFlags(<flag_key_list>, [<default_status>])
    • getFlag(<flag_key>, [<default_status>])

    Similar to evaluateFlag It is recommended to call batchGetFlags() for all your feature flags upon initial load Subsequently you can call getFlag() to get flag value from in-memory cache

Example

import flagsup

if __name__ == "__main__":
    # Initialisation, provide FlagSup SDK with target domain
    flagsup_client = flagsup.CachedFlagsupClient("https://flagsup.dev.tekoapis.net")

    # Option 1: Get flags with User ID

    # It is recommended to call batchEvaluateFlags() for all your feature flags upon getting userId from IAM service
    # Subsequently you can call evaluateFlag() to get flag value from in-memory cache

    # Fetch multiple flag values for the same or different users. Response is cached in memory for subsequent calls.
    # To reduce network overhead, call this to fetch all flags when your app initialise
    batch_response = flagsup_client.batch_evaluate_flag([
        flagsup.EvaluateRequest("flag01", "5f8e4768e00e4d12ba69ed3e7bf3e893"),  # pragma: whitelist secret
        flagsup.EvaluateRequest("flag02", "5f8e4768e00e4d12ba69ed3e7bf3e893"),  # pragma: whitelist secret
    ])

    # Fetch a flag value for the logged in user. Response is cached in memory for subsequent calls.
    flag_status = flagsup_client.evaluate_flag("flag01", "5f8e4768e00e4d12ba69ed3e7bf3e893")  # pragma: whitelist secret
    if flag_status:
        #  Flow when flag is enabled
        pass
    else:
        # // Flow when flag is disabled
        pass
    # Option 2: Get flags without User ID

    # Fetch multiple flag values. Response is cached in memory for subsequent calls.
    # To reduce network overhead, call this to fetch all flags when your app initialise
    batch_response = flagsup_client.batch_get_flag_status(["flag01", "flag02"])

    # Fetch a single flag value. Response is cached in memory for subsequent calls.
    flag_status = flagsup_client.get_flag_status("flag01")

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

flagsup-0.0.2.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flagsup-0.0.2-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file flagsup-0.0.2.tar.gz.

File metadata

  • Download URL: flagsup-0.0.2.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5

File hashes

Hashes for flagsup-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8b8158414349979d6621f32d876ddbebbb063d2e2baa9769bbf374e54b6c2bd9
MD5 f02dfcba2494ffcf726e06240c351a8b
BLAKE2b-256 45464a706e72b798f7ccb2c1a2586513e04adf21c47a057f97e14cad4edc2f17

See more details on using hashes here.

File details

Details for the file flagsup-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: flagsup-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.8.5

File hashes

Hashes for flagsup-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 52512521993af216a7b243e268629f428c8b52d03077ca6fe46541f648d7af19
MD5 5970ac9f645bbca0101ce6d51179d473
BLAKE2b-256 46d9f8cc6d2bb8d95e0f49140879c6ade9d87f002b4d951b5c1c5b633efeee7e

See more details on using hashes here.

Supported by

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