Skip to content

Commit b6fc1d4

Browse files
authored
FFM-3760 Standardise sample code (#63)
* FFM-3760 1.1.10 Standardise sample code FFM-3760 1.1.10 Standardise sample code FFM-3760 1.1.10 Standardise sample code FFM-3760 1.1.10 Standardise sample code FFM-3760 1.1.10 Standardise sample code * FFM-3760 1.1.10 Standardise sample code
1 parent e51f3d9 commit b6fc1d4

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,14 @@ def main():
6565
client = CfClient(apiKey)
6666

6767
# Create a target (different targets can get different results based on rules. This include a custom attribute 'location')
68-
target = Target(identifier='pythonSDK', name="PythonSDK", attributes={"location": "emea"})
68+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
6969

7070
# Loop forever reporting the state of the flag
7171
while True:
7272
result = client.bool_variation(flagName, target, False)
7373
log.info("Flag variation %s", result)
7474
time.sleep(10)
7575

76-
close()
77-
7876

7977
if __name__ == "__main__":
8078
main()

examples/bool_variation_example/bool_variation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
api_key = "Your API Key"
1010
client = CfClient(api_key)
1111

12-
target = Target(identifier='harness')
12+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
1313

1414
while True:
1515
result = client.bool_variation('identifier_of_your_bool_flag', target, False)

examples/cleanup_example/cleanup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def main():
99
api_key = "Your API key"
1010
client = CfClient(api_key)
1111

12-
target = Target(identifier='harness')
12+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
1313

1414
for x in range(10):
15-
result = client.bool_variation('your_flag_identifier', target, False)
15+
result = client.bool_variation('harnessappdemodarkmode', target, False)
1616
log.debug("Result %s", result)
1717
time.sleep(10)
1818

examples/getting_started/getting_started.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,26 @@
77

88

99
# API Key
10-
apiKey = os.getenv('FF_API_KEY', "")
10+
api_key = os.getenv('FF_API_KEY', "")
1111

1212
# Flag Name
1313
flagName = os.getenv('FF_FLAG_NAME', "harnessappdemodarkmode")
1414

1515
def main():
1616
log.info("Harness SDK Getting Started")
1717
# Create a Feature Flag Client
18-
client = CfClient(apiKey)
18+
client = CfClient(api_key)
1919

2020

2121
# Create a target (different targets can get different results based on rules)
22-
target = Target(identifier='pythonSDK', name="PythonSDK", attributes={"location": "emea"})
22+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
2323

2424
# Loop forever reporting the state of the flag
2525
while True:
2626
result = client.bool_variation(flagName, target, False)
2727
log.info("%s flag variation %s", flagName, result)
2828
time.sleep(10)
2929

30-
close()
3130

3231

3332
if __name__ == "__main__":

examples/json_variation_example/json_variation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def main():
99
api_key = "Your API Key"
1010
client = CfClient(api_key)
1111

12-
target = Target(identifier='harness')
12+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
1313

1414
while True:
1515
result = client.json_variation('identifier_of_your_json_flag', target, {})

examples/simple_example/simple_example.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1+
import os
12
import time
23

34
from featureflags.client import CfClient
45
from featureflags.config import *
56
from featureflags.evaluations.auth_target import Target
67
from featureflags.util import log
78

9+
api_key = os.getenv('FF_API_KEY', "")
810

911
def main():
1012
# Create a Feature Flag Client
11-
client = CfClient("c9b3f14f-6336-4d23-83b4-73f29d1ebeeb")
13+
client = CfClient(apiKey)
1214

1315
# Create a target (different targets can get different results based on rules that you add in the UI).
14-
target = Target(identifier='mytarget', name="FriendlyName")
16+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
1517

1618
# Loop forever reporting the state of the flag. If there is an error the default value will be returned
1719
while True:
18-
result = client.bool_variation('simpleboolflag', target, False)
20+
result = client.bool_variation('harnessappdemodarkmode', target, False)
1921
log.info("Flag variation %s", result)
2022
time.sleep(10)
2123

22-
close()
2324

2425

2526
if __name__ == "__main__":

examples/url_change_example/url_change.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
import time
23

34
from featureflags.evaluations.auth_target import Target
@@ -9,15 +10,15 @@
910

1011
def main():
1112
log.debug("Starting example")
12-
api_key = "Your API key"
13+
api_key = os.getenv('FF_API_KEY', "")
1314
client = CfClient(api_key,
1415
with_base_url("https://config.ff.harness.io/api/1.0"),
1516
with_events_url("https://events.ff.harness.io/api/1.0"))
1617

17-
target = Target(identifier='harness')
18+
target = Target(identifier='HT_1', name="Harness_Target_1", attributes={"location": "emea"})
1819

1920
while True:
20-
result = client.bool_variation('your_flag_identifier', target, False)
21+
result = client.bool_variation('harnessappdemodarkmode', target, False)
2122
log.debug("Result %s", result)
2223
time.sleep(10)
2324

0 commit comments

Comments
 (0)