-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathgetting_started.py
More file actions
47 lines (36 loc) · 1.42 KB
/
getting_started.py
File metadata and controls
47 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import logging
from featureflags.client import CfClient
from featureflags.config import *
from featureflags.evaluations.auth_target import Target
from featureflags.util import log
import os
import time
# API Key
api_key = os.getenv('FF_API_KEY', "")
# Flag Name
flagName = os.getenv('FF_FLAG_NAME', "test")
configURL = os.environ.get("FF_CONFIG_URL", "https://ffserver:8000/api/1.0")
eventsURL = os.environ.get("FF_CONFIG_URL", "https://ffserver:8001/api/1.0")
def main():
log.setLevel(logging.INFO)
log.info("Harness SDK Getting Started")
# Create a Feature Flag Client
client = CfClient(api_key,
with_base_url(configURL),
with_events_url(eventsURL),
with_tls_trusted_cas_file(
"/Users/andrewbell/dev/andyb-tls-scripts/sdk"
"/examples_from_scratch/python-sdk-from-scratch/CA"
".crt"))
client.wait_for_initialization()
# Create a target (different targets can get different results based on
# rules)
target = Target(identifier='HT_1', name="Harness_Target_1",
attributes={"location": "emea"})
# Loop forever reporting the state of the flag
while True:
result = client.bool_variation(flagName, target, False)
log.info("%s flag variation %s", flagName, result)
time.sleep(10)
if __name__ == "__main__":
main()